]> source.dussan.org Git - poi.git/commitdiff
added a note to re-use fonts instead of creating a font for each cell
authorYegor Kozlov <yegor@apache.org>
Tue, 6 Nov 2007 18:54:50 +0000 (18:54 +0000)
committerYegor Kozlov <yegor@apache.org>
Tue, 6 Nov 2007 18:54:50 +0000 (18:54 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@592521 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/hssf/quick-guide.xml

index e40dc0dcb3b2d977d092483a58b9bdccf79a381a..6dc4dc909b907c55c8c30280b7de9deb547cda5d 100644 (file)
     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 &lt; 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 &lt; 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>