Package org.apache.poi.xssf.streaming
Class SheetDataWriter
- java.lang.Object
-
- org.apache.poi.xssf.streaming.SheetDataWriter
-
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
GZIPSheetDataWriter,SheetDataWriterWithDecorator,StreamingSheetWriter
public class SheetDataWriter extends Object implements Closeable
Initially copied from BigGridDemo "SpreadsheetWriter". Unlike the original code which wrote the entire document, this class only writes the "sheetData" document fragment so that it was renamed to "SheetDataWriter"
-
-
Constructor Summary
Constructors Constructor Description SheetDataWriter()SheetDataWriter(Writer writer)SheetDataWriter(SharedStringsTable sharedStringsTable)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()flush and close the temp data writer.FilecreateTempFile()Deprecated.useTempFile.createTempFile(String, String)directlyWritercreateWriter(File fd)Deprecated.this method is due to be made non-public, probably protectedprotected InputStreamdecorateInputStream(FileInputStream fis)Override this to translate (such as decrypt or expand) the file input stream as it is being read from disk.protected OutputStreamdecorateOutputStream(FileOutputStream fos)Override this to translate (such as encrypt or compress) the file output stream as it is being written to disk.intgetLastFlushedRow()intgetLowestIndexOfFlushedRows()intgetNumberOfCellsOfLastFlushedRow()intgetNumberOfFlushedRows()protected FilegetTempFile()InputStreamgetWorksheetXMLInputStream()protected voidoutputEscapedString(String s)voidwriteCell(int columnIndex, Cell cell)voidwriteRow(int rownum, SXSSFRow row)Write a row to the file
-
-
-
Field Detail
-
_out
protected final Writer _out
-
-
Constructor Detail
-
SheetDataWriter
public SheetDataWriter() throws IOException- Throws:
IOException
-
SheetDataWriter
public SheetDataWriter(Writer writer) throws IOException
- Throws:
IOException
-
SheetDataWriter
public SheetDataWriter(SharedStringsTable sharedStringsTable) throws IOException
- Throws:
IOException
-
-
Method Detail
-
createTempFile
@Removal(version="6.0.0") public File createTempFile() throws IOException
Deprecated.useTempFile.createTempFile(String, String)directlyCreate 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- Returns:
- temp file to write sheet data
- Throws:
IOException
-
createWriter
@Removal(version="6.0.0") public Writer createWriter(File fd) throws IOException
Deprecated.this method is due to be made non-public, probably protectedCreate a writer for the sheet data.- Parameters:
fd- the file to write to- Throws:
IOException
-
decorateOutputStream
protected OutputStream decorateOutputStream(FileOutputStream fos) throws IOException
Override this to translate (such as encrypt or compress) the file output stream as it is being written to disk. The default behavior is to to pass the stream through unmodified.- Parameters:
fos- the stream to decorate- Returns:
- a decorated stream
- Throws:
IOException- if decorating the stream fails- See Also:
decorateInputStream(FileInputStream)
-
close
public void close() throws IOExceptionflush and close the temp data writer. This method must be invoked before callinggetWorksheetXMLInputStream()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getTempFile
protected File getTempFile()
-
getWorksheetXMLInputStream
public InputStream getWorksheetXMLInputStream() throws IOException
- Returns:
- a stream to read temp file with the sheet data
- Throws:
IOException
-
decorateInputStream
protected InputStream decorateInputStream(FileInputStream fis) throws IOException
Override this to translate (such as decrypt or expand) the file input stream as it is being read from disk. The default behavior is to to pass the stream through unmodified.- Parameters:
fis- the stream to decorate- Returns:
- a decorated stream
- Throws:
IOException- if decorating the stream fails- See Also:
decorateOutputStream(FileOutputStream)
-
getNumberOfFlushedRows
public int getNumberOfFlushedRows()
-
getNumberOfCellsOfLastFlushedRow
public int getNumberOfCellsOfLastFlushedRow()
-
getLowestIndexOfFlushedRows
public int getLowestIndexOfFlushedRows()
-
getLastFlushedRow
public int getLastFlushedRow()
-
writeRow
public void writeRow(int rownum, SXSSFRow row) throws IOExceptionWrite a row to the file- Parameters:
rownum- 0-based row numberrow- a row- Throws:
IOException- If an I/O error occurs
-
writeCell
public void writeCell(int columnIndex, Cell cell) throws IOException- Throws:
IOException
-
outputEscapedString
protected void outputEscapedString(String s) throws IOException
- Throws:
IOException
-
-