POI 3.17 bold font

Viewed 17271

I'm upgrading from POI 3.15 to 3.17

This code does not compile:

HSSFFont fontTitle = wb.createFont();
fontTitle.setFontHeightInPoints((short) 12);
fontTitle.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

I've changed to:

Font fontTitle = wb.createFont();
fontTitle.setFontHeightInPoints((short) 12);
fontTitle.setBoldweight(Font.BOLDWEIGHT_BOLD);

but still in error:

/excel/SQL2XLSX17N.java:271: cannot find symbol               
symbol  : variable BOLDWEIGHT_BOLD                            
location: interface org.apache.poi.ss.usermodel.Font          
               fontTitle.setBoldweight(Font.BOLDWEIGHT_BOLD); 

How do I use a bold font?

2 Answers

Just for history:

OLD: f.setBoldweight(Font.BOLDWEIGHT_NORMAL); NEW: f.setBold(false);

OLD: fb.setBoldweight(Font.BOLDWEIGHT_BOLD); NEW: 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);
}
Related