Package org.apache.poi.xssf.streaming
Class StreamingSheetWriter
- java.lang.Object
-
- org.apache.poi.xssf.streaming.SheetDataWriter
-
- org.apache.poi.xssf.streaming.StreamingSheetWriter
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
@Beta public class StreamingSheetWriter extends SheetDataWriter
Unlike SheetDataWriter, this writer does not create a temporary file, it writes data directly to the provided OutputStream.- Since:
- 5.0.0
-
-
Constructor Summary
Constructors Constructor Description StreamingSheetWriter()
StreamingSheetWriter(java.io.OutputStream out)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
flush and close the temp data writer.java.io.File
createTempFile()
Create a temp file to write sheet data.java.io.Writer
createWriter(java.io.File fd)
Create a writer for the sheet data.java.io.InputStream
getWorksheetXMLInputStream()
-
Methods inherited from class org.apache.poi.xssf.streaming.SheetDataWriter
getLastFlushedRow, getLowestIndexOfFlushedRows, getNumberOfCellsOfLastFlushedRow, getNumberOfFlushedRows, writeCell, writeRow
-
-
-
-
Method Detail
-
createTempFile
public java.io.File createTempFile() throws java.io.IOException
Description copied from class:SheetDataWriter
Create a temp file to write sheet data. By default, temp files are created in the default temporary-file directory with a prefix "poi-sxssf-sheet" and suffix ".xml". Subclasses can override it and specify a different temp directory or filename or suffix, e.g..gz
- Overrides:
createTempFile
in classSheetDataWriter
- Returns:
- temp file to write sheet data
- Throws:
java.io.IOException
-
createWriter
public java.io.Writer createWriter(java.io.File fd) throws java.io.IOException
Description copied from class:SheetDataWriter
Create a writer for the sheet data.- Overrides:
createWriter
in classSheetDataWriter
- Parameters:
fd
- the file to write to- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
Description copied from class:SheetDataWriter
flush and close the temp data writer. This method must be invoked before callingSheetDataWriter.getWorksheetXMLInputStream()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classSheetDataWriter
- Throws:
java.io.IOException
-
getWorksheetXMLInputStream
public java.io.InputStream getWorksheetXMLInputStream() throws java.io.IOException
- Overrides:
getWorksheetXMLInputStream
in classSheetDataWriter
- Returns:
- a stream to read temp file with the sheet data
- Throws:
java.io.IOException
-
-