You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Rudolf Lenz <ru...@lehopa.de> on 2021/01/14 02:20:33 UTC

calling SXSSFWorkbook.write(OutputStream) twice causes exception

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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


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

Posted by Dominik Stadler <do...@gmx.at>.
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 <ru...@lehopa.de> 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: dev-unsubscribe@poi.apache.org
> For additional commands, e-mail: dev-help@poi.apache.org
>
>