public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Support
POIXMLDocumentPart.RelationPart| Modifier and Type | Field and Description |
|---|---|
static int |
PICTURE_TYPE_BMP |
static int |
PICTURE_TYPE_EPS |
static int |
PICTURE_TYPE_GIF
Images formats supported by XSSF but not by HSSF
|
static int |
PICTURE_TYPE_TIFF |
static int |
PICTURE_TYPE_WPG |
DOCUMENT_CREATOR, OLE_OBJECT_REL_TYPE, PACK_OBJECT_REL_TYPEMAX_SENSITIVE_SHEET_NAME_LEN, PICTURE_TYPE_DIB, PICTURE_TYPE_EMF, PICTURE_TYPE_JPEG, PICTURE_TYPE_PICT, PICTURE_TYPE_PNG, PICTURE_TYPE_WMF| Constructor and Description |
|---|
XSSFWorkbook()
Create a new SpreadsheetML workbook.
|
XSSFWorkbook(java.io.File file)
Constructs a XSSFWorkbook object from a given file.
|
XSSFWorkbook(java.io.InputStream is)
Constructs a XSSFWorkbook object, by buffering the whole stream into memory
and then opening an
OPCPackage object for it. |
XSSFWorkbook(OPCPackage pkg)
Constructs a XSSFWorkbook object given a OpenXML4J
Package object,
see https://poi.apache.org/oxml4j/. |
XSSFWorkbook(PackagePart part)
Constructs a XSSFWorkbook object using Package Part.
|
XSSFWorkbook(java.lang.String path)
Constructs a XSSFWorkbook object given a file name.
|
XSSFWorkbook(XSSFFactory factory) |
XSSFWorkbook(XSSFWorkbookType workbookType)
Create a new SpreadsheetML workbook.
|
| Modifier and Type | Method and Description |
|---|---|
int |
addOlePackage(byte[] oleData,
java.lang.String label,
java.lang.String fileName,
java.lang.String command)
Adds an OLE package manager object with the given content to the sheet
|
int |
addPicture(byte[] pictureData,
int format)
Adds a picture to the workbook.
|
int |
addPicture(java.io.InputStream is,
int format)
Adds a picture to the workbook.
|
protected org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotCache |
addPivotCache(java.lang.String rId)
Add pivotCache to the workbook
|
void |
addToolPack(UDFFinder toolpack)
Register a new toolpack in this workbook.
|
protected void |
beforeDocumentRead() |
XSSFSheet |
cloneSheet(int sheetNum)
Create an XSSFSheet from an existing sheet in the XSSFWorkbook.
|
XSSFSheet |
cloneSheet(int sheetNum,
java.lang.String newName)
Create an XSSFSheet from an existing sheet in the XSSFWorkbook.
|
void |
close()
Closes the underlying
OPCPackage from which this
document was read, if there is one |
protected void |
commit()
Save the content in the underlying package part.
|
XSSFCellStyle |
createCellStyle()
Create a new XSSFCellStyle and add it to the workbook's style table
|
XSSFDataFormat |
createDataFormat()
Returns the workbook's data format table (a factory for creating data format strings).
|
protected XSSFDialogsheet |
createDialogsheet(java.lang.String sheetname,
org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDialogsheet dialogsheet) |
XSSFEvaluationWorkbook |
createEvaluationWorkbook() |
XSSFFont |
createFont()
Create a new Font and add it to the workbook's font table
|
XSSFName |
createName()
Creates a new (uninitialised) defined name in this workbook
|
XSSFSheet |
createSheet()
Create an XSSFSheet for this workbook, adds it to the sheets and returns
the high level representation.
|
XSSFSheet |
createSheet(java.lang.String sheetname)
Create a new sheet for this Workbook and return the high level representation.
|
XSSFFont |
findFont(boolean bold,
short color,
short fontHeight,
java.lang.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.
|
java.util.List<PackagePart> |
getAllEmbeddedParts()
Get the document's embedded files.
|
java.util.List<XSSFName> |
getAllNames()
Get a list of all the named ranges in the workbook.
|
java.util.List<XSSFPictureData> |
getAllPictures()
Gets all pictures from the Workbook.
|
CalculationChain |
getCalculationChain()
Return the
CalculationChain object for this workbook |
boolean |
getCellFormulaValidation()
Whether a call to
CellBase.setCellFormula(String) will validate the formula or not. |
CellReferenceType |
getCellReferenceType() |
XSSFCellStyle |
getCellStyleAt(int idx)
Get the cell style object at the given index
|
XSSFCreationHelper |
getCreationHelper()
Returns an object that handles instantiating concrete
classes of the various instances for XSSF.
|
org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook |
getCTWorkbook()
Return the underlying XML bean
|
java.util.Collection<XSSFMap> |
getCustomXMLMappings() |
java.util.List<ExternalLinksTable> |
getExternalLinksTable()
Returns the list of
ExternalLinksTable object for this workbook |
int |
getFirstVisibleTab()
Gets the first tab that is displayed in the list of tabs in excel.
|
XSSFFont |
getFontAt(int 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.
|
MapInfo |
getMapInfo() |
Row.MissingCellPolicy |
getMissingCellPolicy()
Retrieves the current policy on what to do when
getting missing or blank cells from a row.
|
XSSFName |
getName(java.lang.String name)
Get the first named range with the given name.
|
java.util.List<XSSFName> |
getNames(java.lang.String name)
Get the named ranges with the given name.
|
int |
getNumberOfFonts()
Get the number of fonts in the font table
|
int |
getNumberOfFontsAsInt()
Deprecated.
|
int |
getNumberOfNames()
Get the number of named ranges in the this workbook
|
int |
getNumberOfSheets()
Get the number of worksheets in the this workbook
|
int |
getNumCellStyles()
Get the number of styles the workbook contains
|
java.util.List<XSSFPivotTable> |
getPivotTables() |
java.lang.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.
|
SharedStringsTable |
getSharedStringSource()
Returns SharedStringsTable - tha cache of string for this workbook
|
XSSFSheet |
getSheet(java.lang.String name)
Get sheet with the given name (case insensitive match)
|
XSSFSheet |
getSheetAt(int index)
Get the XSSFSheet object at the given index.
|
int |
getSheetIndex(Sheet sheet)
Returns the index of the given sheet
|
int |
getSheetIndex(java.lang.String name)
Returns the index of the sheet by his name (case insensitive match)
|
java.lang.String |
getSheetName(int sheetIx)
Get the sheet name
|
SheetVisibility |
getSheetVisibility(int sheetIx)
Get the visibility (visible, hidden, very hidden) of a sheet in this workbook
|
SpreadsheetVersion |
getSpreadsheetVersion()
Returns the spreadsheet version (EXCLE2007) of this workbook
|
StylesTable |
getStylesSource()
Return a object representing a collection of shared objects used for styling content,
e.g.
|
XSSFTable |
getTable(java.lang.String name)
Returns the data table with the given name (case insensitive).
|
ThemesTable |
getTheme()
Returns the Theme of current workbook.
|
XSSFWorkbookType |
getWorkbookType() |
XSSFFactory |
getXssfFactory() |
boolean |
isDate1904()
Gets a boolean value that indicates whether the date systems used in the workbook starts in 1904.
|
boolean |
isHidden() |
boolean |
isMacroEnabled()
Are we a normal workbook (.xlsx), or a
macro enabled workbook (.xlsm)?
|
boolean |
isRevisionLocked()
Specifies a boolean value that indicates whether the workbook is locked for revisions.
|
boolean |
isSheetHidden(int sheetIx)
Check whether a sheet is hidden.
|
boolean |
isSheetVeryHidden(int sheetIx)
Check whether a sheet is very hidden.
|
boolean |
isStructureLocked()
Specifies a boolean value that indicates whether structure of workbook is locked.
|
boolean |
isWindowsLocked()
Specifies a boolean value that indicates whether the windows that comprise the workbook are locked.
|
java.util.Iterator<Sheet> |
iterator()
Alias for
sheetIterator() to allow
foreach loops
Note: remove() is not supported on this iterator. |
int |
linkExternalWorkbook(java.lang.String name,
Workbook workbook)
Adds the External Link Table part and relations required to allow formulas
referencing the specified external workbook to be added to this one.
|
void |
lockRevision()
Locks the workbook for revisions.
|
void |
lockStructure()
Locks the structure of workbook.
|
void |
lockWindows()
Locks the windows that comprise the workbook.
|
protected static OPCPackage |
newPackage(XSSFWorkbookType workbookType)
Create a new SpreadsheetML package and setup the default minimal content
|
protected void |
onDeleteFormula(XSSFCell cell)
Fired when a formula is deleted from this workbook,
for example when calling cell.setCellFormula(null)
|
protected void |
onDocumentRead()
Fired when a package part is read
|
void |
parseSheet(java.util.Map<java.lang.String,XSSFSheet> shIdMap,
org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet ctSheet)
Not normally to be called externally, but possibly to be overridden to avoid
the DOM based parse of large sheets (see examples).
|
void |
removeName(Name name)
Remove a defined 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 index)
Convenience method to set the active sheet.
|
void |
setCellFormulaValidation(boolean value)
Whether a call to
CellBase.setCellFormula(String) will validate the formula or not. |
void |
setCellReferenceType(CellReferenceType cellReferenceType) |
void |
setFirstVisibleTab(int index)
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.
|
protected void |
setPivotTables(java.util.List<XSSFPivotTable> pivotTables) |
void |
setPrintArea(int sheetIndex,
int startColumn,
int endColumn,
int startRow,
int endRow)
For the Convenience of Java Programmers maintaining pointers.
|
void |
setPrintArea(int sheetIndex,
java.lang.String reference)
Sets the printarea for the sheet provided
|
void |
setRevisionsPassword(java.lang.String password,
HashAlgorithm hashAlgo)
Sets the revisions password.
|
void |
setSelectedTab(int index)
We only set one sheet as selected for compatibility with HSSF.
|
void |
setSheetHidden(int sheetIx,
boolean hidden)
Hide or unhide a sheet.
|
void |
setSheetName(int sheetIndex,
java.lang.String sheetname)
Set the sheet name.
|
void |
setSheetOrder(java.lang.String sheetname,
int pos)
sets the order of appearance for a given sheet.
|
void |
setSheetVisibility(int sheetIx,
SheetVisibility visibility)
Hide or unhide a sheet.
|
void |
setVBAProject(java.io.InputStream vbaProjectStream)
Adds a vbaProject.bin file to the workbook.
|
void |
setVBAProject(XSSFWorkbook macroWorkbook)
Adds a vbaProject.bin file taken from another, given workbook to this one.
|
void |
setWorkbookPassword(java.lang.String password,
HashAlgorithm hashAlgo)
Sets the workbook password.
|
void |
setWorkbookType(XSSFWorkbookType type)
Sets whether the workbook will be an .xlsx or .xlsm (macro-enabled) file.
|
java.util.Iterator<Sheet> |
sheetIterator()
Returns an iterator of the sheets in the workbook
in sheet order.
|
java.util.Spliterator<Sheet> |
spliterator()
Returns a spliterator of the sheets in the workbook
in sheet order.
|
void |
unLock()
Removes the workbook protection settings
|
void |
unLockRevision()
Unlocks the workbook for revisions.
|
void |
unLockStructure()
Unlocks the structure of workbook.
|
void |
unLockWindows()
Unlocks the windows that comprise the workbook.
|
boolean |
validateRevisionsPassword(java.lang.String password)
Validate the password against the stored hash, the hashing method will be determined
by the existing password attributes
|
boolean |
validateWorkbookPassword(java.lang.String password)
Validate the password against the stored hash, the hashing method will be determined
by the existing password attributes
|
getCorePart, getPackage, getProperties, getRelatedByType, load, openPackage, write_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommitted, onDocumentCreate, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeRelation, removeRelation, removeRelation, setCommitted, toStringpublic static final int PICTURE_TYPE_GIF
public static final int PICTURE_TYPE_TIFF
public static final int PICTURE_TYPE_EPS
public static final int PICTURE_TYPE_BMP
public static final int PICTURE_TYPE_WPG
public XSSFWorkbook()
public XSSFWorkbook(XSSFFactory factory)
public XSSFWorkbook(XSSFWorkbookType workbookType)
workbookType - The type of workbook to make (.xlsx or .xlsm).public XSSFWorkbook(OPCPackage pkg) throws java.io.IOException
Package object,
see https://poi.apache.org/oxml4j/.
Once you have finished working with the Workbook, you should close the package
by calling either close() or OPCPackage.close(), to avoid
leaving file handles open.
Creating a XSSFWorkbook from a file-backed OPC Package has a lower memory footprint than an InputStream backed one.
pkg - the OpenXML4J OPC Package object.java.io.IOException - If reading data from the package failsPOIXMLException - a RuntimeException that can be caused by invalid OOXML datajava.lang.RuntimeException - a number of other runtime exceptions can be thrown, especially if there are problems with the
input formatpublic XSSFWorkbook(java.io.InputStream is)
throws java.io.IOException
OPCPackage object for it.
Using an InputStream requires more memory than using a File, so
if a File is available then you should instead do something like
OPCPackage pkg = OPCPackage.open(path);
XSSFWorkbook wb = new XSSFWorkbook(pkg);
// work with the wb object
......
pkg.close(); // gracefully closes the underlying zip file
java.io.IOException - If reading data from the stream failsPOIXMLException - a RuntimeException that can be caused by invalid OOXML datajava.lang.RuntimeException - a number of other runtime exceptions can be thrown, especially if there are problems with the
input formatpublic XSSFWorkbook(java.io.File file)
throws java.io.IOException,
InvalidFormatException
Once you have finished working with the Workbook, you should close
the package by calling close(), to avoid leaving file
handles open.
Opening a XSSFWorkbook from a file has a lower memory footprint than opening from an InputStream
file - the file to openjava.io.IOException - If reading data from the file failsInvalidFormatException - If the file has a format that cannot be read or if the file is corruptedPOIXMLException - a RuntimeException that can be caused by invalid OOXML datajava.lang.RuntimeException - a number of other runtime exceptions can be thrown, especially if there are problems with the
input formatpublic XSSFWorkbook(java.lang.String path)
throws java.io.IOException
Once you have finished working with the Workbook, you should close
the package by calling close(), to avoid leaving file
handles open.
Opening a XSSFWorkbook from a file has a lower memory footprint than opening from an InputStream
path - the file name.java.io.IOException - If reading data from the file failsPOIXMLException - a RuntimeException that can be caused by invalid OOXML datajava.lang.RuntimeException - a number of other runtime exceptions can be thrown, especially if there are problems with the
input formatpublic XSSFWorkbook(PackagePart part) throws java.io.IOException
part - package partjava.io.IOException - If reading data from the Package Part failsPOIXMLException - a RuntimeException that can be caused by invalid OOXML datajava.lang.RuntimeException - a number of other runtime exceptions can be thrown, especially if there are problems with the
input formatpublic XSSFFactory getXssfFactory()
protected void beforeDocumentRead()
protected void onDocumentRead()
throws java.io.IOException
POIXMLDocumentPartonDocumentRead in class POIXMLDocumentPartjava.io.IOException - a subclass may throw an IOException when a document is readpublic void parseSheet(java.util.Map<java.lang.String,XSSFSheet> shIdMap, org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet ctSheet)
POIXMLException - a RuntimeException that can be caused by invalid OOXML datajava.lang.RuntimeException - a number of other runtime exceptions can be thrown, especially if there are problems with the
input formatprotected static OPCPackage newPackage(XSSFWorkbookType workbookType)
@Internal public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook getCTWorkbook()
public int addPicture(byte[] pictureData,
int format)
addPicture in interface WorkbookpictureData - The bytes of the pictureformat - The format of the picture.getAllPictures() .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 int addPicture(java.io.InputStream is,
int format)
throws java.io.IOException
is - The sream to read image fromformat - The format of the picture.getAllPictures() .java.io.IOExceptionWorkbook.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 XSSFSheet cloneSheet(int sheetNum)
cloneSheet in interface WorkbooksheetNum - The index of the sheet to clonejava.lang.IllegalArgumentException - if the sheet index in invalidPOIXMLException - if there were errors when cloningpublic void close()
throws java.io.IOException
POIXMLDocumentOPCPackage from which this
document was read, if there is one
Once this has been called, no further operations, updates or reads should be performed on the document.
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface Workbookclose in class POIXMLDocumentjava.io.IOException - for writable packages, if an IO exception occur during the saving process.public XSSFSheet cloneSheet(int sheetNum, java.lang.String newName)
sheetNum - The index of the sheet to clonenewName - The name to set for the newly created sheetjava.lang.IllegalArgumentException - if the sheet index or the sheet
name is invalidPOIXMLException - if there were errors when cloningpublic XSSFCellStyle createCellStyle()
createCellStyle in interface Workbookpublic XSSFDataFormat createDataFormat()
createDataFormat in interface WorkbookDataFormatpublic XSSFFont createFont()
createFont in interface Workbookpublic XSSFName createName()
WorkbookcreateName in interface Workbookpublic XSSFSheet createSheet()
createSheet in interface Workbookpublic XSSFSheet createSheet(java.lang.String sheetname)
Note that Excel allows sheet names up to 31 chars in length but other applications (such as OpenOffice) allow more. Some versions of Excel crash with names longer than 31 chars, others - truncate such names to 31 character.
POI's SpreadsheetAPI silently truncates the input argument to 31 characters. Example:
Sheet sheet = workbook.createSheet("My very long sheet name which is longer than 31 chars"); // will be truncated
assert 31 == sheet.getSheetName().length();
assert "My very long sheet name which i" == sheet.getSheetName();
Except the 31-character constraint, Excel applies some other rules:
Sheet name MUST be unique in the workbook and MUST NOT contain the any of the following characters:
See WorkbookUtil.createSafeSheetName(String nameProposal)
for a safe way to create valid names
createSheet in interface Workbooksheetname - sheetname to set for the sheet.java.lang.IllegalArgumentException - if the name is null or invalid
or workbook already contains a sheet with this nameWorkbookUtil.createSafeSheetName(String nameProposal)protected XSSFDialogsheet createDialogsheet(java.lang.String sheetname, org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDialogsheet dialogsheet)
public XSSFFont findFont(boolean bold, short color, short fontHeight, java.lang.String name, boolean italic, boolean strikeout, short typeOffset, byte underline)
public int getActiveSheetIndex()
getActiveSheetIndex in interface Workbookpublic java.util.List<XSSFPictureData> getAllPictures()
getAllPictures in interface WorkbookXSSFPictureData objects.)addPicture(byte[], int)public XSSFCellStyle getCellStyleAt(int idx)
getCellStyleAt in interface Workbookidx - index within the set of stylespublic XSSFFont getFontAt(int idx)
Workbookpublic XSSFName getName(java.lang.String name)
getNames(String name) returns all named ranges with the given name.public java.util.List<XSSFName> getNames(java.lang.String name)
public java.util.List<XSSFName> getAllNames()
getAllNames in interface Workbookpublic int getNumCellStyles()
getNumCellStyles in interface Workbookpublic int getNumberOfFonts()
WorkbookgetNumberOfFonts in interface Workbook@Deprecated @Removal(version="6.0.0") public int getNumberOfFontsAsInt()
WorkbookgetNumberOfFontsAsInt in interface Workbookpublic int getNumberOfNames()
getNumberOfNames in interface Workbookpublic int getNumberOfSheets()
getNumberOfSheets in interface Workbookpublic java.lang.String getPrintArea(int sheetIndex)
getPrintArea in interface WorkbooksheetIndex - Zero-based sheet index (0 Represents the first sheet to keep consistent with java)public XSSFSheet getSheet(java.lang.String name)
public XSSFSheet getSheetAt(int index)
getSheetAt in interface Workbookindex - of the sheet number (0-based physical & logical)java.lang.IllegalArgumentException - if the index is out of range (index
< 0 || index >= getNumberOfSheets()).public int getSheetIndex(java.lang.String name)
getSheetIndex in interface Workbookname - the sheet name-1 if not foundpublic int getSheetIndex(Sheet sheet)
getSheetIndex in interface Workbooksheet - the sheet to look up-1 if not foundpublic java.lang.String getSheetName(int sheetIx)
getSheetName in interface WorkbooksheetIx - Numberpublic java.util.Iterator<Sheet> sheetIterator()
removeSheetAt(int) to remove sheets instead.sheetIterator in interface Workbookpublic java.util.Iterator<Sheet> iterator()
sheetIterator() to allow
foreach loops
Note: remove() is not supported on this iterator.
Use removeSheetAt(int) to remove sheets instead.public java.util.Spliterator<Sheet> spliterator()
spliterator in interface java.lang.Iterable<Sheet>spliterator in interface Workbookpublic boolean isMacroEnabled()
public void removeName(Name name)
WorkbookremoveName in interface Workbookname - the name to remove.java.lang.IllegalArgumentException - if the named range is not a part of this XSSFWorkbookpublic void removePrintArea(int sheetIndex)
removePrintArea in interface WorkbooksheetIndex - 0-based sheet index (0 = First Sheet)public void removeSheetAt(int index)
Care must be taken if the removed sheet is the currently active or only selected sheet in
the workbook. There are a few situations when Excel must have a selection and/or active
sheet. (For example when printing - see Bug 40414).
This method makes sure that if the removed sheet was active, another sheet will become
active in its place. Furthermore, if the removed sheet was the only selected sheet, another
sheet will become selected. The newly active/selected sheet will have the same index, or
one less if the removed sheet was the last in the workbook.
removeSheetAt in interface Workbookindex - of the sheet (0-based)public Row.MissingCellPolicy getMissingCellPolicy()
Row.MissingCellPolicygetMissingCellPolicy in interface Workbookpublic void setMissingCellPolicy(Row.MissingCellPolicy missingCellPolicy)
Row.getCell(int)}. See
Row.MissingCellPolicysetMissingCellPolicy in interface Workbookpublic void setActiveSheet(int index)
setActiveSheet in interface Workbookindex - index of the active sheet (0-based)public int getFirstVisibleTab()
getFirstVisibleTab in interface Workbookpublic void setFirstVisibleTab(int index)
setFirstVisibleTab in interface Workbookindex - integer that contains the index to the active sheet in this book view.public void setPrintArea(int sheetIndex,
java.lang.String reference)
i.e. Reference = $A$1:$B$2
setPrintArea in interface WorkbooksheetIndex - 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 WorkbooksheetIndex - 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 CellReferenceType getCellReferenceType()
getCellReferenceType in interface Workbookpublic void setCellReferenceType(CellReferenceType cellReferenceType)
setCellReferenceType in interface WorkbookcellReferenceType - the type of cell references usedpublic void setSelectedTab(int index)
setSelectedTab in interface Workbookindex - the index of the sheet to select (0 based)Sheet.setSelected(boolean)public void setSheetName(int sheetIndex,
java.lang.String sheetname)
setSheetName in interface WorkbooksheetIndex - sheet number (0 based)sheetname - the new sheet namejava.lang.IllegalArgumentException - if the name is null or invalid
or workbook already contains a sheet with this namecreateSheet(String),
WorkbookUtil.createSafeSheetName(String nameProposal)public void setSheetOrder(java.lang.String sheetname,
int pos)
setSheetOrder in interface Workbooksheetname - the name of the sheet to reorderpos - the position that we want to insert the sheet into (0 based)protected void commit()
throws java.io.IOException
POIXMLDocumentPartSub-classes should override and add logic to marshal the "model" into Ooxml4J.
For example, the code saving a generic XML entry may look as follows:
protected void commit() throws IOException {
PackagePart part = getPackagePart();
try (OutputStream out = part.getOutputStream()) {
XmlObject bean = getXmlBean(); //the "model" which holds changes in memory
bean.save(out, DEFAULT_XML_OPTIONS);
}
}
commit in class POIXMLDocumentPartjava.io.IOException - a subclass may throw an IOException if the changes can't be committed@Internal public SharedStringsTable getSharedStringSource()
public StylesTable getStylesSource()
public ThemesTable getTheme()
public XSSFCreationHelper getCreationHelper()
getCreationHelper in interface Workbook@Internal public boolean isDate1904()
The default value is false, meaning that the workbook uses the 1900 date system, where 1/1/1900 is the first day in the system..
isDate1904 in interface Date1904Supportpublic java.util.List<PackagePart> getAllEmbeddedParts() throws OpenXML4JException
getAllEmbeddedParts in class POIXMLDocumentOpenXML4JException - if the embedded parts can't be determined@NotImplemented public boolean isHidden()
@NotImplemented public void setHidden(boolean hiddenFlag)
public boolean isSheetHidden(int sheetIx)
Workbook
Note that a sheet could instead be set to be very hidden, which is different
(Workbook.isSheetVeryHidden(int))
isSheetHidden in interface WorkbooksheetIx - Numbertrue if sheet is hiddenWorkbook.getSheetVisibility(int)public boolean isSheetVeryHidden(int sheetIx)
Workbook
This is different from the normal hidden status
(Workbook.isSheetHidden(int))
isSheetVeryHidden in interface WorkbooksheetIx - sheet index to checktrue if sheet is very hiddenWorkbook.getSheetVisibility(int)public SheetVisibility getSheetVisibility(int sheetIx)
WorkbookgetSheetVisibility in interface WorkbooksheetIx - the index of the sheetpublic void setSheetHidden(int sheetIx,
boolean hidden)
WorkbooksetSheetHidden in interface WorkbooksheetIx - the sheet index (0-based)hidden - True to mark the sheet as hidden, false otherwiseWorkbook.setSheetVisibility(int, SheetVisibility)public void setSheetVisibility(int sheetIx,
SheetVisibility visibility)
WorkbooksetSheetVisibility in interface WorkbooksheetIx - the sheet index (0-based)visibility - the sheet visibility to setprotected void onDeleteFormula(XSSFCell cell)
CellBase.setCellFormula(String)@Internal public CalculationChain getCalculationChain()
CalculationChain object for this workbook
The calculation chain object specifies the order in which the cells in a workbook were last calculated
CalculationChain object or null if not defined@Internal public java.util.List<ExternalLinksTable> getExternalLinksTable()
ExternalLinksTable object for this workbook
The external links table specifies details of named ranges etc that are referenced from other workbooks, along with the last seen values of what they point to.
Note that Excel uses index 0 for the current workbook, so the first External Links in a formula would be '[1]Foo' which corresponds to entry 0 in this list.
ExternalLinksTable list, which may be emptypublic java.util.Collection<XSSFMap> getCustomXMLMappings()
@Internal public MapInfo getMapInfo()
@Beta public int linkExternalWorkbook(java.lang.String name, Workbook workbook)
This support is still regarded as in beta and may change
see https://bz.apache.org/bugzilla/show_bug.cgi?id=57184
linkExternalWorkbook in interface Workbookname - The name the workbook will be referenced as in formulasworkbook - The open workbook to fetch the link required information frompublic boolean isStructureLocked()
public boolean isWindowsLocked()
public boolean isRevisionLocked()
public void lockStructure()
public void unLockStructure()
public void lockWindows()
public void unLockWindows()
public void lockRevision()
public void unLockRevision()
public void setWorkbookPassword(java.lang.String password,
HashAlgorithm hashAlgo)
password - if null, the password will be removedhashAlgo - if null, the password will be set as XOR password (Excel 2010 and earlier)
otherwise the given algorithm is used for calculating the hash password (Excel 2013)public boolean validateWorkbookPassword(java.lang.String password)
public void setRevisionsPassword(java.lang.String password,
HashAlgorithm hashAlgo)
password - if null, the password will be removedhashAlgo - if null, the password will be set as XOR password (Excel 2010 and earlier)
otherwise the given algorithm is used for calculating the hash password (Excel 2013)public boolean validateRevisionsPassword(java.lang.String password)
public void unLock()
public void addToolPack(UDFFinder toolpack)
addToolPack in interface Workbooktoolpack - 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 true, this flag will tell Excel that it needs to recalculate all formulas in the workbook the next time the file is opened.
Note, that recalculation updates cached formula results and, thus, modifies the workbook. Depending on the version, Excel may prompt you with "Do you want to save the changes in filename?" on close.
setForceFormulaRecalculation in interface Workbookvalue - true if the application will perform a full recalculation of
workbook values when the workbook is openedpublic boolean getForceFormulaRecalculation()
getForceFormulaRecalculation in interface Workbook@Beta protected org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotCache addPivotCache(java.lang.String rId)
@Beta public java.util.List<XSSFPivotTable> getPivotTables()
@Beta protected void setPivotTables(java.util.List<XSSFPivotTable> pivotTables)
public XSSFWorkbookType getWorkbookType()
public void setWorkbookType(XSSFWorkbookType type)
public void setVBAProject(java.io.InputStream vbaProjectStream)
throws java.io.IOException
java.io.IOException - If copying data from the stream fails.public void setVBAProject(XSSFWorkbook macroWorkbook) throws java.io.IOException, InvalidFormatException
java.io.IOException - If copying the VBAProject stream fails.InvalidFormatException - If an error occurs while handling parts of the XSSF formatpublic SpreadsheetVersion getSpreadsheetVersion()
getSpreadsheetVersion in interface Workbookpublic XSSFTable getTable(java.lang.String name)
name - the data table name (case-insensitive)name, or null if no table is named name.public int addOlePackage(byte[] oleData,
java.lang.String label,
java.lang.String fileName,
java.lang.String command)
throws java.io.IOException
WorkbookaddOlePackage in interface WorkbookoleData - the payloadlabel - the label of the payloadfileName - the original filenamecommand - the command to open the payloadjava.io.IOException - if the object can't be embeddedpublic void setCellFormulaValidation(boolean value)
CellBase.setCellFormula(String) will validate the formula or not.
When enabled (which is the default), this option can lead to formulas being modified by POI formula renderer.value - true if the application will validate the formula is correctpublic boolean getCellFormulaValidation()
CellBase.setCellFormula(String) will validate the formula or not.
When enabled (which is the default), this option can lead to formulas being modified by POI formula renderer.public XSSFEvaluationWorkbook createEvaluationWorkbook()
createEvaluationWorkbook in interface WorkbookCopyright 2022 The Apache Software Foundation or its licensors, as applicable.