Bug 65478 - DeferredSXSSFWorkboot not working cellStyle
Summary: DeferredSXSSFWorkboot not working cellStyle
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: SXSSF (show other bugs)
Version: unspecified
Hardware: PC Mac OS X 10.1
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-31 09:38 UTC by silver0r
Modified: 2021-08-01 08:44 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description silver0r 2021-07-31 09:38:22 UTC
Hello, PIO Team

I heared Apache POI 5.0.0 version upgrade and apply DeferredSXSSFWorkbook. I really wanted this and it's powerful.

When I apply DeferredSXSSFWorkbook, I found some bug.

When applying a cellStyle based on DeferredSXSSFWorkbook, it's not working and an error occurs when the excel file is opened.
(Also SXSSFWorkbook is working for me)


DeferredSXSSFWorkbook workbook = new DeferredSXSSFWorkbook(500);
DeferredSXSSFSheet deferredSXSSFSheet = workbook.createSheet();

deferredSXSSFSheet.setRowGenerator(sheet -> {
    Row row = sheet.createRow(0);
    Cell cell = row.createCell(0);
    CellStyle cellStyle = workbook.createCellStyle();
    cellStyle.setAlignment(HorizontalAlignment.RIGHT);

    cell.setCellStyle(cellStyle);
    cell.setCellValue("test");
});

workbook.write(response.getOutputStream());


Could you check it? TYSM.
Comment 1 PJ Fanning 2021-07-31 20:59:36 UTC
the row generator is designed for generating rows - can you create the style outside the row generator function?
Comment 2 silver0r 2021-08-01 05:02:59 UTC
(In reply to PJ Fanning from comment #1)
> the row generator is designed for generating rows - can you create the style
> outside the row generator function?

TYSM your comment

How can I create the cell style outside the row generator?
It would be of great help if you could provide a simple example.

and I have question. Can I make multiple row generator function in one xlsx file?

TYSM
Comment 3 PJ Fanning 2021-08-01 05:30:15 UTC
I have updated the example at https://github.com/apache/poi/blob/trunk/poi-examples/src/main/java/org/apache/poi/examples/xssf/streaming/DeferredGeneration.java to show the cell style creation. You can only add 1 row generator per sheet.
Comment 4 silver0r 2021-08-01 08:44:31 UTC
(In reply to PJ Fanning from comment #3)
> I have updated the example at
> https://github.com/apache/poi/blob/trunk/poi-examples/src/main/java/org/
> apache/poi/examples/xssf/streaming/DeferredGeneration.java to show the cell
> style creation. You can only add 1 row generator per sheet.

thanks for your kind
I'll try it :)