本文整理匯總了Java中jxl.write.WritableFont.NO_BOLD屬性的典型用法代碼示例。如果您正苦於以下問題:Java WritableFont.NO_BOLD屬性的具體用法?Java WritableFont.NO_BOLD怎麽用?Java WritableFont.NO_BOLD使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類jxl.write.WritableFont
的用法示例。
在下文中一共展示了WritableFont.NO_BOLD屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createIndex
/**
* Create the index worksheet.
*
* <p>This also creates links back to the index in each of the worksheets.</p>
*/
public void createIndex() {
WritableSheet sheet = workbook.createSheet(spreadsheetifyName("Index"), 0);
createTitle(sheet, "Index");
try {
// Create links for each worksheet, apart from the first sheet which is the
// index we're currently creating
final String[] names = workbook.getSheetNames();
for (int currentSheet = 1; currentSheet < names.length; currentSheet++) {
// Create the link from the index to the table's worksheet
WritableHyperlink link = new WritableHyperlink(0, currentSheet - 1 + NUMBER_OF_ROWS_IN_TITLE, names[currentSheet], workbook.getSheet(currentSheet), 0, 0);
sheet.addHyperlink(link);
//Add the filename in column B (stored in cell B2 of each sheet)
String fileName = workbook.getSheet(currentSheet).getCell(1, 1).getContents();
Label fileNameLabel = new Label(1, currentSheet - 1 + NUMBER_OF_ROWS_IN_TITLE, fileName);
WritableFont fileNameFont = new WritableFont(WritableFont.ARIAL,10,WritableFont.NO_BOLD,false,UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
WritableCellFormat fileNameFormat = new WritableCellFormat(fileNameFont);
fileNameLabel.setCellFormat(fileNameFormat);
sheet.addCell(fileNameLabel);
// Create the link back to the index
link = new WritableHyperlink(0, 1, "Back to index", sheet, 0, currentSheet + NUMBER_OF_ROWS_IN_TITLE - 1);
workbook.getSheet(currentSheet).addHyperlink(link);
//Set column A of each sheet to be wide enough to show "Back to index"
workbook.getSheet(currentSheet).setColumnView(0, 13);
}
// Make Column A fairly wide to show tab names and hide column B
sheet.setColumnView(0, 35);
sheet.setColumnView(1, 0);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例2: getFormatRed
/**
* @return the formatRed
*/
public WritableCellFormat getFormatRed() throws Exception{
// if(formatRed == null){
formatRed=new WritableCellFormat();
formatRed.setAlignment(jxl.format.Alignment.CENTRE);
formatRed.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
WritableFont wf_color = new WritableFont(WritableFont.ARIAL,10,WritableFont.NO_BOLD,false,UnderlineStyle.NO_UNDERLINE,Colour.RED);
WritableCellFormat wff_color = new WritableCellFormat(wf_color);
formatRed.setBorder(Border.ALL, BorderLineStyle.THIN);
formatRed.setFont(wf_color);
// }
return formatRed;
}
示例3: updateFont
private void updateFont() {
font = new WritableFont(fontName, fontSize, bold ? WritableFont.BOLD : WritableFont.NO_BOLD);
}
示例4: createFileAndUpload
public static boolean createFileAndUpload(String merCode, String startDate, String endDate,String date,String date_hms){
boolean fileFlag = false;
try{
List<MerFundStance> dataList = merFundStanceDAO.queryMerFundStanceDataLst(merCode, startDate, endDate);
String basePath = "/var/www/apps/java/data/shls";
File f1 = new File(basePath);
if (!f1.exists()) {
f1.mkdirs();
}
File f2 = new File(basePath + "/" + merCode);//判斷基礎路徑下商戶文件夾是否存在,若不存在則創建
if (!f2.exists()) {
f2.mkdirs();
}
File f = new File(basePath + "/" + merCode + "/" +date);//判斷路徑下日期文件夾是否存在,若不存在則創建
if (!f.exists()) {
f.mkdirs();
}
log.info("開始創建excel文件");
log.info(pingJie.getStringPingJie("開始創建excel文件,全路徑為:",basePath , "/" , merCode , "/" , date+ "/" , date_hms , "_shls.xls"));
WritableWorkbook wbook = Workbook.createWorkbook(new File(basePath + "/" + merCode + "/" + date
+ "/" + date_hms + "_shls.xls"));
WritableSheet wsheet = wbook.createSheet("商戶流水", 0);
// 設置excel裏的字體
WritableFont wf = new WritableFont(WritableFont.ARIAL, 12,WritableFont.NO_BOLD, false);
// 給標題規定字體的格式
WritableCellFormat titleFormat = new WritableCellFormat(wf);
Label excelTitle = new Label(0, 0, "商戶號",titleFormat);
wsheet.addCell(excelTitle);
Label excelTitle1 = new Label(1, 0, "交易日期",titleFormat);
wsheet.addCell(excelTitle1);
Label excelTitle2 = new Label(2, 0, "交易金額",titleFormat);
wsheet.addCell(excelTitle2);
Label excelTitle3 = new Label(3, 0, "變動金額",titleFormat);
wsheet.addCell(excelTitle3);
Label excelTitle4 = new Label(4, 0, "賬戶餘額",titleFormat);
wsheet.addCell(excelTitle4);
Label excelTitle5 = new Label(5, 0, "簡短說明",titleFormat);
wsheet.addCell(excelTitle5);
if(dataList != null && dataList.size() > 0){
int dataCount = 1;
String tradeDate = null;
String tradeTime = null;
for (MerFundStance merFundStance : dataList) {
Label excelTitle_mer_code = new Label(0, dataCount, merFundStance.getMerCode().getId(), titleFormat);
wsheet.addCell(excelTitle_mer_code);
tradeDate = merFundStance.getTradeTime().toString().substring(0, 10).replace("-", "");
tradeTime = merFundStance.getTradeTime().toString().substring(11, 19).replace(":", "");
Label excelTitle_trade_time = new Label(1, dataCount, tradeDate + tradeTime, titleFormat);
wsheet.addCell(excelTitle_trade_time);
Label excelTitle_mer_fee = new Label(2, dataCount, String.format("%.2f", merFundStance.getTradeAmount()), titleFormat);
wsheet.addCell(excelTitle_mer_fee);
Label excelTitle_change_amount = new Label(3, dataCount, String.format("%.2f", merFundStance.getChangeAmount()), titleFormat);
wsheet.addCell(excelTitle_change_amount);
Label excelTitle_account_amount = new Label(4, dataCount, String.format("%.2f", merFundStance.getAccountAmount()), titleFormat);
wsheet.addCell(excelTitle_account_amount);
Label excelTitle_derc_status = new Label(5, dataCount, cn.com.chinaebi.dz.object.util.DercStatusConvert.getDercStatus(merFundStance.getDercStatus()), titleFormat);
wsheet.addCell(excelTitle_derc_status);
dataCount ++;
}
}else{
log.debug(pingJie.getStringPingJie("根據請求參數查詢數據為空"));
}
// 寫入文件
wbook.write();
wbook.close();
fileFlag = true;
log.info("文件創建成功");
}catch(Exception e){
log.error(e);
}
return fileFlag;
}
示例5: exportExcel
public static void exportExcel(String name, String[] head,
String[][] content) throws Exception {
// FileChooser
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.SAVE_DIALOG
| JFileChooser.DIRECTORIES_ONLY);
chooser.showDialog(null, null);
File fi = chooser.getSelectedFile();
if (fi == null) {
return;
} else {
String f = fi.getAbsolutePath() + "/" + name;
File file = new File(f);
if (!file.exists()) {
file.createNewFile();
}
WritableWorkbook book = Workbook.createWorkbook(file);
WritableSheet sheet = book.createSheet("第一頁", 0);
SheetSettings setting = sheet.getSettings();
setting.setVerticalFreeze(1);
// 第一行字體
WritableFont headFont = new WritableFont(
WritableFont.createFont("微軟雅黑"), 10, WritableFont.BOLD);
WritableCellFormat headF = new WritableCellFormat(headFont);
headF.setAlignment(Alignment.CENTRE); // 平行居中
headF.setVerticalAlignment(VerticalAlignment.CENTRE); // 垂直居中
// 表格內容字體
WritableFont contentFont = new WritableFont(
WritableFont.createFont("微軟雅黑"), 9, WritableFont.NO_BOLD);
WritableCellFormat contentF = new WritableCellFormat(contentFont);
contentF.setAlignment(Alignment.CENTRE); // 平行居中
contentF.setVerticalAlignment(VerticalAlignment.CENTRE); // 垂直居中
int column = head.length;
// 不包括頭
int row = content.length;
for (int i = 0; i < column; i++)
sheet.addCell(new Label(i, 0, head[i], headF));
for (int i = 0; i < row; i++)
for (int j = 0; j < column; j++)
sheet.addCell(new Label(j, i + 1, content[i][j], contentF));
book.write();
book.close();
JOptionPane.showMessageDialog(null, "導出excel成功辣!", "提示",
JOptionPane.CLOSED_OPTION);
}
}