我从POI 3.15升级到3.17
此代码无法编译:
HSSFFont fontTitle = wb.createFont();
fontTitle.setFontHeightInPoints((short) 12);
fontTitle.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
我已改为:
Font fontTitle = wb.createFont();
fontTitle.setFontHeightInPoints((short) 12);
fontTitle.setBoldweight(Font.BOLDWEIGHT_BOLD);
但仍然有误:
/excel/SQL2XLSX17N.java:271: cannot find symbol
symbol : variable BOLDWEIGHT_BOLD
location: interface org.apache.poi.ss.usermodel.Font
fontTitle.setBoldweight(Font.BOLDWEIGHT_BOLD);
如何使用粗体字?
答案 0 :(得分:11)
答案 1 :(得分:2)
仅用于历史记录:
OLD:f.setBoldweight(Font.BOLDWEIGHT_NORMAL);
新:f.setBold(false);
OLD:fb.setBoldweight(Font.BOLDWEIGHT_BOLD);
新:fb.setBold(true);
/**
* sets the font to be bold or not
*/
public void setBold(boolean bold) {
if (bold)
font.setBoldWeight(BOLDWEIGHT_BOLD);
else
font.setBoldWeight(BOLDWEIGHT_NORMAL);
}