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
(XSSF 支持但 HSSF 不支持的图像格式)
|
static int |
PICTURE_TYPE_TIFF |
static int |
PICTURE_TYPE_WPG |
DOCUMENT_CREATOR, OLE_OBJECT_REL_TYPE, PACK_OBJECT_REL_TYPE
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
(将具有给定内容的 OLE 包管理器对象添加到工作表)
|
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
(将 pivotCache 添加到工作簿)
|
void |
addToolPack(UDFFinder toopack)
Register a new toolpack in this workbook.
(在此工作簿中注册一个新的工具包。)
|
protected void |
beforeDocumentRead() |
XSSFSheet |
cloneSheet(int sheetNum)
Create an XSSFSheet from an existing sheet in the XSSFWorkbook.
(从 XSSFWorkbook 中的现有工作表创建 XSSFSheet。)
|
XSSFSheet |
cloneSheet(int sheetNum, java.lang.String newName)
Create an XSSFSheet from an existing sheet in the XSSFWorkbook.
(从 XSSFWorkbook 中的现有工作表创建 XSSFSheet。)
|
void |
close()
Closes the underlying
OPCPackage from which this document was read, if there is one
(关闭从中读取此文档的底层 OPCPackage(如果有))
|
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
(创建一个新的 XSSFCellStyle 并将其添加到工作簿的样式表中)
|
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,将其添加到工作表并返回高级表示。)
|
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
(返回此工作簿的 CalculationChain 对象)
|
boolean |
getCellFormulaValidation()
Whether a call to
CellBase.setCellFormula(String) will validate the formula or not.
(对 CellBase.setCellFormula(String) 的调用是否会验证公式。)
|
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.
(返回一个对象,该对象处理实例化 XSSF 的各种实例的具体类。)
|
org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook |
getCTWorkbook()
Return the underlying XML bean
(返回底层 XML bean)
|
java.util.Collection<XSSFMap> |
getCustomXMLMappings() |
java.util.List<ExternalLinksTable> |
getExternalLinksTable()
Returns the list of
ExternalLinksTable object for this workbook
(返回此工作簿的 ExternalLinksTable 对象列表)
|
int |
getFirstVisibleTab()
Gets the first tab that is displayed in the list of tabs in excel.
(获取在 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.
(打开工作簿时是否会要求 Excel 重新计算所有公式。)
|
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
(返回 SharedStringsTable - 此工作簿的字符串缓存)
|
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.
(获取给定索引处的 XSSFSheet 对象。)
|
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
(返回此工作簿的电子表格版本 (EXCLE2007))
|
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() |
boolean |
isDate1904()
Gets a boolean value that indicates whether the date systems used in the workbook starts in 1904.
(获取一个布尔值,该值指示工作簿中使用的日期系统是否从 1904 年开始。)
|
boolean |
isHidden() |
boolean |
isMacroEnabled()
Are we a normal workbook (.xlsx), or a macro enabled workbook (.xlsm)?
(我们是普通工作簿 (.xlsx),还是启用宏的工作簿 (.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.
(允许 foreach 循环的 sheetIterator() 的别名 注意:此迭代器不支持 remove()。)
|
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
(创建一个新的 SpreadsheetML 包并设置默认的最小内容)
|
protected void |
onDeleteFormula(XSSFCell cell)
Fired when a formula is deleted from this workbook, for example when calling cell.setCellFormula(null)
(从此工作簿中删除公式时触发,例如调用 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).
(通常不会在外部调用,但可能会被覆盖以避免基于 DOM 的大型工作表解析(参见示例)。)
|
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.
(对 CellBase.setCellFormula(String) 的调用是否会验证公式。)
|
void |
setFirstVisibleTab(int index)
Sets the first tab that is displayed in the list of tabs in excel.
(设置在 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.
(为了方便 Java 程序员维护指针。)
|
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.
(为了与 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.
(将 vbaProject.bin 文件添加到工作簿。)
|
void |
setVBAProject(XSSFWorkbook macroWorkbook)
Adds a vbaProject.bin file taken from another, given workbook to this one.
(将取自另一个给定工作簿的 vbaProject.bin 文件添加到该工作簿。)
|
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.
(设置工作簿是 .xlsx 还是 .xlsm(启用宏)文件。)
|
java.util.Iterator<Sheet> |
sheetIterator()
Returns an iterator 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, toString
public 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).
(workbookType - 要制作的工作簿的类型(.xlsx 或 .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.
(在给定 OpenXML4J Package 对象的情况下构造一个 XSSFWorkbook 对象,请参阅 https://poi.apache.org/oxml4j/。完成工作簿的处理后,应通过调用 close() 或 OPCPackage.close() 来关闭包,以避免文件句柄处于打开状态。从文件支持的 OPC 包创建 XSSFWorkbook 的内存占用低于 InputStream 支持的包。)pkg
- the OpenXML4J
OPC Package
object.
(pkg - OpenXML4J OPC 包对象。)
java.io.IOException
(java.io.IOException)
public 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
(构造一个 XSSFWorkbook 对象,方法是将整个流缓冲到内存中,然后为其打开一个 OPCPackage 对象。使用 InputStream 比使用 File 需要更多内存,因此如果 File 可用,那么您应该改为执行类似 OPCPackage pkg = OPCPackage.open(path); XSSFWorkbook wb = new XSSFWorkbook(pkg); // 使用 wb 对象 ...... pkg.close(); // 优雅地关闭底层 zip 文件)
java.io.IOException
(java.io.IOException)
public 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
(从给定文件构造一个 XSSFWorkbook 对象。完成工作簿的处理后,应通过调用 close() 关闭包,以避免文件句柄处于打开状态。从文件打开 XSSFWorkbook 比从 InputStream 打开内存占用更少)file
- the file to open
(file - 要打开的文件)
java.io.IOException
(java.io.IOException)
InvalidFormatException
(无效格式异常)
public 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
(构造一个给定文件名的 XSSFWorkbook 对象。完成工作簿的处理后,应通过调用 close() 关闭包,以避免文件句柄处于打开状态。从文件打开 XSSFWorkbook 比从 InputStream 打开内存占用更少)path
- the file name.
(路径 - 文件名。)
java.io.IOException
(java.io.IOException)
public XSSFWorkbook(PackagePart part) throws java.io.IOException
part
- package part
(部分 - 封装部分)
java.io.IOException
(java.io.IOException)
protected void beforeDocumentRead()
protected void onDocumentRead() throws java.io.IOException
POIXMLDocumentPart
onDocumentRead
in class
POIXMLDocumentPart
java.io.IOException
- a subclass may throw an IOException when a document is read
(java.io.IOException - 读取文档时子类可能会抛出 IOException)
public void parseSheet(java.util.Map<java.lang.String,XSSFSheet> shIdMap, org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet ctSheet)
protected 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
Workbook
(界面 Workbook 中的 addPicture)
pictureData
- The bytes of the picture
(pictureData - 图片的字节数)
format
- The format of the picture.
(format - 图片的格式。)
getAllPictures()
.
(该图片的索引(从0开始),添加的图片可以从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 from
(is - 从中读取图像的目标)
format
- The format of the picture.
(format - 图片的格式。)
getAllPictures()
.
(该图片的索引(从0开始),添加的图片可以从getAllPictures()中获得。)
java.io.IOException
(java.io.IOException)
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 XSSFSheet cloneSheet(int sheetNum)
cloneSheet
in interface
Workbook
(界面 Workbook 中的 cloneSheet)
sheetNum
- The index of the sheet to clone
(sheetNum - 要克隆的工作表的索引)
java.lang.IllegalArgumentException
- if the sheet index in invalid
(java.lang.IllegalArgumentException - 如果工作表索引无效)
POIXMLException
- if there were errors when cloning
(POIXMLException - 如果克隆时出现错误)
public void close() throws java.io.IOException
POIXMLDocument
OPCPackage
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.
(关闭从中读取此文档的底层 OPCPackage,如果有的话,一旦调用了这个,就不应对文档执行进一步的操作、更新或读取。)close
in interface
java.io.Closeable
(在接口 java.io.Closeable 中关闭)
close
in interface
java.lang.AutoCloseable
(在接口 java.lang.AutoCloseable 中关闭)
close
in interface
Workbook
(在界面工作簿中关闭)
close
in class
POIXMLDocument
java.io.IOException
- for writable packages, if an IO exception occur during the saving process.
(java.io.IOException - 对于可写包,如果在保存过程中发生 IO 异常。)
public XSSFSheet cloneSheet(int sheetNum, java.lang.String newName)
sheetNum
- The index of the sheet to clone
(sheetNum - 要克隆的工作表的索引)
newName
- The name to set for the newly created sheet
(newName - 为新创建的工作表设置的名称)
java.lang.IllegalArgumentException
- if the sheet index or the sheet name is invalid
(java.lang.IllegalArgumentException - 如果工作表索引或工作表名称无效)
POIXMLException
- if there were errors when cloning
(POIXMLException - 如果克隆时出现错误)
public XSSFCellStyle createCellStyle()
createCellStyle
in interface
Workbook
(界面 Workbook 中的 createCellStyle)
public XSSFDataFormat createDataFormat()
createDataFormat
in interface
Workbook
(接口 Workbook 中的 createDataFormat)
DataFormat
public XSSFFont createFont()
createFont
in interface
Workbook
(界面 Workbook 中的 createFont)
public XSSFName createName()
Workbook
createName
in interface
Workbook
(界面 Workbook 中的 createName)
public XSSFSheet createSheet()
createSheet
in interface
Workbook
(界面 Workbook 中的 createSheet)
public 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
Workbook
(界面 Workbook 中的 createSheet)
sheetname
- sheetname to set for the sheet.
(sheetname - 为工作表设置的工作表名。)
java.lang.IllegalArgumentException
- if the name is null or invalid or workbook already contains a sheet with this name
(java.lang.IllegalArgumentException - 如果名称为 null 或无效,或者工作簿已包含具有此名称的工作表)
WorkbookUtil.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
Workbook
(接口 Workbook 中的 getActiveSheetIndex)
public java.util.List<XSSFPictureData> getAllPictures()
getAllPictures
in interface
Workbook
(接口 Workbook 中的 getAllPictures)
XSSFPictureData
objects.)
(图片列表(XSSFPitureData 对象的列表。))
addPicture(byte[], int)
public XSSFCellStyle getCellStyleAt(int idx)
getCellStyleAt
in interface
Workbook
(接口 Workbook 中的 getCellStyleAt)
idx
- index within the set of styles
(idx - 样式集中的索引)
public XSSFFont getFontAt(int idx)
Workbook
public XSSFName getName(java.lang.String name)
getNames(String name)
returns all named ranges with the given name.
(获取具有给定名称的第一个命名范围。注意:命名范围的名称不是唯一的,因为它们是由工作表限定的。 getNames(String name) 返回具有给定名称的所有命名范围。)
public java.util.List<XSSFName> getNames(java.lang.String name)
public java.util.List<XSSFName> getAllNames()
getAllNames
in interface
Workbook
(接口 Workbook 中的 getAllNames)
public int getNumCellStyles()
getNumCellStyles
in interface
Workbook
(接口 Workbook 中的 getNumCellStyles)
public int getNumberOfFonts()
Workbook
getNumberOfFonts
in interface
Workbook
(接口 Workbook 中的 getNumberOfFonts)
@Deprecated @Removal(version="6.0.0") public int getNumberOfFontsAsInt()
Workbook
getNumberOfFontsAsInt
in interface
Workbook
(接口 Workbook 中的 getNumberOfFontsAsInt)
public int getNumberOfNames()
getNumberOfNames
in interface
Workbook
(接口 Workbook 中的 getNumberOfNames)
public int getNumberOfSheets()
getNumberOfSheets
in interface
Workbook
(接口 Workbook 中的 getNumberOfSheets)
public java.lang.String getPrintArea(int sheetIndex)
getPrintArea
in interface
Workbook
(接口 Workbook 中的 getPrintArea)
sheetIndex
- Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
(sheetIndex - 从零开始的工作表索引(0 表示与 java 保持一致的第一个工作表))
public XSSFSheet getSheet(java.lang.String name)
public XSSFSheet getSheetAt(int index)
getSheetAt
in interface
Workbook
(接口 Workbook 中的 getSheetAt)
index
- of the sheet number (0-based physical & logical)
(index - 工作表编号(基于 0 的物理和逻辑))
java.lang.IllegalArgumentException
- if the index is out of range (index < 0 || index >= getNumberOfSheets()).
(java.lang.IllegalArgumentException - 如果索引超出范围(索引 < 0 || 索引 >= getNumberOfSheets())。)
public int getSheetIndex(java.lang.String name)
getSheetIndex
in interface
Workbook
(接口 Workbook 中的 getSheetIndex)
name
- the sheet name
(name - 工作表名称)
public int getSheetIndex(Sheet sheet)
getSheetIndex
in interface
Workbook
(接口 Workbook 中的 getSheetIndex)
sheet
- the sheet to look up
(sheet - 要查找的工作表)
public java.lang.String getSheetName(int sheetIx)
getSheetName
in interface
Workbook
(接口 Workbook 中的 getSheetName)
sheetIx
- Number
(sheetIx - 编号)
public java.util.Iterator<Sheet> sheetIterator()
removeSheetAt(int)
to remove sheets instead.
(按工作表顺序返回工作簿中工作表的迭代器。包括隐藏和非常隐藏的工作表。注意:此迭代器不支持 remove()。改为使用 removeSheetAt(int) 删除工作表。)
sheetIterator
in interface
Workbook
(接口 Workbook 中的 sheetIterator)
public 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.
(允许 foreach 循环的 sheetIterator() 的别名 注意:此迭代器不支持 remove()。改为使用 removeSheetAt(int) 删除工作表。)
iterator
in interface
java.lang.Iterable<Sheet>
(接口 java.lang.Iterable 中的迭代器
public boolean isMacroEnabled()
public void removeName(Name name)
Workbook
removeName
in interface
Workbook
(界面 Workbook 中的 removeName)
name
- the name to remove.
(name - 要删除的名称。)
java.lang.IllegalArgumentException
- if the named range is not a part of this XSSFWorkbook
(java.lang.IllegalArgumentException - 如果命名范围不是此 XSSFWorkbook 的一部分)
public void removePrintArea(int sheetIndex)
removePrintArea
in interface
Workbook
(界面 Workbook 中的 removePrintArea)
sheetIndex
- 0-based sheet index (0 = First Sheet)
(sheetIndex - 基于 0 的工作表索引(0 = 第一个工作表))
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
Workbook
(界面 Workbook 中的 removeSheetAt)
index
- of the sheet (0-based)
(工作表的索引(从 0 开始))
public Row.MissingCellPolicy getMissingCellPolicy()
Row.MissingCellPolicy
(检索有关在一行中缺少单元格或空白单元格时要执行的操作的当前策略。默认是返回空白和空单元格。 Row.MissingCellPolicy)
getMissingCellPolicy
in interface
Workbook
(工作簿界面中的 getMissingCellPolicy)
public void setMissingCellPolicy(Row.MissingCellPolicy missingCellPolicy)
Row.getCell(int)
}. See
Row.MissingCellPolicy
(设置有关在一行中缺少单元格或空白单元格时要执行的操作的策略。然后这将适用于对 Row.getCell(int)} 的所有调用。请参见 Row.MissingCellPolicy)
setMissingCellPolicy
in interface
Workbook
(接口 Workbook 中的 setMissingCellPolicy)
public void setActiveSheet(int index)
setActiveSheet
in interface
Workbook
(接口 Workbook 中的 setActiveSheet)
index
- index of the active sheet (0-based)
(index - 活动工作表的索引(从 0 开始))
public int getFirstVisibleTab()
getFirstVisibleTab
in interface
Workbook
(接口 Workbook 中的 getFirstVisibleTab)
public void setFirstVisibleTab(int index)
setFirstVisibleTab
in interface
Workbook
(界面 Workbook 中的 setFirstVisibleTab)
index
- integer that contains the index to the active sheet in this book view.
(index - 整数,包含此书视图中活动工作表的索引。)
public void setPrintArea(int sheetIndex, java.lang.String reference)
i.e. Reference = $A$1:$B$2
(设置提供的工作表的打印区域,即参考 = $A$1:$B$2)setPrintArea
in interface
Workbook
(界面 Workbook 中的 setPrintArea)
sheetIndex
- Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
(sheetIndex - 从零开始的工作表索引(0 表示与 java 保持一致的第一个工作表))
reference
- Valid name Reference for the Print Area
(参考 - 打印区域的有效名称参考)
public void setPrintArea(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow)
setPrintArea
in interface
Workbook
(界面 Workbook 中的 setPrintArea)
sheetIndex
- Zero-based sheet index (0 = First Sheet)
(sheetIndex - 从零开始的工作表索引(0 = 第一个工作表))
startColumn
- Column to begin printarea
(startColumn - 列开始 printarea)
endColumn
- Column to end the printarea
(endColumn - 结束打印区域的列)
startRow
- Row to begin the printarea
(startRow - 开始打印区域的行)
endRow
- Row to end the printarea
(endRow - 结束打印区域的行)
setPrintArea(int, String)
public void setSelectedTab(int index)
setSelectedTab
in interface
Workbook
(界面 Workbook 中的 setSelectedTab)
index
- the index of the sheet to select (0 based)
(index - 要选择的工作表的索引(基于 0))
Sheet.setSelected(boolean)
public void setSheetName(int sheetIndex, java.lang.String sheetname)
setSheetName
in interface
Workbook
(工作簿界面中的 setSheetName)
sheetIndex
- sheet number (0 based)
(sheetIndex - 工作表编号(从 0 开始))
sheetname
- the new sheet name
(sheetname - 新的工作表名称)
java.lang.IllegalArgumentException
- if the name is null or invalid or workbook already contains a sheet with this name
(java.lang.IllegalArgumentException - 如果名称为 null 或无效,或者工作簿已包含具有此名称的工作表)
createSheet(String)
,
WorkbookUtil.createSafeSheetName(String nameProposal)
public void setSheetOrder(java.lang.String sheetname, int pos)
setSheetOrder
in interface
Workbook
(工作簿界面中的 setSheetOrder)
sheetname
- the name of the sheet to reorder
(sheetname - 要重新排序的工作表的名称)
pos
- the position that we want to insert the sheet into (0 based)
(pos - 我们要将工作表插入的位置(基于 0))
protected void commit() throws java.io.IOException
POIXMLDocumentPart
Sub-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(); OutputStream out = part.getOutputStream(); XmlObject bean = getXmlBean(); //the "model" which holds changes in memory bean.save(out, DEFAULT_XML_OPTIONS); out.close(); }(将内容保存在底层包部分中。默认实现是空的,这意味着包部分保持不变。子类应覆盖并添加逻辑以将“模型”编组到 Ooxml4J。例如,保存通用 XML 条目的代码可能如下所示: protected void commit() throws IOException { PackagePart part = getPackagePart();输出流输出 = part.getOutputStream(); XmlObject bean = getXmlBean(); //保存内存变化的“模型” bean.save(out, DEFAULT_XML_OPTIONS); out.close(); })
commit
in class
POIXMLDocumentPart
java.io.IOException
- a subclass may throw an IOException if the changes can't be committed
(java.io.IOException - 如果无法提交更改,子类可能会抛出 IOException)
@Internal public SharedStringsTable getSharedStringSource()
public StylesTable getStylesSource()
public ThemesTable getTheme()
public XSSFCreationHelper getCreationHelper()
getCreationHelper
in interface
Workbook
(接口 Workbook 中的 getCreationHelper)
@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..
(获取一个布尔值,指示工作簿中使用的日期系统是否从 1904 年开始。默认值为 false,表示工作簿使用 1900 年日期系统,其中 1/1/1900 是系统中的第一天。)isDate1904
in interface
Date1904Support
(isDate1904 在接口 Date1904Support)
public java.util.List<PackagePart> getAllEmbeddedParts() throws OpenXML4JException
getAllEmbeddedParts
in class
POIXMLDocument
(类 POIXMLDocument 中的 getAllEmbeddedParts)
OpenXML4JException
- if the embedded parts can't be determined
(OpenXML4JException - 如果无法确定嵌入的部分)
@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
Workbook
(isSheetHidden 在界面工作簿中)
sheetIx
- Number
(sheetIx - 编号)
true
if sheet is hidden
(如果工作表被隐藏,则为真)
Workbook.getSheetVisibility(int)
public boolean isSheetVeryHidden(int sheetIx)
Workbook
This is different from the normal hidden status (Workbook.isSheetHidden(int)
)
isSheetVeryHidden
in interface
Workbook
(isSheetVeryHidden 在界面工作簿中)
sheetIx
- sheet index to check
(sheetIx - 要检查的工作表索引)
true
if sheet is very hidden
(如果工作表非常隐藏,则为 true)
Workbook.getSheetVisibility(int)
public SheetVisibility getSheetVisibility(int sheetIx)
Workbook
getSheetVisibility
in interface
Workbook
(接口 Workbook 中的 getSheetVisibility)
sheetIx
- the index of the sheet
(sheetIx - 工作表的索引)
public void setSheetHidden(int sheetIx, boolean hidden)
Workbook
setSheetHidden
in interface
Workbook
(界面 Workbook 中的 setSheetHidden)
sheetIx
- the sheet index (0-based)
(sheetIx - 工作表索引(从 0 开始))
hidden
- True to mark the sheet as hidden, false otherwise
(hidden - True 将工作表标记为隐藏,否则为 false)
Workbook.setSheetVisibility(int, SheetVisibility)
public void setSheetVisibility(int sheetIx, SheetVisibility visibility)
Workbook
setSheetVisibility
in interface
Workbook
(界面 Workbook 中的 setSheetVisibility)
sheetIx
- the sheet index (0-based)
(sheetIx - 工作表索引(从 0 开始))
visibility
- the sheet visibility to set
(visibility - 要设置的工作表可见性)
protected 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 对象 计算链对象指定上次计算工作簿中单元格的顺序)CalculationChain
object or
null
if not defined
(CalculationChain 对象或 null 如果未定义)
@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 对象列表 外部链接表指定从其他工作簿引用的命名范围等的详细信息,以及它们指向的最后看到的值。请注意,Excel 对当前工作簿使用索引 0,因此公式中的第一个外部链接将是“[1]Foo”,它对应于此列表中的条目 0。)ExternalLinksTable
list, which may be empty
(ExternalLinksTable 列表,可能为空)
public java.util.Collection<XSSFMap> getCustomXMLMappings()
@Internal public MapInfo getMapInfo()
@NotImplemented public int linkExternalWorkbook(java.lang.String name, Workbook workbook)
linkExternalWorkbook
in interface
Workbook
(接口工作簿中的链接外部工作簿)
name
- The name the workbook will be referenced as in formulas
(name - 将在公式中引用工作簿的名称)
workbook
- The open workbook to fetch the link required information from
(工作簿 - 用于从中获取链接所需信息的打开工作簿)
java.lang.RuntimeException
- stating that this method is not implemented yet.
(java.lang.RuntimeException - 说明此方法尚未实现。)
public 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 removed
(密码 - 如果为空,密码将被删除)
hashAlgo
- 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)
(hashAlgo - 如果为空,密码将设置为 XOR 密码(Excel 2010 及更早版本),否则使用给定算法计算哈希密码(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 removed
(密码 - 如果为空,密码将被删除)
hashAlgo
- 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)
(hashAlgo - 如果为空,密码将设置为 XOR 密码(Excel 2010 及更早版本),否则使用给定算法计算哈希密码(Excel 2013))
public boolean validateRevisionsPassword(java.lang.String password)
public void unLock()
public void addToolPack(UDFFinder toopack)
addToolPack
in interface
Workbook
(界面 Workbook 中的 addToolPack)
toopack
- the toolpack to register
(Toopack - 要注册的工具包)
public 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.
(打开工作簿时应用程序是否应执行完全重新计算。通常,当您修改以前由 Excel 创建的工作簿的单元格公式或值时,您希望强制重新计算公式。设置为 true 时,此标志将告诉 Excel 在下次打开文件时需要重新计算工作簿中的所有公式。请注意,重新计算会更新缓存的公式结果,因此会修改工作簿。根据版本,Excel 可能会提示您“是否要保存文件名中的更改?”关闭。)setForceFormulaRecalculation
in interface
Workbook
(接口 Workbook 中的 setForceFormulaRecalculation)
value
- true if the application will perform a full recalculation of workbook values when the workbook is opened
(value - 如果应用程序将在打开工作簿时完全重新计算工作簿值,则为 true)
public boolean getForceFormulaRecalculation()
getForceFormulaRecalculation
in interface
Workbook
(接口 Workbook 中的 getForceFormulaRecalculation)
@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.
(java.io.IOException - 如果从流中复制数据失败。)
public void setVBAProject(XSSFWorkbook macroWorkbook) throws java.io.IOException, InvalidFormatException
java.io.IOException
- If copying the VBAProject stream fails.
(java.io.IOException - 如果复制 VBAProject 流失败。)
InvalidFormatException
- If an error occurs while handling parts of the XSSF format
(InvalidFormatException - 如果在处理部分 XSSF 格式时发生错误)
public SpreadsheetVersion getSpreadsheetVersion()
getSpreadsheetVersion
in interface
Workbook
(接口 Workbook 中的 getSpreadsheetVersion)
public XSSFTable getTable(java.lang.String name)
name
- the data table name (case-insensitive)
(name - 数据表名称(不区分大小写))
public int addOlePackage(byte[] oleData, java.lang.String label, java.lang.String fileName, java.lang.String command) throws java.io.IOException
Workbook
addOlePackage
in interface
Workbook
(接口 Workbook 中的 addOlePackage)
oleData
- the payload
(oleData - 有效载荷)
label
- the label of the payload
(label - 有效负载的标签)
fileName
- the original filename
(fileName - 原始文件名)
command
- the command to open the payload
(command - 打开有效载荷的命令)
java.io.IOException
- if the object can't be embedded
(java.io.IOException - 如果无法嵌入对象)
public void setCellFormulaValidation(boolean value)
CellBase.setCellFormula(String)
will validate the formula or not.
(对 CellBase.setCellFormula(String) 的调用是否会验证公式。)
value
- true if the application will validate the formula is correct
(value - 如果应用程序将验证公式是否正确,则为 true)
public boolean getCellFormulaValidation()
CellBase.setCellFormula(String)
will validate the formula or not.
(对 CellBase.setCellFormula(String) 的调用是否会验证公式。)
public XSSFEvaluationWorkbook createEvaluationWorkbook()
createEvaluationWorkbook
in interface
Workbook
(接口 Workbook 中的 createEvaluationWorkbook)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.