Class SXSSFWorkbook
- java.lang.Object
-
- org.apache.poi.xssf.streaming.SXSSFWorkbook
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<Sheet>,Workbook
- Direct Known Subclasses:
DeferredSXSSFWorkbook,SXSSFWorkbookWithCustomZipEntrySource
public class SXSSFWorkbook extends Object implements Workbook
Streaming version of XSSFWorkbook implementing the "BigGridDemo" strategy. This allows to write very large files without running out of memory as only a configurable portion of the rows are kept in memory at any one time. You can provide a template workbook which is used as basis for the written data. See https://poi.apache.org/spreadsheet/how-to.html#sxssf for details. Please note that there are still things that still may consume a large amount of memory based on which features you are using, e.g. merged regions, comments, ... are still only stored in memory and thus may require a lot of memory if used extensively. SXSSFWorkbook defaults to using inline strings instead of a shared strings table. This is very efficient, since no document content needs to be kept in memory, but is also known to produce documents that are incompatible with some clients. With shared strings enabled all unique strings in the document has to be kept in memory. Depending on your document content this could use a lot more resources than with shared strings disabled. Carefully review your memory budget and compatibility needs before deciding whether to enable shared strings or not.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interfaceSXSSFWorkbook.ISheetInjectorprotected classSXSSFWorkbook.SheetIterator<T extends Sheet>
-
Field Summary
Fields Modifier and Type Field Description protected SharedStringsTable_sharedStringSourceshared string table - a cache of strings in this workbookprotected XSSFWorkbook_wbstatic intDEFAULT_WINDOW_SIZESpecifies how many rows can be accessed at most viaSXSSFSheet.getRow(int).protected Zip64Modezip64Modecontrols whether Zip64 mode is used - Always became the default in POI 5.0.0-
Fields inherited from interface org.apache.poi.ss.usermodel.Workbook
MAX_SENSITIVE_SHEET_NAME_LEN, PICTURE_TYPE_DIB, PICTURE_TYPE_EMF, PICTURE_TYPE_JPEG, PICTURE_TYPE_PICT, PICTURE_TYPE_PNG, PICTURE_TYPE_WMF
-
-
Constructor Summary
Constructors Constructor Description SXSSFWorkbook()Construct a new workbook with default row window sizeSXSSFWorkbook(int rowAccessWindowSize)Construct an empty workbook and specify the window for row access.SXSSFWorkbook(XSSFWorkbook workbook)Construct a workbook from a template.SXSSFWorkbook(XSSFWorkbook workbook, int rowAccessWindowSize)Constructs an workbook from an existing workbook.SXSSFWorkbook(XSSFWorkbook workbook, int rowAccessWindowSize, boolean compressTmpFiles)Constructs an workbook from an existing workbook.SXSSFWorkbook(XSSFWorkbook workbook, int rowAccessWindowSize, boolean compressTmpFiles, boolean useSharedStringsTable)Constructs an workbook from an existing workbook.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intaddOlePackage(byte[] oleData, String label, String fileName, String command)intaddPicture(byte[] pictureData, int format)Adds a picture to the workbook.voidaddToolPack(UDFFinder toolpack)Register a new toolpack in this workbook.SheetcloneSheet(int sheetNum)Not implemented for SXSSFWorkbook Create a Sheet from an existing sheet in the Workbook.voidclose()Closes the underlyingXSSFWorkbookandOPCPackageon which this Workbook is based, if any.protected ZipArchiveOutputStreamcreateArchiveOutputStream(OutputStream out)CellStylecreateCellStyle()Create a new Cell style and add it to the workbook's style tableDataFormatcreateDataFormat()Returns the instance of DataFormat for this workbook.EvaluationWorkbookcreateEvaluationWorkbook()FontcreateFont()Create a new Font and add it to the workbook's font tableNamecreateName()Creates a new (uninitialised) defined name in this workbookSXSSFSheetcreateSheet()Create a Sheet for this Workbook, adds it to the sheets and returns the high level representation.SXSSFSheetcreateSheet(String sheetname)Create a Sheet for this Workbook, adds it to the sheets and returns the high level representation.protected SheetDataWritercreateSheetDataWriter()protected SXSSFWorkbook.ISheetInjectorcreateSheetInjector(SXSSFSheet sxSheet)booleandispose()Dispose of temporary files backing this workbook on disk.FontfindFont(boolean bold, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline)Finds a font that matches the one with the supplied attributesprotected voidflushSheets()intgetActiveSheetIndex()Convenience method to get the active sheet.List<? extends Name>getAllNames()Returns all defined namesList<? extends PictureData>getAllPictures()Gets all pictures from the Workbook.CellReferenceTypegetCellReferenceType()CellStylegetCellStyleAt(int idx)Get the cell style object at the given indexCreationHelpergetCreationHelper()Returns an object that handles instantiating concrete classes of the various instances one needs for HSSF, XSSF and SXSSF.intgetFirstVisibleTab()Gets the first tab that is displayed in the list of tabs in excel.FontgetFontAt(int idx)booleangetForceFormulaRecalculation()Whether Excel will be asked to recalculate all formulas when the workbook is opened.Row.MissingCellPolicygetMissingCellPolicy()Retrieves the current policy on what to do when getting missing or blank cells from a row.NamegetName(String name)List<? extends Name>getNames(String name)Returns all defined names with the given name.intgetNumberOfFonts()intgetNumberOfFontsAsInt()Deprecated.intgetNumberOfNames()intgetNumberOfSheets()Get the number of spreadsheets in the workbookintgetNumCellStyles()Get the number of styles the workbook containsStringgetPrintArea(int sheetIndex)Retrieves the reference for the printarea of the specified sheet, the sheet name is appended to the reference even if it was not specified.intgetRandomAccessWindowSize()See the constructors for a more detailed description of the sliding window of rows.protected SharedStringsTablegetSharedStringSource()SXSSFSheetgetSheet(String name)Get sheet with the given nameSXSSFSheetgetSheetAt(int index)Get the Sheet object at the given index.protected XSSFSheetgetSheetFromZipEntryName(String sheetRef)intgetSheetIndex(String name)Returns the index of the sheet by his nameintgetSheetIndex(Sheet sheet)Returns the index of the given sheetStringgetSheetName(int sheet)Set the sheet nameSheetVisibilitygetSheetVisibility(int sheetIx)SpreadsheetVersiongetSpreadsheetVersion()Returns the spreadsheet version (EXCLE2007) of this workbookXSSFWorkbookgetXSSFWorkbook()protected voidinjectData(ZipEntrySource zipEntrySource, OutputStream out)booleanisCompressTempFiles()Get whether temp files should be compressed.protected booleanisDate1904()booleanisHidden()booleanisSheetHidden(int sheetIx)booleanisSheetVeryHidden(int sheetIx)intlinkExternalWorkbook(String name, Workbook workbook)Not implemented for SXSSFWorkbook Adds the LinkTable records required to allow formulas referencing the specified external workbook to be added to this one.voidremoveName(Name name)Remove the given defined namevoidremovePrintArea(int sheetIndex)Delete the printarea for the sheet specifiedvoidremoveSheetAt(int index)Removes sheet at the given indexvoidsetActiveSheet(int sheetIndex)Convenience method to set the active sheet.voidsetCellReferenceType(CellReferenceType cellReferenceType)voidsetCompressTempFiles(boolean compress)Set whether temp files should be compressed.voidsetFirstVisibleTab(int sheetIndex)Sets the first tab that is displayed in the list of tabs in excel.voidsetForceFormulaRecalculation(boolean value)Whether the application shall perform a full recalculation when the workbook is opened.voidsetHidden(boolean hiddenFlag)voidsetMissingCellPolicy(Row.MissingCellPolicy missingCellPolicy)Sets the policy on what to do when getting missing or blank cells from a row.voidsetPrintArea(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow)For the Convenience of Java Programmers maintaining pointers.voidsetPrintArea(int sheetIndex, String reference)Sets the printarea for the sheet providedprotected voidsetRandomAccessWindowSize(int rowAccessWindowSize)voidsetSelectedTab(int index)Sets the tab whose data is actually seen when the sheet is opened.voidsetSheetHidden(int sheetIx, boolean hidden)voidsetSheetName(int sheet, String name)Set the sheet name.voidsetSheetOrder(String sheetname, int pos)Sets the order of appearance for a given sheet.voidsetSheetVisibility(int sheetIx, SheetVisibility visibility)voidsetShouldCalculateSheetDimensions(boolean shouldCalculateSheetDimensions)voidsetZip64Mode(Zip64Mode zip64Mode)Sets the Zip64 ModeIterator<Sheet>sheetIterator()Returns an iterator of the sheets in the workbook in sheet order.booleanshouldCalculateSheetDimensions()Spliterator<Sheet>spliterator()Returns a spliterator of the sheets in the workbook in sheet order.voidwrite(OutputStream stream)Write out this workbook to an OutputStream.voidwriteAvoidingTempFiles(OutputStream stream)Write out this workbook to an OutputStream.
-
-
-
Field Detail
-
DEFAULT_WINDOW_SIZE
public static final int DEFAULT_WINDOW_SIZE
Specifies how many rows can be accessed at most viaSXSSFSheet.getRow(int). When a new node is created viaSXSSFSheet.createRow(int)and the total number of unflushed records would exceed the specified value, then the row with the lowest index value is flushed and cannot be accessed viaSXSSFSheet.getRow(int)anymore.- See Also:
- Constant Field Values
-
_wb
protected final XSSFWorkbook _wb
-
_sharedStringSource
protected final SharedStringsTable _sharedStringSource
shared string table - a cache of strings in this workbook
-
zip64Mode
protected Zip64Mode zip64Mode
controls whether Zip64 mode is used - Always became the default in POI 5.0.0
-
-
Constructor Detail
-
SXSSFWorkbook
public SXSSFWorkbook()
Construct a new workbook with default row window size
-
SXSSFWorkbook
public SXSSFWorkbook(XSSFWorkbook workbook)
Construct a workbook from a template.
There are three use-cases to use SXSSFWorkbook(XSSFWorkbook) :- Append new sheets to existing workbooks. You can open existing workbook from a file or create on the fly with XSSF.
-
Append rows to existing sheets. The row number MUST be greater
than
max(rownum)in the template sheet. - Use existing workbook as a template and re-use global objects such as cell styles, formats, images, etc.
-
Access initial cells and rows in the template. After constructing
all internal windows are empty and
SXSSFSheet.getRow(int)andSXSSFRow.getCell(int)returnnull. - Override existing cells and rows. The API silently allows that but the output file is invalid and Excel cannot read it.
- Parameters:
workbook- the template workbook
-
SXSSFWorkbook
public SXSSFWorkbook(XSSFWorkbook workbook, int rowAccessWindowSize)
Constructs an workbook from an existing workbook.When a new node is created via
SXSSFSheet.createRow(int)and the total number of unflushed records would exceed the specified value, then the row with the lowest index value is flushed and cannot be accessed viaSXSSFSheet.getRow(int)anymore.A value of
-1indicates unlimited access. In this case all records that have not been flushed by a call toflush()are available for random access.A value of
0is not allowed because it would flush any newly created row without having a chance to specify any cells.- Parameters:
rowAccessWindowSize- the number of rows that are kept in memory until flushed out, see above.
-
SXSSFWorkbook
public SXSSFWorkbook(XSSFWorkbook workbook, int rowAccessWindowSize, boolean compressTmpFiles)
Constructs an workbook from an existing workbook.When a new node is created via
SXSSFSheet.createRow(int)and the total number of unflushed records would exceed the specified value, then the row with the lowest index value is flushed and cannot be accessed viaSXSSFSheet.getRow(int)anymore.A value of
-1indicates unlimited access. In this case all records that have not been flushed by a call toflush()are available for random access.A value of
0is not allowed because it would flush any newly created row without having a chance to specify any cells.- Parameters:
rowAccessWindowSize- the number of rows that are kept in memory until flushed out, see above.compressTmpFiles- whether to use gzip compression for temporary files
-
SXSSFWorkbook
public SXSSFWorkbook(XSSFWorkbook workbook, int rowAccessWindowSize, boolean compressTmpFiles, boolean useSharedStringsTable)
Constructs an workbook from an existing workbook.When a new node is created via
SXSSFSheet.createRow(int)and the total number of unflushed records would exceed the specified value, then the row with the lowest index value is flushed and cannot be accessed viaSXSSFSheet.getRow(int)anymore.A value of
-1indicates unlimited access. In this case all records that have not been flushed by a call toflush()are available for random access.A value of
0is not allowed because it would flush any newly created row without having a chance to specify any cells.- Parameters:
workbook- the template workbookrowAccessWindowSize- the number of rows that are kept in memory until flushed out, see above.compressTmpFiles- whether to use gzip compression for temporary filesuseSharedStringsTable- whether to use a shared strings table
-
SXSSFWorkbook
public SXSSFWorkbook(int rowAccessWindowSize)
Construct an empty workbook and specify the window for row access.When a new node is created via
SXSSFSheet.createRow(int)and the total number of unflushed records would exceed the specified value, then the row with the lowest index value is flushed and cannot be accessed viaSXSSFSheet.getRow(int)anymore.A value of
-1indicates unlimited access. In this case all records that have not been flushed by a call toflush()are available for random access.A value of
0is not allowed because it would flush any newly created row without having a chance to specify any cells.- Parameters:
rowAccessWindowSize- the number of rows that are kept in memory until flushed out, see above.
-
-
Method Detail
-
getRandomAccessWindowSize
public int getRandomAccessWindowSize()
See the constructors for a more detailed description of the sliding window of rows.- Returns:
- The number of rows that are kept in memory at once before flushing them out.
-
setRandomAccessWindowSize
protected void setRandomAccessWindowSize(int rowAccessWindowSize)
-
setZip64Mode
@Beta public void setZip64Mode(Zip64Mode zip64Mode)
Sets the Zip64 Mode- Parameters:
zip64Mode-Zip64Mode- Since:
- 4.1.0
-
isCompressTempFiles
public boolean isCompressTempFiles()
Get whether temp files should be compressed.- Returns:
- whether to compress temp files
-
setCompressTempFiles
public void setCompressTempFiles(boolean compress)
Set whether temp files should be compressed.SXSSF writes sheet data in temporary files (a temp file per-sheet) and the size of these temp files can grow to to a very large size, e.g. for a 20 MB csv data the size of the temp xml file become few GB large. If the "compress" flag is set to
truethen the temporary XML is gzipped.Please note the "compress" option may cause performance penalty.
Setting this option only affects compression for subsequent
createSheet()calls.- Parameters:
compress- whether to compress temp files
-
setShouldCalculateSheetDimensions
public void setShouldCalculateSheetDimensions(boolean shouldCalculateSheetDimensions)
- Parameters:
shouldCalculateSheetDimensions- defaults totrue, set tofalseif the calculated dimensions are causing trouble- Since:
- POI 5.2.3
-
shouldCalculateSheetDimensions
public boolean shouldCalculateSheetDimensions()
- Returns:
- shouldCalculateSheetDimensions defaults to
true, set tofalseif the calculated dimensions are causing trouble - Since:
- POI 5.2.3
-
getSharedStringSource
@Internal protected SharedStringsTable getSharedStringSource()
-
createSheetDataWriter
protected SheetDataWriter createSheetDataWriter() throws IOException
- Throws:
IOException
-
injectData
protected void injectData(ZipEntrySource zipEntrySource, OutputStream out) throws IOException
- Throws:
IOException
-
createArchiveOutputStream
protected ZipArchiveOutputStream createArchiveOutputStream(OutputStream out)
-
createSheetInjector
protected SXSSFWorkbook.ISheetInjector createSheetInjector(SXSSFSheet sxSheet) throws IOException
- Throws:
IOException
-
getXSSFWorkbook
public XSSFWorkbook getXSSFWorkbook()
-
getActiveSheetIndex
public int getActiveSheetIndex()
Convenience method to get the active sheet. The active sheet is is the sheet which is currently displayed when the workbook is viewed in Excel. 'Selected' sheet(s) is a distinct concept.- Specified by:
getActiveSheetIndexin interfaceWorkbook- Returns:
- the index of the active sheet (0-based)
-
setActiveSheet
public void setActiveSheet(int sheetIndex)
Convenience method to set the active sheet. The active sheet is is the sheet which is currently displayed when the workbook is viewed in Excel. 'Selected' sheet(s) is a distinct concept.- Specified by:
setActiveSheetin interfaceWorkbook- Parameters:
sheetIndex- index of the active sheet (0-based)
-
getFirstVisibleTab
public int getFirstVisibleTab()
Gets the first tab that is displayed in the list of tabs in excel.- Specified by:
getFirstVisibleTabin interfaceWorkbook- Returns:
- the first tab that to display in the list of tabs (0-based).
-
setFirstVisibleTab
public void setFirstVisibleTab(int sheetIndex)
Sets the first tab that is displayed in the list of tabs in excel.- Specified by:
setFirstVisibleTabin interfaceWorkbook- Parameters:
sheetIndex- the first tab that to display in the list of tabs (0-based)
-
setSheetOrder
public void setSheetOrder(String sheetname, int pos)
Sets the order of appearance for a given sheet.- Specified by:
setSheetOrderin interfaceWorkbook- Parameters:
sheetname- the name of the sheet to reorderpos- the position that we want to insert the sheet into (0 based)
-
setSelectedTab
public void setSelectedTab(int index)
Sets the tab whose data is actually seen when the sheet is opened. This may be different from the "selected sheet" since excel seems to allow you to show the data of one sheet when another is seen "selected" in the tabs (at the bottom).- Specified by:
setSelectedTabin interfaceWorkbook- Parameters:
index- the index of the sheet to select (0 based)- See Also:
Sheet.setSelected(boolean)
-
setSheetName
public void setSheetName(int sheet, String name)Set the sheet name.- Specified by:
setSheetNamein interfaceWorkbook- Parameters:
sheet- number (0 based)- Throws:
IllegalArgumentException- if the name is greater than 31 chars or contains/\?*[]
-
getSheetName
public String getSheetName(int sheet)
Set the sheet name- Specified by:
getSheetNamein interfaceWorkbook- Parameters:
sheet- sheet number (0 based)- Returns:
- Sheet name
-
getSheetIndex
public int getSheetIndex(String name)
Returns the index of the sheet by his name- Specified by:
getSheetIndexin interfaceWorkbook- Parameters:
name- the sheet name- Returns:
- index of the sheet (0 based)
-
getSheetIndex
public int getSheetIndex(Sheet sheet)
Returns the index of the given sheet- Specified by:
getSheetIndexin interfaceWorkbook- Parameters:
sheet- the sheet to look up- Returns:
- index of the sheet (0 based)
-
createSheet
public SXSSFSheet createSheet()
Create a Sheet for this Workbook, adds it to the sheets and returns the high level representation. Use this to create new sheets.- Specified by:
createSheetin interfaceWorkbook- Returns:
- Sheet representing the new sheet.
-
createSheet
public SXSSFSheet createSheet(String sheetname)
Create a Sheet for this Workbook, adds it to the sheets and returns the high level representation. Use this to create new sheets.- Specified by:
createSheetin interfaceWorkbook- Parameters:
sheetname- sheetname to set for the sheet.- Returns:
- Sheet representing the new sheet.
- Throws:
IllegalArgumentException- if the name is greater than 31 chars or contains/\?*[]
-
cloneSheet
@NotImplemented public Sheet cloneSheet(int sheetNum)
Not implemented for SXSSFWorkbook Create a Sheet from an existing sheet in the Workbook.- Specified by:
cloneSheetin interfaceWorkbook- Returns:
- Sheet representing the cloned sheet.
-
getNumberOfSheets
public int getNumberOfSheets()
Get the number of spreadsheets in the workbook- Specified by:
getNumberOfSheetsin interfaceWorkbook- Returns:
- the number of sheets
-
sheetIterator
public Iterator<Sheet> sheetIterator()
Returns an iterator of the sheets in the workbook in sheet order. Includes hidden and very hidden sheets.- Specified by:
sheetIteratorin interfaceWorkbook- Returns:
- an iterator of the sheets.
-
spliterator
public Spliterator<Sheet> spliterator()
Returns a spliterator of the sheets in the workbook in sheet order. Includes hidden and very hidden sheets.- Specified by:
spliteratorin interfaceIterable<Sheet>- Specified by:
spliteratorin interfaceWorkbook- Returns:
- a spliterator of the sheets.
- Since:
- POI 5.2.0
-
getSheetAt
public SXSSFSheet getSheetAt(int index)
Get the Sheet object at the given index.- Specified by:
getSheetAtin interfaceWorkbook- Parameters:
index- of the sheet number (0-based physical and logical)- Returns:
- Sheet at the provided index
-
getSheet
public SXSSFSheet getSheet(String name)
Get sheet with the given name
-
removeSheetAt
public void removeSheetAt(int index)
Removes sheet at the given index- Specified by:
removeSheetAtin interfaceWorkbook- Parameters:
index- of the sheet to remove (0-based)
-
createFont
public Font createFont()
Create a new Font and add it to the workbook's font table- Specified by:
createFontin interfaceWorkbook- Returns:
- new font object
-
findFont
public Font findFont(boolean bold, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline)
Finds a font that matches the one with the supplied attributes
-
getNumberOfFonts
public int getNumberOfFonts()
- Specified by:
getNumberOfFontsin interfaceWorkbook
-
getNumberOfFontsAsInt
@Deprecated @Removal(version="6.0.0") public int getNumberOfFontsAsInt()
Deprecated.- Specified by:
getNumberOfFontsAsIntin interfaceWorkbook
-
createCellStyle
public CellStyle createCellStyle()
Create a new Cell style and add it to the workbook's style table- Specified by:
createCellStylein interfaceWorkbook- Returns:
- the new Cell Style object
-
getNumCellStyles
public int getNumCellStyles()
Get the number of styles the workbook contains- Specified by:
getNumCellStylesin interfaceWorkbook- Returns:
- count of cell styles
-
getCellStyleAt
public CellStyle getCellStyleAt(int idx)
Get the cell style object at the given index- Specified by:
getCellStyleAtin interfaceWorkbook- Parameters:
idx- index within the set of styles (0-based)- Returns:
- CellStyle object at the index
-
close
public void close() throws IOExceptionCloses the underlyingXSSFWorkbookandOPCPackageon which this Workbook is based, if any.Once this has been called, no further operations, updates or reads should be performed on the Workbook.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceWorkbook- Throws:
IOException
-
write
public void write(OutputStream stream) throws IOException
Write out this workbook to an OutputStream.- Specified by:
writein interfaceWorkbook- Parameters:
stream- - the java OutputStream you wish to write to- Throws:
IOException- if anything can't be written.
-
writeAvoidingTempFiles
@Beta public void writeAvoidingTempFiles(OutputStream stream) throws IOException
Write out this workbook to an OutputStream. This (experimental) method avoids the temp file thatwrite(java.io.OutputStream)creates but will use more memory as a result. Other SXSSF code can create temp files, so using this does not guarantee that there will be no temp file usage.- Parameters:
stream- - the java OutputStream you wish to write to- Throws:
IOException- if anything can't be written.- Since:
- POI 5.1.0 (experimental and still liable to change or be removed)
-
flushSheets
protected void flushSheets() throws IOException- Throws:
IOException
-
dispose
public boolean dispose()
Dispose of temporary files backing this workbook on disk. Calling this method will render the workbook unusable.- Returns:
- true if all temporary files were deleted successfully.
-
getNumberOfNames
public int getNumberOfNames()
- Specified by:
getNumberOfNamesin interfaceWorkbook- Returns:
- the total number of defined names in this workbook
-
getNames
public List<? extends Name> getNames(String name)
Returns all defined names with the given name.
-
getAllNames
public List<? extends Name> getAllNames()
Returns all defined names- Specified by:
getAllNamesin interfaceWorkbook- Returns:
- all defined names
-
createName
public Name createName()
Creates a new (uninitialised) defined name in this workbook- Specified by:
createNamein interfaceWorkbook- Returns:
- new defined name object
-
removeName
public void removeName(Name name)
Remove the given defined name- Specified by:
removeNamein interfaceWorkbook- Parameters:
name- the name to remove
-
setPrintArea
public void setPrintArea(int sheetIndex, String reference)Sets the printarea for the sheet providedi.e. Reference = $A$1:$B$2
- Specified by:
setPrintAreain interfaceWorkbook- Parameters:
sheetIndex- Zero-based sheet index (0 Represents the first sheet to keep consistent with java)reference- Valid name Reference for the Print Area
-
setPrintArea
public void setPrintArea(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow)For the Convenience of Java Programmers maintaining pointers.- Specified by:
setPrintAreain interfaceWorkbook- Parameters:
sheetIndex- Zero-based sheet index (0 = First Sheet)startColumn- Column to begin printareaendColumn- Column to end the printareastartRow- Row to begin the printareaendRow- Row to end the printarea- See Also:
setPrintArea(int, String)
-
getPrintArea
public String getPrintArea(int sheetIndex)
Retrieves the reference for the printarea of the specified sheet, the sheet name is appended to the reference even if it was not specified.- Specified by:
getPrintAreain interfaceWorkbook- Parameters:
sheetIndex- Zero-based sheet index (0 Represents the first sheet to keep consistent with java)- Returns:
- String Null if no print area has been defined
-
removePrintArea
public void removePrintArea(int sheetIndex)
Delete the printarea for the sheet specified- Specified by:
removePrintAreain interfaceWorkbook- Parameters:
sheetIndex- Zero-based sheet index (0 = First Sheet)
-
getMissingCellPolicy
public Row.MissingCellPolicy getMissingCellPolicy()
Retrieves the current policy on what to do when getting missing or blank cells from a row.The default is to return blank and null cells.
Row.MissingCellPolicy- Specified by:
getMissingCellPolicyin interfaceWorkbook
-
setMissingCellPolicy
public void setMissingCellPolicy(Row.MissingCellPolicy missingCellPolicy)
Sets the policy on what to do when getting missing or blank cells from a row. This will then apply to all calls toRow.getCell(int). SeeRow.MissingCellPolicy- Specified by:
setMissingCellPolicyin interfaceWorkbook
-
createDataFormat
public DataFormat createDataFormat()
Returns the instance of DataFormat for this workbook.- Specified by:
createDataFormatin interfaceWorkbook- Returns:
- the DataFormat object
-
addPicture
public int addPicture(byte[] pictureData, int format)Adds a picture to the workbook.- Specified by:
addPicturein interfaceWorkbook- Parameters:
pictureData- The bytes of the pictureformat- The format of the picture.- Returns:
- the index to this picture (1 based).
- See Also:
Workbook.PICTURE_TYPE_EMF,Workbook.PICTURE_TYPE_WMF,Workbook.PICTURE_TYPE_PICT,Workbook.PICTURE_TYPE_JPEG,Workbook.PICTURE_TYPE_PNG,Workbook.PICTURE_TYPE_DIB
-
getAllPictures
public List<? extends PictureData> getAllPictures()
Gets all pictures from the Workbook.- Specified by:
getAllPicturesin interfaceWorkbook- Returns:
- the list of pictures (a list of
PictureDataobjects.)
-
getCreationHelper
public CreationHelper getCreationHelper()
Returns an object that handles instantiating concrete classes of the various instances one needs for HSSF, XSSF and SXSSF.- Specified by:
getCreationHelperin interfaceWorkbook
-
isDate1904
protected boolean isDate1904()
-
isHidden
@NotImplemented("XSSFWorkbook#isHidden is not implemented") public boolean isHidden()
-
setHidden
@NotImplemented("XSSFWorkbook#setHidden is not implemented") public void setHidden(boolean hiddenFlag)
-
isSheetHidden
public boolean isSheetHidden(int sheetIx)
- Specified by:
isSheetHiddenin interfaceWorkbook
-
isSheetVeryHidden
public boolean isSheetVeryHidden(int sheetIx)
- Specified by:
isSheetVeryHiddenin interfaceWorkbook
-
getSheetVisibility
public SheetVisibility getSheetVisibility(int sheetIx)
- Specified by:
getSheetVisibilityin interfaceWorkbook
-
setSheetHidden
public void setSheetHidden(int sheetIx, boolean hidden)- Specified by:
setSheetHiddenin interfaceWorkbook
-
setSheetVisibility
public void setSheetVisibility(int sheetIx, SheetVisibility visibility)- Specified by:
setSheetVisibilityin interfaceWorkbook
-
linkExternalWorkbook
@NotImplemented public int linkExternalWorkbook(String name, Workbook workbook)
Not implemented for SXSSFWorkbook Adds the LinkTable records required to allow formulas referencing the specified external workbook to be added to this one. Allows formulas such as "[MyOtherWorkbook]Sheet3!$A$5" to be added to the file, for workbooks not already referenced. Note: this is not implemented and thus currently throws an Exception stating this.- Specified by:
linkExternalWorkbookin interfaceWorkbook- Parameters:
name- The name the workbook will be referenced as in formulasworkbook- The open workbook to fetch the link required information from- Throws:
RuntimeException- stating that this method is not implemented yet.
-
addToolPack
public void addToolPack(UDFFinder toolpack)
Register a new toolpack in this workbook.- Specified by:
addToolPackin interfaceWorkbook- Parameters:
toolpack- the toolpack to register
-
setForceFormulaRecalculation
public void setForceFormulaRecalculation(boolean value)
Whether the application shall perform a full recalculation when the workbook is opened.Typically you want to force formula recalculation when you modify cell formulas or values of a workbook previously created by Excel. When set to 0, this flag will tell Excel that it needs to recalculate all formulas in the workbook the next time the file is opened.
- Specified by:
setForceFormulaRecalculationin interfaceWorkbook- Parameters:
value- true if the application will perform a full recalculation of workbook values when the workbook is opened- Since:
- 3.8
-
getForceFormulaRecalculation
public boolean getForceFormulaRecalculation()
Whether Excel will be asked to recalculate all formulas when the workbook is opened.- Specified by:
getForceFormulaRecalculationin interfaceWorkbook
-
getSpreadsheetVersion
public SpreadsheetVersion getSpreadsheetVersion()
Returns the spreadsheet version (EXCLE2007) of this workbook- Specified by:
getSpreadsheetVersionin interfaceWorkbook- Returns:
- EXCEL2007 SpreadsheetVersion enum
- Since:
- 3.14 beta 2
-
addOlePackage
public int addOlePackage(byte[] oleData, String label, String fileName, String command) throws IOException- Specified by:
addOlePackagein interfaceWorkbook- Throws:
IOException
-
createEvaluationWorkbook
public EvaluationWorkbook createEvaluationWorkbook()
- Specified by:
createEvaluationWorkbookin interfaceWorkbook
-
getCellReferenceType
public CellReferenceType getCellReferenceType()
- Specified by:
getCellReferenceTypein interfaceWorkbook
-
setCellReferenceType
public void setCellReferenceType(CellReferenceType cellReferenceType)
- Specified by:
setCellReferenceTypein interfaceWorkbook
-
-