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:
Closeable,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
-
-
Field Summary
-
Fields inherited from class org.apache.poi.xssf.streaming.SheetDataWriter
_out
-
-
Constructor Summary
Constructors Constructor Description StreamingSheetWriter()StreamingSheetWriter(OutputStream out)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()flush and close the temp data writer.FilecreateTempFile()Create a temp file to write sheet data.WritercreateWriter(File fd)Create a writer for the sheet data.protected static WritercreateWriter(OutputStream out)Create a writer for the sheet data.InputStreamgetWorksheetXMLInputStream()-
Methods inherited from class org.apache.poi.xssf.streaming.SheetDataWriter
decorateInputStream, decorateOutputStream, getLastFlushedRow, getLowestIndexOfFlushedRows, getNumberOfCellsOfLastFlushedRow, getNumberOfFlushedRows, getTempFile, outputEscapedString, writeCell, writeRow
-
-
-
-
Constructor Detail
-
StreamingSheetWriter
public StreamingSheetWriter() throws IOException- Throws:
IOException
-
StreamingSheetWriter
public StreamingSheetWriter(OutputStream out) throws IOException
- Throws:
IOException
-
-
Method Detail
-
createTempFile
public File createTempFile() throws IOException
Description copied from class:SheetDataWriterCreate 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:
createTempFilein classSheetDataWriter- Returns:
- temp file to write sheet data
- Throws:
IOException
-
createWriter
public Writer createWriter(File fd) throws IOException
Description copied from class:SheetDataWriterCreate a writer for the sheet data.- Overrides:
createWriterin classSheetDataWriter- Parameters:
fd- the file to write to- Throws:
IOException
-
createWriter
protected static Writer createWriter(OutputStream out) throws IOException
Create a writer for the sheet data.- Parameters:
out- the output stream to write to- Throws:
IOException
-
close
public void close() throws IOExceptionDescription copied from class:SheetDataWriterflush and close the temp data writer. This method must be invoked before callingSheetDataWriter.getWorksheetXMLInputStream()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classSheetDataWriter- Throws:
IOException
-
getWorksheetXMLInputStream
public InputStream getWorksheetXMLInputStream() throws IOException
- Overrides:
getWorksheetXMLInputStreamin classSheetDataWriter- Returns:
- a stream to read temp file with the sheet data
- Throws:
IOException
-
-