Package org.apache.poi.xssf.streaming
Class SheetDataWriter
- java.lang.Object
-
- org.apache.poi.xssf.streaming.SheetDataWriter
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
GZIPSheetDataWriter,SheetDataWriterWithDecorator
public class SheetDataWriter extends java.lang.Object implements java.io.CloseableInitially 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(SharedStringsTable sharedStringsTable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()flush and close the temp data writer.java.io.FilecreateTempFile()Create a temp file to write sheet data.java.io.WritercreateWriter(java.io.File fd)Create a writer for the sheet data.protected java.io.InputStreamdecorateInputStream(java.io.FileInputStream fis)Override this to translate (such as decrypt or expand) the file input stream as it is being read from disk.protected java.io.OutputStreamdecorateOutputStream(java.io.FileOutputStream fos)Override this to translate (such as encrypt or compress) the file output stream as it is being written to disk.protected voidfinalize()intgetLastFlushedRow()intgetLowestIndexOfFlushedRows()intgetNumberOfCellsOfLastFlushedRow()intgetNumberOfFlushedRows()protected java.io.FilegetTempFile()java.io.InputStreamgetWorksheetXMLInputStream()protected voidoutputQuotedString(java.lang.String s)voidwriteCell(int columnIndex, Cell cell)voidwriteRow(int rownum, SXSSFRow row)Write a row to the file
-
-
-
Constructor Detail
-
SheetDataWriter
public SheetDataWriter() throws java.io.IOException- Throws:
java.io.IOException
-
SheetDataWriter
public SheetDataWriter(SharedStringsTable sharedStringsTable) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
createTempFile
public java.io.File createTempFile() throws java.io.IOExceptionCreate 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:
java.io.IOException
-
createWriter
public java.io.Writer createWriter(java.io.File fd) throws java.io.IOExceptionCreate a writer for the sheet data.- Parameters:
fd- the file to write to- Throws:
java.io.IOException
-
decorateOutputStream
protected java.io.OutputStream decorateOutputStream(java.io.FileOutputStream fos) throws java.io.IOExceptionOverride 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:
java.io.IOException- See Also:
decorateInputStream(FileInputStream)
-
close
public void close() throws java.io.IOExceptionflush and close the temp data writer. This method must be invoked before callinggetWorksheetXMLInputStream()- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
getTempFile
protected java.io.File getTempFile()
-
getWorksheetXMLInputStream
public java.io.InputStream getWorksheetXMLInputStream() throws java.io.IOException- Returns:
- a stream to read temp file with the sheet data
- Throws:
java.io.IOException
-
decorateInputStream
protected java.io.InputStream decorateInputStream(java.io.FileInputStream fis) throws java.io.IOExceptionOverride 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:
java.io.IOException- See Also:
decorateOutputStream(FileOutputStream)
-
getNumberOfFlushedRows
public int getNumberOfFlushedRows()
-
getNumberOfCellsOfLastFlushedRow
public int getNumberOfCellsOfLastFlushedRow()
-
getLowestIndexOfFlushedRows
public int getLowestIndexOfFlushedRows()
-
getLastFlushedRow
public int getLastFlushedRow()
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
writeRow
public void writeRow(int rownum, SXSSFRow row) throws java.io.IOExceptionWrite a row to the file- Parameters:
rownum- 0-based row numberrow- a row- Throws:
java.io.IOException- If an I/O error occurs
-
writeCell
public void writeCell(int columnIndex, Cell cell) throws java.io.IOException- Throws:
java.io.IOException
-
outputQuotedString
protected void outputQuotedString(java.lang.String s) throws java.io.IOException- Throws:
java.io.IOException
-
-