calling SXSSFWorkbook.write(OutputStream) twice causes exception

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

calling SXSSFWorkbook.write(OutputStream) twice causes exception

Rudolf Lenz
I called SXSSFWorkbook.write(OutputStream) twice with different
outputStreams.

The second call cause an exception:
     at java.io.BufferedWriter.ensureOpen(BufferedWriter.java:116)
     at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:126)
     at java.io.BufferedWriter.flush(BufferedWriter.java:253)
     at
org.apache.poi.xssf.streaming.SheetDataWriter.close(SheetDataWriter.java:128)
     at
org.apache.poi.xssf.streaming.SXSSFSheet.getWorksheetXMLInputStream(SXSSFSheet.java:98)
     at
org.apache.poi.xssf.streaming.SXSSFWorkbook.injectData(SXSSFWorkbook.java:408)
     at
org.apache.poi.xssf.streaming.SXSSFWorkbook.write(SXSSFWorkbook.java:959)

I suggest to delete  _out.flush();   in
org.apache.poi.xssf.streaming.SheetDataWriter.close()

The following  _out.close()   flushes anyway and does NOT cause an
exception if  _out  is already closed by a previous SXSSFWorkbook.write().

Kind regards
Rudi



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: calling SXSSFWorkbook.write(OutputStream) twice causes exception

Dominik Stadler
Hi,

I adjusted this now so that _flush() is not called any more, unit-tests
indicate that writing multiple time works now for all three workbook-types
HSSF, XSSF and SXSSF.

Regards... Dominik.


On Thu, Jan 14, 2021 at 3:20 AM Rudolf Lenz <[hidden email]> wrote:

> I called SXSSFWorkbook.write(OutputStream) twice with different
> outputStreams.
>
> The second call cause an exception:
>      at java.io.BufferedWriter.ensureOpen(BufferedWriter.java:116)
>      at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:126)
>      at java.io.BufferedWriter.flush(BufferedWriter.java:253)
>      at
>
> org.apache.poi.xssf.streaming.SheetDataWriter.close(SheetDataWriter.java:128)
>      at
>
> org.apache.poi.xssf.streaming.SXSSFSheet.getWorksheetXMLInputStream(SXSSFSheet.java:98)
>      at
>
> org.apache.poi.xssf.streaming.SXSSFWorkbook.injectData(SXSSFWorkbook.java:408)
>      at
> org.apache.poi.xssf.streaming.SXSSFWorkbook.write(SXSSFWorkbook.java:959)
>
> I suggest to delete  _out.flush();   in
> org.apache.poi.xssf.streaming.SheetDataWriter.close()
>
> The following  _out.close()   flushes anyway and does NOT cause an
> exception if  _out  is already closed by a previous SXSSFWorkbook.write().
>
> Kind regards
> Rudi
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>