-
-
Notifications
You must be signed in to change notification settings - Fork 90
Open
Description
SXSSFWorkbook is the Streaming version of XSSFWorkbook, It allows to write very large files without running out of memory as only a configurable portion of the rows are kept in memory at any one time.
This feature is quite relevant to Android where memory is not abundant.
https://poi.apache.org/apidocs/dev/org/apache/poi/xssf/streaming/SXSSFWorkbook.html
stack trace:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.dstadler.poiandroidtest.poitest, PID: 20594
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/font/FontRenderContext;
at org.apache.poi.ss.util.SheetUtil.<clinit>(SheetUtil.java:111)
at org.apache.poi.ss.util.SheetUtil.getDefaultCharWidth(SheetUtil.java:271)
at org.apache.poi.xssf.streaming.AutoSizeColumnTracker.<init>(AutoSizeColumnTracker.java:117)
at org.apache.poi.xssf.streaming.SXSSFSheet.<init>(SXSSFSheet.java:82)
at org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet(SXSSFWorkbook.java:658)
at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:679)
at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:90)
at org.dstadler.poiandroidtest.poitest.DocumentListActivity.writeWorkbook(DocumentListActivity.java:183)
at org.dstadler.poiandroidtest.poitest.DocumentListActivity.onCreate(DocumentListActivity.java:72)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
the issue can be easily replicated by modifying the method writeWorkbook() in DocumentListActivity.java of the piotest module. to the following:
private void writeWorkbook() throws java.io.IOException {
Workbook wb = new SXSSFWorkbook(100);
try {
Sheet sheet = wb.createSheet("Sheet1");
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue("cell-1");
cell = row.createCell(1);
cell.setCellValue("cell-2");
cell = row.createCell(2);
cell.setCellValue("cell-3");
XSSFCellStyle style = (XSSFCellStyle) wb.createCellStyle();
style.setFillBackgroundColor(new XSSFColor(new org.apache.poi.java.awt.Color(1, 2, 3)));
Hyperlink link = wb.getCreationHelper().createHyperlink(HyperlinkType.URL);
link.setAddress("http://www.google.at");
link.setLabel("Google");
cell.setHyperlink(link);
cell.setCellStyle(style);
sheet.setPrintGridlines(true);
OutputStream stream = openFileOutput("test.xlsx", Context.MODE_PRIVATE);
try {
wb.write(stream);
} finally {
stream.close();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
wb.close();
}
}
Metadata
Metadata
Assignees
Labels
No labels