mirror of https://github.com/apache/poi.git
added a note to re-use fonts instead of creating a font for each cell
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@592521 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e072572961
commit
63543343fb
|
@ -330,7 +330,40 @@
|
|||
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
|
||||
wb.write(fileOut);
|
||||
fileOut.close();
|
||||
</source>
|
||||
</source>
|
||||
<p>
|
||||
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:
|
||||
</p>
|
||||
<p><strong>Wrong:</strong></p>
|
||||
<source>
|
||||
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);
|
||||
}
|
||||
</source>
|
||||
<p><strong>Correct:</strong></p>
|
||||
<source>
|
||||
|
||||
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);
|
||||
}
|
||||
</source>
|
||||
|
||||
</section>
|
||||
<anchor id="CustomColors"/>
|
||||
<section><title>Custom colors</title>
|
||||
|
|
Loading…
Reference in New Issue