aboutsummaryrefslogtreecommitdiffstats
path: root/poi-examples
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-07-31 21:20:33 +0000
committerPJ Fanning <fanningpj@apache.org>2021-07-31 21:20:33 +0000
commitcceb9102549f645c8622371804e659de40fa69f2 (patch)
tree709172d21ffce535f6ab2b0e6b22c5ec26cb718e /poi-examples
parentf4cf7dc99e38e1faf4f6af960daf281fccf65b35 (diff)
downloadpoi-cceb9102549f645c8622371804e659de40fa69f2.tar.gz
poi-cceb9102549f645c8622371804e659de40fa69f2.zip
update docs about deferred SXSSF and limitations on what can be done in row generating function
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891937 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-examples')
-rw-r--r--poi-examples/src/main/java/org/apache/poi/examples/xssf/streaming/DeferredGeneration.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/poi-examples/src/main/java/org/apache/poi/examples/xssf/streaming/DeferredGeneration.java b/poi-examples/src/main/java/org/apache/poi/examples/xssf/streaming/DeferredGeneration.java
index 9c53c4ee0b..0e13a4dce3 100644
--- a/poi-examples/src/main/java/org/apache/poi/examples/xssf/streaming/DeferredGeneration.java
+++ b/poi-examples/src/main/java/org/apache/poi/examples/xssf/streaming/DeferredGeneration.java
@@ -18,6 +18,8 @@
package org.apache.poi.examples.xssf.streaming;
import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.streaming.DeferredSXSSFSheet;
import org.apache.poi.xssf.streaming.DeferredSXSSFWorkbook;
@@ -36,10 +38,15 @@ public class DeferredGeneration {
try (DeferredSXSSFWorkbook wb = new DeferredSXSSFWorkbook()) {
DeferredSXSSFSheet sheet1 = wb.createSheet("new sheet");
+ // cell styles should be created outside the row generator function
+ CellStyle cellStyle = wb.createCellStyle();
+ cellStyle.setAlignment(HorizontalAlignment.CENTER);
+
sheet1.setRowGenerator((ssxSheet) -> {
for (int i = 0; i < 10; i++) {
Row row = ssxSheet.createRow(i);
Cell cell = row.createCell(1);
+ cell.setCellStyle(cellStyle);
cell.setCellValue("value " + i);
}
});