我可以知道如何在同一代码中使用粗体吗?我只需要一行粗体。我怎么能为它编写代码?
我的代码,
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);
答案 0 :(得分:2)
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.