diff --git a/src/documentation/content/xdocs/hssf/quick-guide.xml b/src/documentation/content/xdocs/hssf/quick-guide.xml index e40dc0dcb3..6dc4dc909b 100644 --- a/src/documentation/content/xdocs/hssf/quick-guide.xml +++ b/src/documentation/content/xdocs/hssf/quick-guide.xml @@ -330,7 +330,40 @@ FileOutputStream fileOut = new FileOutputStream("workbook.xls"); wb.write(fileOut); fileOut.close(); - + +

+ Note, the maximum number of unique fonts in a workbook is limited to 32767 ( + the maximum positive short). You should re-use fonts in your apllications instead of + creating a font for each cell. +Examples: +

+

Wrong:

+ + for (int i = 0; i < 10000; i++) { + HSSFRow row = sheet.createRow(i); + HSSFCell cell = row.createCell((short) 0); + + HSSFCellStyle style = workbook.createCellStyle(); + HSSFFont font = workbook.createFont(); + font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); + style.setFont(font); + cell.setCellStyle(style); + } + +

Correct:

+ + + HSSFCellStyle style = workbook.createCellStyle(); + HSSFFont font = workbook.createFont(); + font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); + style.setFont(font); + for (int i = 0; i < 10000; i++) { + HSSFRow row = sheet.createRow(i); + HSSFCell cell = row.createCell((short) 0); + cell.setCellStyle(style); + } + +
Custom colors