Bug 68524 - Writing XLSX fails silently in POI 5.2.5
Summary: Writing XLSX fails silently in POI 5.2.5
Status: RESOLVED WORKSFORME
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-23 13:51 UTC by Michael Hrenka
Modified: 2024-02-25 20:39 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Hrenka 2024-01-23 13:51:40 UTC
I've noticed that a certain problem appeared with version 5.2.5, while versions 5.2.3 and 5.2.4 work properly.

When I create an XSSFWorkbook like this:

org.apache.poi.ss.usermodel.Workbook workbook = new org.apache.poi.xssf.usermodel.XSSFWorkbook();

then fill it will the createSheet Method and so on, and later use the write Method to write to a simple FileOutputStream, like this:

java.io.OutputStream stream = new java.io.FileOutputStream(new java.io.File(filename));
workbook.write(stream);

the writing fails. There is a .xlsx file, but it is corrupt, so that I cannot open it, with 0 kb being displayed as its apparent size.

I do not get any exception, the write operation just fails silently.

The code in which this operation fails is written in Groovy (currently 2.5). It worked for a long time, and an update to POI 5.2.5 causes the problem, while a downgrade to 5.2.4 fixes it.
Comment 1 Dominik Stadler 2024-01-24 18:57:59 UTC
As this seems to mostly only affect you while others do use 5.2.5 successfully it may be related to something that you are doing when writing the file.

Can you provide a minimal reproducer code-snippet which can be used to reproduce this behavior?
Comment 2 Tim Allison 2024-01-25 12:43:37 UTC
I agree with Dominik, we need more info.

I'm not able to trigger this with plain Java:
        XSSFWorkbook workbook = new XSSFWorkbook();
        XSSFSheet sheet = workbook.createSheet();
        Row row =
                sheet.createRow(0);
        Cell c = row.createCell(0);
        c.setCellValue("this is a test");
        String filename = "/xxx/test.xlsx";
        java.io.OutputStream stream = new java.io.FileOutputStream(new java.io.File(filename));
        workbook.write(stream);

Do you have the same problem if you explicitly close the stream and close the workbook?
Comment 3 Dominik Stadler 2024-02-25 20:39:40 UTC
No update for some time, thus closing, please reopen with code which allows to reproduce the problem if you are still having issues.