Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_WINDOW_SIZE
Specifies how many rows can be accessed at most via getRow().
|
PICTURE_TYPE_DIB, PICTURE_TYPE_EMF, PICTURE_TYPE_JPEG, PICTURE_TYPE_PICT, PICTURE_TYPE_PNG, PICTURE_TYPE_WMF, SHEET_STATE_HIDDEN, SHEET_STATE_VERY_HIDDEN, SHEET_STATE_VISIBLE
Constructor and Description |
---|
SXSSFWorkbook()
Construct a new workbook
|
SXSSFWorkbook(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.
|
Modifier and Type | Method and Description |
---|---|
void |
addDefaultCellStyle(CellStyle cellStyle) |
int |
addDxfCellStyle(DxfCellStyle cellStyle) |
void |
addNamedStyle(NamedStyle namedStyle) |
int |
addPicture(byte[] pictureData,
int format)
Adds a picture to the workbook.
|
void |
addTableStyle(TableStyle tbStyle) |
void |
addToolPack(UDFFinder toopack)
Register a new toolpack in this workbook.
|
void |
clearDefaultCellStyles() |
void |
clearDxfCellStyles() |
void |
clearNamedStyles() |
void |
clearTableStyles() |
Sheet |
cloneSheet(int sheetNum)
Create an Sheet from an existing sheet in the Workbook.
|
CellStyle |
createCellStyle()
Create a new Cell style and add it to the workbook's style table
|
DataFormat |
createDataFormat()
Returns the instance of DataFormat for this workbook.
|
DxfCellStyle |
createDxfCellStyle() |
Font |
createFont()
Create a new Font and add it to the workbook's font table
|
Name |
createName()
Creates a new (uninitialised) defined name in this workbook
|
NamedStyle |
createNamedStyle(String name,
boolean custom,
int builtinId,
int index) |
PivotCache |
createPivotCache(AreaReference sourceRef) |
Sheet |
createSheet()
Sreate an Sheet for this Workbook, adds it to the sheets and returns
the high level representation.
|
Sheet |
createSheet(String sheetname)
Create an Sheet for this Workbook, adds it to the sheets and returns
the high level representation.
|
TableStyle |
createTableStyle(String name) |
boolean |
dispose()
Dispose of temporary files backing this workbook on disk.
|
Font |
findFont(short boldWeight,
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
|
int |
getActiveSheetIndex()
Convenience method to get the active sheet.
|
List<? extends PictureData> |
getAllPictures()
Gets all pictures from the Workbook.
|
CellStyle |
getCellStyleAt(int idx)
Get the cell style object at the given index
|
CreationHelper |
getCreationHelper()
Returns an object that handles instantiating concrete
classes of the various instances one needs for HSSF and XSSF.
|
List<CellStyle> |
getDefaultCellStyles() |
String |
getDefaultPivotStyle() |
String |
getDefaultTableStyle() |
List<DxfCellStyle> |
getDxfCellStyles() |
int |
getDxfIndex(DxfCellStyle dxfCellStyle) |
int |
getFirstVisibleTab()
Gets the first tab that is displayed in the list of tabs in excel.
|
Font |
getFontAt(short idx)
Get the font at the given index number
|
boolean |
getForceFormulaRecalculation()
Whether Excel will be asked to recalculate all formulas when the workbook is opened.
|
Row.MissingCellPolicy |
getMissingCellPolicy()
Retrieves the current policy on what to do when
getting missing or blank cells from a row.
|
Name |
getName(String name) |
Name |
getNameAt(int nameIndex) |
List<NamedStyle> |
getNamedStyles() |
int |
getNameIndex(String name)
Gets the defined name index by name
Note: Excel defined names are case-insensitive and this method performs a case-insensitive search. |
short |
getNumberOfFonts()
Get the number of fonts in the font table
|
int |
getNumberOfNames() |
int |
getNumberOfSheets()
Get the number of spreadsheets in the workbook
|
short |
getNumCellStyles()
Get the number of styles the workbook contains
|
List<PivotCache> |
getPivotCaches() |
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.
|
int |
getRandomAccessWindowSize() |
Sheet |
getSheet(String name)
Get sheet with the given name
|
Sheet |
getSheetAt(int index)
Get the Sheet object at the given index.
|
int |
getSheetIndex(Sheet sheet)
Returns the index of the given sheet
|
int |
getSheetIndex(String name)
Returns the index of the sheet by his name
|
String |
getSheetName(int sheet)
Set the sheet name
|
List<TableStyle> |
getTableStyles() |
XSSFWorkbook |
getXSSFWorkbook() |
boolean |
isHidden() |
boolean |
isSheetHidden(int sheetIx)
Check whether a sheet is hidden.
|
boolean |
isSheetVeryHidden(int sheetIx)
Check whether a sheet is very hidden.
|
void |
removeName(int index)
Remove the defined name at the specified index
|
void |
removeName(String name)
Remove a defined name by name
|
void |
removePrintArea(int sheetIndex)
Delete the printarea for the sheet specified
|
void |
removeSheetAt(int index)
Removes sheet at the given index
|
void |
setActiveSheet(int sheetIndex)
Convenience method to set the active sheet.
|
void |
setCompressTempFiles(boolean compress)
Set whether temp files should be compressed.
|
void |
setDefaultPivotStyle(String defaultPivotStyle) |
void |
setDefaultTableStyle(String defaultTableStyle) |
void |
setFirstVisibleTab(int sheetIndex)
Sets the first tab that is displayed in the list of tabs in excel.
|
void |
setForceFormulaRecalculation(boolean value)
Whether the application shall perform a full recalculation when the workbook is opened.
|
void |
setHidden(boolean hiddenFlag) |
void |
setMissingCellPolicy(Row.MissingCellPolicy missingCellPolicy)
Sets the policy on what to do when
getting missing or blank cells from a row.
|
void |
setPrintArea(int sheetIndex,
int startColumn,
int endColumn,
int startRow,
int endRow)
For the Convenience of Java Programmers maintaining pointers.
|
void |
setPrintArea(int sheetIndex,
String reference)
Sets the printarea for the sheet provided
|
void |
setRepeatingRowsAndColumns(int sheetIndex,
int startColumn,
int endColumn,
int startRow,
int endRow)
|
void |
setSelectedTab(int index)
Sets the tab whose data is actually seen when the sheet is opened.
|
void |
setSheetHidden(int sheetIx,
boolean hidden)
Hide or unhide a sheet
|
void |
setSheetHidden(int sheetIx,
int hidden)
Hide or unhide a sheet.
|
void |
setSheetName(int sheet,
String name)
Set the sheet name.
|
void |
setSheetOrder(String sheetname,
int pos)
Sets the order of appearance for a given sheet.
|
void |
write(OutputStream stream)
Write out this workbook to an Outputstream.
|
public static final int DEFAULT_WINDOW_SIZE
public SXSSFWorkbook()
public SXSSFWorkbook(XSSFWorkbook workbook)
There are three use-cases to use SXSSFWorkbook(XSSFWorkbook) :
workbook
- the template workbookpublic SXSSFWorkbook(XSSFWorkbook workbook, int rowAccessWindowSize)
When a new node is created via createRow() 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 via getRow() anymore.
A value of -1 indicates unlimited access. In this case all records that have not been flushed by a call to flush() are available for random access.
A value of 0 is not allowed because it would flush any newly created row without having a chance to specify any cells.
rowAccessWindowSize
- public SXSSFWorkbook(XSSFWorkbook workbook, int rowAccessWindowSize, boolean compressTmpFiles)
When a new node is created via createRow() 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 via getRow() anymore.
A value of -1 indicates unlimited access. In this case all records that have not been flushed by a call to flush() are available for random access.
A value of 0 is not allowed because it would flush any newly created row without having a chance to specify any cells.
rowAccessWindowSize
- compressTmpFiles
- whether to use gzip compression for temporary filespublic SXSSFWorkbook(int rowAccessWindowSize)
When a new node is created via createRow() 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 via getRow() anymore.
A value of -1 indicates unlimited access. In this case all records that have not been flushed by a call to flush() are available for random access.
A value of 0 is not allowed because it would flush any newly created row without having a chance to specify any cells.
rowAccessWindowSize
- public int getRandomAccessWindowSize()
public void setCompressTempFiles(boolean compress)
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 true
then the temporary XML is gzipped.
Please note the the "compress" option may cause performance penalty.
compress
- whether to compress temp filespublic XSSFWorkbook getXSSFWorkbook()
public int getActiveSheetIndex()
getActiveSheetIndex
in interface Workbook
public void setActiveSheet(int sheetIndex)
setActiveSheet
in interface Workbook
sheetIndex
- index of the active sheet (0-based)public int getFirstVisibleTab()
getFirstVisibleTab
in interface Workbook
public void setFirstVisibleTab(int sheetIndex)
setFirstVisibleTab
in interface Workbook
sheetIndex
- the first tab that to display in the list of tabs (0-based)public void setSheetOrder(String sheetname, int pos)
setSheetOrder
in interface Workbook
sheetname
- the name of the sheet to reorderpos
- the position that we want to insert the sheet into (0 based)public void setSelectedTab(int index)
setSelectedTab
in interface Workbook
index
- the index of the sheet to select (0 based)Sheet.setSelected(boolean)
public void setSheetName(int sheet, String name)
setSheetName
in interface Workbook
sheet
- number (0 based)IllegalArgumentException
- if the name is greater than 31 chars or contains /\?*[]
Workbook.createSheet(String)
,
WorkbookUtil.createSafeSheetName(String nameProposal)
public String getSheetName(int sheet)
getSheetName
in interface Workbook
sheet
- sheet number (0 based)public int getSheetIndex(String name)
getSheetIndex
in interface Workbook
name
- the sheet namepublic int getSheetIndex(Sheet sheet)
getSheetIndex
in interface Workbook
sheet
- the sheet to look uppublic Sheet createSheet()
createSheet
in interface Workbook
public Sheet createSheet(String sheetname)
createSheet
in interface Workbook
sheetname
- sheetname to set for the sheet.IllegalArgumentException
- if the name is greater than 31 chars or contains /\?*[]
WorkbookUtil.createSafeSheetName(String nameProposal)
public Sheet cloneSheet(int sheetNum)
cloneSheet
in interface Workbook
public int getNumberOfSheets()
getNumberOfSheets
in interface Workbook
public Sheet getSheetAt(int index)
getSheetAt
in interface Workbook
index
- of the sheet number (0-based physical & logical)public void removeSheetAt(int index)
removeSheetAt
in interface Workbook
index
- of the sheet to remove (0-based)public void setRepeatingRowsAndColumns(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow)
SXSSFSheet.setRepeatingRows(CellRangeAddress)
or SXSSFSheet.setRepeatingColumns(CellRangeAddress)
To set just repeating columns:
workbook.setRepeatingRowsAndColumns(0,0,1,-1-1);To set just repeating rows:
workbook.setRepeatingRowsAndColumns(0,-1,-1,0,4);To remove all repeating rows and columns for a sheet.
workbook.setRepeatingRowsAndColumns(0,-1,-1,-1,-1);
setRepeatingRowsAndColumns
in interface Workbook
sheetIndex
- 0 based index to sheet.startColumn
- 0 based start of repeating columns.endColumn
- 0 based end of repeating columns.startRow
- 0 based start of repeating rows.endRow
- 0 based end of repeating rows.public Font createFont()
createFont
in interface Workbook
public Font findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline)
public short getNumberOfFonts()
getNumberOfFonts
in interface Workbook
public Font getFontAt(short idx)
public CellStyle createCellStyle()
createCellStyle
in interface Workbook
public short getNumCellStyles()
getNumCellStyles
in interface Workbook
public CellStyle getCellStyleAt(int idx)
getCellStyleAt
in interface Workbook
idx
- index within the set of styles (0-based)public void write(OutputStream stream) throws IOException
write
in interface Workbook
stream
- - the java OutputStream you wish to write toIOException
- if anything can't be written.public boolean dispose()
public int getNumberOfNames()
getNumberOfNames
in interface Workbook
public Name getNameAt(int nameIndex)
getNameAt
in interface Workbook
nameIndex
- position of the named range (0-based)IllegalArgumentException
- if the supplied index is invalidpublic Name createName()
createName
in interface Workbook
public int getNameIndex(String name)
getNameIndex
in interface Workbook
name
- the name of the defined namepublic void removeName(int index)
removeName
in interface Workbook
index
- named range index (0 based)public void removeName(String name)
removeName
in interface Workbook
name
- the name of the defined namepublic void setPrintArea(int sheetIndex, String reference)
i.e. Reference = $A$1:$B$2
setPrintArea
in interface Workbook
sheetIndex
- Zero-based sheet index (0 Represents the first sheet to keep consistent with java)reference
- Valid name Reference for the Print Areapublic void setPrintArea(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow)
setPrintArea
in interface Workbook
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 printareasetPrintArea(int, String)
public String getPrintArea(int sheetIndex)
getPrintArea
in interface Workbook
sheetIndex
- Zero-based sheet index (0 Represents the first sheet to keep consistent with java)public void removePrintArea(int sheetIndex)
removePrintArea
in interface Workbook
sheetIndex
- Zero-based sheet index (0 = First Sheet)public Row.MissingCellPolicy getMissingCellPolicy()
The default is to return blank and null cells.
Row.MissingCellPolicy
getMissingCellPolicy
in interface Workbook
public void setMissingCellPolicy(Row.MissingCellPolicy missingCellPolicy)
Row.getCell(int)
. See
Row.MissingCellPolicy
setMissingCellPolicy
in interface Workbook
public DataFormat createDataFormat()
createDataFormat
in interface Workbook
public int addPicture(byte[] pictureData, int format)
addPicture
in interface Workbook
pictureData
- The bytes of the pictureformat
- The format of the picture.Workbook.PICTURE_TYPE_EMF
,
Workbook.PICTURE_TYPE_WMF
,
Workbook.PICTURE_TYPE_PICT
,
Workbook.PICTURE_TYPE_JPEG
,
Workbook.PICTURE_TYPE_PNG
,
Workbook.PICTURE_TYPE_DIB
public List<? extends PictureData> getAllPictures()
getAllPictures
in interface Workbook
PictureData
objects.)public CreationHelper getCreationHelper()
getCreationHelper
in interface Workbook
public boolean isHidden()
public void setHidden(boolean hiddenFlag)
public boolean isSheetHidden(int sheetIx)
Note that a sheet could instead be set to be very hidden, which is different
(isSheetVeryHidden(int)
)
isSheetHidden
in interface Workbook
sheetIx
- Numbertrue
if sheet is hiddenpublic boolean isSheetVeryHidden(int sheetIx)
This is different from the normal hidden status
(isSheetHidden(int)
)
isSheetVeryHidden
in interface Workbook
sheetIx
- sheet index to checktrue
if sheet is very hiddenpublic void setSheetHidden(int sheetIx, boolean hidden)
setSheetHidden
in interface Workbook
sheetIx
- the sheet index (0-based)hidden
- True to mark the sheet as hidden, false otherwisepublic void setSheetHidden(int sheetIx, int hidden)
setSheetHidden
in interface Workbook
sheetIx
- the sheet index (0-based)hidden
- one of the following Workbook
constants:
Workbook.SHEET_STATE_VISIBLE
,
Workbook.SHEET_STATE_HIDDEN
, or
Workbook.SHEET_STATE_VERY_HIDDEN
.IllegalArgumentException
- if the supplied sheet index or state is invalidpublic void addToolPack(UDFFinder toopack)
addToolPack
in interface Workbook
toopack
- the toolpack to registerpublic void setForceFormulaRecalculation(boolean value)
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.
setForceFormulaRecalculation
in interface Workbook
value
- true if the application will perform a full recalculation of
workbook values when the workbook is openedpublic boolean getForceFormulaRecalculation()
getForceFormulaRecalculation
in interface Workbook
public PivotCache createPivotCache(AreaReference sourceRef)
createPivotCache
in interface Workbook
public List<PivotCache> getPivotCaches()
getPivotCaches
in interface Workbook
public void addDefaultCellStyle(CellStyle cellStyle)
addDefaultCellStyle
in interface Workbook
public List<CellStyle> getDefaultCellStyles()
getDefaultCellStyles
in interface Workbook
public void addNamedStyle(NamedStyle namedStyle)
addNamedStyle
in interface Workbook
public NamedStyle createNamedStyle(String name, boolean custom, int builtinId, int index)
createNamedStyle
in interface Workbook
public List<NamedStyle> getNamedStyles()
getNamedStyles
in interface Workbook
public int addDxfCellStyle(DxfCellStyle cellStyle)
addDxfCellStyle
in interface Workbook
public DxfCellStyle createDxfCellStyle()
createDxfCellStyle
in interface Workbook
public List<DxfCellStyle> getDxfCellStyles()
getDxfCellStyles
in interface Workbook
public void clearDefaultCellStyles()
clearDefaultCellStyles
in interface Workbook
public void clearNamedStyles()
clearNamedStyles
in interface Workbook
public void clearDxfCellStyles()
clearDxfCellStyles
in interface Workbook
public void clearTableStyles()
clearTableStyles
in interface Workbook
public List<TableStyle> getTableStyles()
getTableStyles
in interface Workbook
public String getDefaultPivotStyle()
getDefaultPivotStyle
in interface Workbook
public String getDefaultTableStyle()
getDefaultTableStyle
in interface Workbook
public void addTableStyle(TableStyle tbStyle)
addTableStyle
in interface Workbook
public TableStyle createTableStyle(String name)
createTableStyle
in interface Workbook
public int getDxfIndex(DxfCellStyle dxfCellStyle)
getDxfIndex
in interface Workbook
public void setDefaultPivotStyle(String defaultPivotStyle)
setDefaultPivotStyle
in interface Workbook
public void setDefaultTableStyle(String defaultTableStyle)
setDefaultTableStyle
in interface Workbook
Copyright © 2020. All rights reserved.