本文整理汇总了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);
}
}