-4

我可以知道如何在同一代码中使用粗体吗?我只需要一行应该是粗体。我该如何为它编写代码?

我的代码,

WritableFont cellFont = new WritableFont(WritableFont.TIMES,14);
cellFont.setBoldStyle(WritableFont.BOLD); 
WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
cellFormat.setWrap(true); 
Label Sheet1cellContent = new Label(0,0,"LAST NAME",cellFormat);
4

1 回答 1

2

参考Apache POI

HSSFFont boldFont = wb.createFont();
boldFont.setFontHeightInPoints((short)22);
boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); //Setting Bold font

HSSFCellStyle boldStyle = wb.createCellStyle();
boldStyle.setFont(boldFont); //Attaching the font to the Style

HSSFRow row = sheet1.createRow((short)1);
HSSFCell cell = row.createCell((short)0);
cell.setCellValue("This quick brown fox");
cell.setCellStyle(boldStyle); //Applying Style to the Cell.
于 2013-09-30T09:44:43.457 回答