本文整理匯總了Java中jxl.write.WritableFont.createFont方法的典型用法代碼示例。如果您正苦於以下問題:Java WritableFont.createFont方法的具體用法?Java WritableFont.createFont怎麽用?Java WritableFont.createFont使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jxl.write.WritableFont
的用法示例。
在下文中一共展示了WritableFont.createFont方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setExcelListTitle
import jxl.write.WritableFont; //導入方法依賴的package包/類
/**
* 設置報表內容頭
*
* @param listTitle
* 報表頭
* @throws IOException
* @throws WriteException
*/
@Deprecated
public void setExcelListTitle(String[] listTitle) throws WriteException, IOException {
try {
irow++;
long start = System.currentTimeMillis();
wfont = new WritableFont(WritableFont.createFont("宋體"), 10, WritableFont.BOLD, false,
UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
wcfFC = new WritableCellFormat(wfont);
wcfFC.setBorder(Border.ALL, BorderLineStyle.MEDIUM);
wcfFC.setAlignment(Alignment.CENTRE);// 對齊方式
wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);// 對齊方式
for (int i = icol; i < listTitle.length; i++) {
wsheet.addCell(new Label(i, irow, listTitle[i], wcfFC));
}
trow = irow;
logger.info("title use time:" + (System.currentTimeMillis() - start));
} catch (Exception e) {
this.close();
}
}
示例2: setReportTitle
import jxl.write.WritableFont; //導入方法依賴的package包/類
/**
* 設置報表標題
*
* @param reportTitle
* 報表標題
* @throws IOException
* @throws WriteException
* @throws WriteException
*/
public void setReportTitle(String reportTitle) throws WriteException, IOException {
try {
irow++;
wfont = new WritableFont(WritableFont.createFont("宋體"), 12, WritableFont.BOLD, false,
UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
wcfFC = new WritableCellFormat(wfont);
wcfFC.setAlignment(Alignment.CENTRE);// 對齊方式
// wcfFC.setBackground(jxl.format.Colour.VERY_LIGHT_YELLOW);// 背景色
wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);// 對齊方式
// wcfFC.setBorder(Border.ALL, BorderLineStyle.MEDIUM,
// Colour.BLACK);//
// 邊框
wsheet.addCell(new Label(icol, irow, reportTitle, wcfFC));
trow = irow;
} catch (Exception e) {
this.close();
}
}
示例3: setExcelListTitle
import jxl.write.WritableFont; //導入方法依賴的package包/類
/**
* 設置報表內容頭
*
* @param listTitle
* 報表頭
* @throws IOException
* @throws WriteException
*/
@Deprecated
public void setExcelListTitle(String[] listTitle) throws WriteException, IOException {
try {
irow++;
long start = System.currentTimeMillis();
wfont = new WritableFont(WritableFont.createFont("宋體"), 10, WritableFont.BOLD, false,
UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
wcfFC = new WritableCellFormat(wfont);
wcfFC.setBorder(Border.ALL, BorderLineStyle.MEDIUM);
wcfFC.setAlignment(Alignment.CENTRE);// 對齊方式
wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);// 對齊方式
for (int i = icol; i < listTitle.length; i++) {
wsheet.addCell(new Label(i, irow, listTitle[i], wcfFC));
}
trow = irow;
log.info("title use time:" + (System.currentTimeMillis() - start));
} catch (Exception e) {
this.close();
}
}
示例4: generateWriteableCellFormats
import jxl.write.WritableFont; //導入方法依賴的package包/類
protected Map<CellFormat, WritableCellFormat> generateWriteableCellFormats(WritableCellFormat base) {
try {
WritableFont bold = new WritableFont(WritableFont.createFont(base.getFont().getName()),
base.getFont().getPointSize(), WritableFont.BOLD);
Map<CellFormat, WritableCellFormat> result = new HashMap<>();
for (boolean isCentered : new boolean[] { true, false }) {
for (boolean isBold : new boolean[] { true, false }) {
for (boolean hasTopBorder : new boolean[] { true, false }) {
CellFormat f = new CellFormat();
f.isCentered = isCentered;
f.isBold = isBold;
f.hasTopBorder = hasTopBorder;
WritableCellFormat format = new WritableCellFormat(base);
if (isCentered) format.setAlignment(Alignment.CENTRE);
if (isBold) format.setFont(bold);
if (hasTopBorder) format.setBorder(Border.TOP, BorderLineStyle.THIN);
result.put(f, format);
}
}
}
return result;
}
catch (WriteException e) { throw new RuntimeException(e); }
}
示例5: exportExcel
import jxl.write.WritableFont; //導入方法依賴的package包/類
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);
}
}