public final class HSSFWorkbook extends POIDocument implements Workbook
InternalWorkbook
,
HSSFSheet
Modifier and Type | Field and Description |
---|---|
protected java.util.List<HSSFSheet> |
_sheets
this holds the HSSFSheet objects attached to this workbook
(这包含附加到此工作簿的 HSSFSheet 对象)
|
static int |
INITIAL_CAPACITY
used for compile-time performance/memory optimization.
(用于编译时性能/内存优化。)
|
PICTURE_TYPE_DIB, PICTURE_TYPE_EMF, PICTURE_TYPE_JPEG, PICTURE_TYPE_PICT, PICTURE_TYPE_PNG, PICTURE_TYPE_WMF
Constructor and Description |
---|
HSSFWorkbook()
Creates new HSSFWorkbook from scratch (start here!)
|
HSSFWorkbook(DirectoryNode directory, boolean preserveNodes)
given a POI POIFSFileSystem object, and a specific directory within it, read in its Workbook and populate the high and low level models.
|
HSSFWorkbook(DirectoryNode directory, POIFSFileSystem fs, boolean preserveNodes)
given a POI POIFSFileSystem object, and a specific directory within it, read in its Workbook and populate the high and low level models.
|
HSSFWorkbook(java.io.InputStream s)
Companion to HSSFWorkbook(POIFSFileSystem), this constructs the POI filesystem around your
InputStream , including all nodes.
|
HSSFWorkbook(java.io.InputStream s, boolean preserveNodes)
Companion to HSSFWorkbook(POIFSFileSystem), this constructs the POI filesystem around your
InputStream .
|
HSSFWorkbook(POIFSFileSystem fs)
Given a POI POIFSFileSystem object, read in its Workbook along with all related nodes, and populate the high and low level models.
|
HSSFWorkbook(POIFSFileSystem fs, boolean preserveNodes)
Given a POI POIFSFileSystem object, read in its Workbook and populate the high and low level models.
|
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 |
addOlePackage(POIFSFileSystem poiData, java.lang.String label, java.lang.String fileName, java.lang.String command)
Adds an OLE package manager object with the given POIFS to the sheet
(将具有给定 POIFS 的 OLE 包管理器对象添加到工作表)
|
int |
addPicture(byte[] pictureData, int format)
Adds a picture to the workbook.
(将图片添加到工作簿。)
|
void |
addToolPack(UDFFinder toopack)
Register a new toolpack in this workbook.
(在此工作簿中注册一个新的工具包。)
|
boolean |
changeExternalReference(java.lang.String oldUrl, java.lang.String newUrl)
Changes an external referenced file to another file.
(将外部参考文件更改为另一个文件。)
|
HSSFSheet |
cloneSheet(int sheetIndex)
create an HSSFSheet from an existing sheet in the HSSFWorkbook.
(从 HSSFWorkbook 中的现有工作表创建一个 HSSFSheet。)
|
void |
close()
Closes the underlying
POIFSFileSystem from which the Workbook was read, if any.
(关闭从中读取工作簿的基础 POIFSFileSystem(如果有)。)
|
static HSSFWorkbook |
create(InternalWorkbook book) |
HSSFCellStyle |
createCellStyle()
Create a new Cell style and add it to the workbook's style table.
(创建一个新的单元格样式并将其添加到工作簿的样式表中。)
|
HSSFDataFormat |
createDataFormat()
Returns the instance of HSSFDataFormat for this workbook.
(返回此工作簿的 HSSFDataFormat 实例。)
|
HSSFEvaluationWorkbook |
createEvaluationWorkbook() |
HSSFFont |
createFont()
create a new Font and add it to the workbook's font table
(创建一个新字体并将其添加到工作簿的字体表中)
|
HSSFName |
createName()
creates a new named range and add it to the model
(创建一个新的命名范围并将其添加到模型中)
|
HSSFSheet |
createSheet()
create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns the high level representation.
(为此 HSSFWorkbook 创建一个 HSSFSheet,将其添加到工作表并返回高级表示。)
|
HSSFSheet |
createSheet(java.lang.String sheetname)
Create a new sheet for this Workbook and return the high level representation.
(为此工作簿创建一个新工作表并返回高级表示。)
|
void |
dumpDrawingGroupRecords(boolean fat)
Spits out a list of all the drawing records in the workbook.
(吐出工作簿中所有绘图记录的列表。)
|
HSSFFont |
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()
gets the tab whose data is actually seen when the sheet is opened.
(获取打开工作表时实际看到其数据的选项卡。)
|
java.util.List<HSSFObjectData> |
getAllEmbeddedObjects()
Gets all embedded OLE2 objects from the Workbook.
(从工作簿中获取所有嵌入的 OLE2 对象。)
|
java.util.List<HSSFName> |
getAllNames()
Returns all defined names.
(返回所有定义的名称。)
|
java.util.List<HSSFPictureData> |
getAllPictures()
Gets all pictures from the Workbook.
(获取工作簿中的所有图片。)
|
boolean |
getBackupFlag()
determine whether the Excel GUI will backup the workbook when saving.
(确定 Excel GUI 是否在保存时备份工作簿。)
|
byte[] |
getBytes()
Method getBytes - get the bytes of just the HSSF portions of the XLS file.
(方法 getBytes - 仅获取 XLS 文件的 HSSF 部分的字节。)
|
HSSFCellStyle |
getCellStyleAt(int idx)
get the cell style object at the given index
(获取给定索引处的单元格样式对象)
|
HSSFCreationHelper |
getCreationHelper()
Returns an object that handles instantiating concrete classes of the various instances one needs for HSSF and XSSF.
(返回一个对象,该对象处理实例化 HSSF 和 XSSF 所需的各种实例的具体类。)
|
HSSFPalette |
getCustomPalette() |
EncryptionInfo |
getEncryptionInfo() |
int |
getFirstVisibleTab()
sets the first tab that is displayed in the list of tabs in excel.
(设置在 excel 选项卡列表中显示的第一个选项卡。)
|
HSSFFont |
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 重新计算所有公式。)
|
InternalWorkbook |
getInternalWorkbook() |
Row.MissingCellPolicy |
getMissingCellPolicy()
Retrieves the current policy on what to do when getting missing or blank cells from a row.
(检索有关在一行中缺少单元格或空白单元格时要执行的操作的当前策略。)
|
HSSFName |
getName(java.lang.String name) |
java.lang.String |
getNameName(int index)
gets the named range name
(获取命名范围名称)
|
NameRecord |
getNameRecord(int nameIndex) |
java.util.List<HSSFName> |
getNames(java.lang.String name)
Returns all defined names with the given name.
(返回具有给定名称的所有已定义名称。)
|
int |
getNumberOfFonts()
Get the number of fonts in the font table
(获取字体表中的字体数量)
|
int |
getNumberOfFontsAsInt()
Deprecated.
(已弃用。)
|
int |
getNumberOfNames() |
int |
getNumberOfSheets()
get the number of spreadsheets in the workbook (this will be three after serialization)
(获取工作簿中电子表格的数量(序列化后为三个))
|
int |
getNumCellStyles()
get the number of styles the workbook contains
(获取工作簿包含的样式数)
|
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.
(检索指定工作表的打印区域的引用,即使未指定工作表名称,也会将其附加到引用中。)
|
java.util.Collection<java.lang.Integer> |
getSelectedTabs()
Gets the selected sheets (if more than one, Excel calls these a [Group]).
(获取选定的工作表(如果有多个工作表,Excel 将这些工作表称为 [Group])。)
|
HSSFSheet |
getSheet(java.lang.String name)
Get sheet with the given name (case insensitive match)
(获取具有给定名称的工作表(不区分大小写匹配))
|
HSSFSheet |
getSheetAt(int index)
Get the HSSFSheet object at the given index.
(获取给定索引处的 HSSFSheet 对象。)
|
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
(按他的名字返回工作表的索引)
|
java.lang.String |
getSheetName(int sheetIndex)
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 (EXCLE97) of this workbook
(返回此工作簿的电子表格版本 (EXCLE97))
|
InternalWorkbook |
getWorkbook() |
static java.lang.String |
getWorkbookDirEntryName(DirectoryNode directory) |
void |
insertChartRecord()
Test only.
(仅测试。)
|
boolean |
isHidden() |
boolean |
isSheetHidden(int sheetIx)
Check whether a sheet is hidden.
(检查工作表是否隐藏。)
|
boolean |
isSheetVeryHidden(int sheetIx)
Check whether a sheet is very hidden.
(检查工作表是否非常隐藏。)
|
boolean |
isWriteProtected()
Is the workbook protected with a password (not encrypted)?
(工作簿是否受密码保护(未加密)?)
|
java.util.Iterator<Sheet> |
iterator()
Alias for
sheetIterator() to allow foreach loops
(sheetIterator() 的别名以允许 foreach 循环)
|
int |
linkExternalWorkbook(java.lang.String name, Workbook workbook)
Adds the LinkTable records required to allow formulas referencing the specified external workbook to be added to this one.
(添加允许将引用指定外部工作簿的公式添加到此工作簿所需的 LinkTable 记录。)
|
void |
removeName(Name name)
Remove a 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 |
setBackupFlag(boolean backupValue)
determine whether the Excel GUI will backup the workbook when saving.
(确定 Excel GUI 是否在保存时备份工作簿。)
|
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.
(设置有关在一行中缺少单元格或空白单元格时要执行的操作的策略。)
|
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 |
setSelectedTab(int index)
Selects a single sheet.
(选择单个工作表。)
|
void |
setSelectedTabs(java.util.Collection<java.lang.Integer> indexes)
Selects multiple sheets as a group.
(选择多个工作表作为一个组。)
|
void |
setSelectedTabs(int[] indexes)
Selects multiple sheets as a group.
(选择多个工作表作为一个组。)
|
void |
setSheetHidden(int sheetIx, boolean hidden)
Hide or unhide a sheet.
(隐藏或取消隐藏工作表。)
|
void |
setSheetName(int sheetIx, java.lang.String name)
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.
(隐藏或取消隐藏工作表。)
|
java.util.Iterator<Sheet> |
sheetIterator()
Returns an iterator of the sheets in the workbook in sheet order.
(按工作表顺序返回工作簿中工作表的迭代器。)
|
void |
unwriteProtectWorkbook()
removes the write protect flag
(删除写保护标志)
|
void |
write()
Write out this workbook to the currently open
File via the writeable
POIFSFileSystem it was opened as.
(通过打开它的可写 POIFSFileSystem 将此工作簿写入当前打开的文件。)
|
void |
write(java.io.File newFile)
Method write - write out this workbook to a new
File .
(方法写入 - 将此工作簿写入新文件。)
|
void |
write(java.io.OutputStream stream)
Method write - write out this workbook to an
OutputStream .
(方法 write - 将此工作簿写出到 OutputStream。)
|
void |
writeProtectWorkbook(java.lang.String password, java.lang.String username)
protect a workbook with a password (not encypted, just sets writeprotect flags and the password.
(使用密码保护工作簿(未加密,只需设置写保护标志和密码。)
|
clearDirectory, createInformationProperties, getDirectory, getDocumentSummaryInformation, getEncryptedPropertyStreamName, getPropertySet, getPropertySet, getSummaryInformation, initDirectory, readProperties, replaceDirectory, validateInPlaceWritePossible, writeProperties, writeProperties, writeProperties
public static final int INITIAL_CAPACITY
protected java.util.List<HSSFSheet> _sheets
public HSSFWorkbook()
public HSSFWorkbook(POIFSFileSystem fs) throws java.io.IOException
This calls HSSFWorkbook(POIFSFileSystem, boolean)
with preserve nodes set to true.
java.io.IOException
- if the stream cannot be read
(java.io.IOException - 如果无法读取流)
HSSFWorkbook(POIFSFileSystem, boolean)
,
POIFSFileSystem
public HSSFWorkbook(POIFSFileSystem fs, boolean preserveNodes) throws java.io.IOException
fs
- the POI filesystem that contains the Workbook stream.
(fs - 包含工作簿流的 POI 文件系统。)
preserveNodes
- whether to preserve other nodes, such as macros. This takes more memory, so only say yes if you need to. If set, will store all of the POIFSFileSystem in memory
(preserveNodes - 是否保留其他节点,例如宏。这需要更多的内存,所以只有在需要时才说是。如果设置,会将所有 POIFSFileSystem 存储在内存中)
java.io.IOException
- if the stream cannot be read
(java.io.IOException - 如果无法读取流)
POIFSFileSystem
public HSSFWorkbook(DirectoryNode directory, POIFSFileSystem fs, boolean preserveNodes) throws java.io.IOException
directory
- the POI filesystem directory to process from
(directory - 要处理的 POI 文件系统目录)
fs
- the POI filesystem that contains the Workbook stream.
(fs - 包含工作簿流的 POI 文件系统。)
preserveNodes
- whether to preserve other nodes, such as macros. This takes more memory, so only say yes if you need to. If set, will store all of the POIFSFileSystem in memory
(preserveNodes - 是否保留其他节点,例如宏。这需要更多的内存,所以只有在需要时才说是。如果设置,会将所有 POIFSFileSystem 存储在内存中)
java.io.IOException
- if the stream cannot be read
(java.io.IOException - 如果无法读取流)
POIFSFileSystem
public HSSFWorkbook(DirectoryNode directory, boolean preserveNodes) throws java.io.IOException
directory
- the POI filesystem directory to process from
(directory - 要处理的 POI 文件系统目录)
preserveNodes
- whether to preserve other nodes, such as macros. This takes more memory, so only say yes if you need to. If set, will store all of the POIFSFileSystem in memory
(preserveNodes - 是否保留其他节点,例如宏。这需要更多的内存,所以只有在需要时才说是。如果设置,会将所有 POIFSFileSystem 存储在内存中)
java.io.IOException
- if the stream cannot be read
(java.io.IOException - 如果无法读取流)
POIFSFileSystem
public HSSFWorkbook(java.io.InputStream s) throws java.io.IOException
InputStream
, including all nodes.
This calls HSSFWorkbook(InputStream, boolean)
with preserve nodes set to true.
java.io.IOException
- if the stream cannot be read
(java.io.IOException - 如果无法读取流)
HSSFWorkbook(InputStream, boolean)
,
HSSFWorkbook(POIFSFileSystem)
,
POIFSFileSystem
public HSSFWorkbook(java.io.InputStream s, boolean preserveNodes) throws java.io.IOException
InputStream
.
(与 HSSFWorkbook(POIFSFileSystem) 配套,它围绕您的 InputStream 构建 POI 文件系统。)
s
- the POI filesystem that contains the Workbook stream.
(s - 包含工作簿流的 POI 文件系统。)
preserveNodes
- whether to preserve other nodes, such as macros. This takes more memory, so only say yes if you need to.
(preserveNodes - 是否保留其他节点,例如宏。这需要更多的内存,所以只有在需要时才说是。)
java.io.IOException
- if the stream cannot be read
(java.io.IOException - 如果无法读取流)
POIFSFileSystem
,
HSSFWorkbook(POIFSFileSystem)
public static HSSFWorkbook create(InternalWorkbook book)
public static java.lang.String getWorkbookDirEntryName(DirectoryNode directory)
public Row.MissingCellPolicy getMissingCellPolicy()
Row.MissingCellPolicy
(检索有关在一行中缺少单元格或空白单元格时要执行的操作的当前策略。默认是返回空白和空单元格。 Row.MissingCellPolicy)
getMissingCellPolicy
in interface
Workbook
(工作簿界面中的 getMissingCellPolicy)
public void setMissingCellPolicy(Row.MissingCellPolicy missingCellPolicy)
HSSFRow.getCell(int)
}. See
Row.MissingCellPolicy
. Note that this has no effect on any iterators, only on when fetching Cells by their column index.
(设置有关在一行中缺少单元格或空白单元格时要执行的操作的策略。然后,这将适用于对 HSSFRow.getCell(int)} 的所有调用。请参阅 Row.MissingCellPolicy。请注意,这对任何迭代器都没有影响,仅在通过列索引获取单元格时才有效。)
setMissingCellPolicy
in interface
Workbook
(接口 Workbook 中的 setMissingCellPolicy)
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))
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 setSelectedTabs(int[] indexes)
indexes
.
(选择多个工作表作为一个组。这与“活动”工作表(具有焦点的工作表)不同。取消选择不在索引中的工作表。)
indexes
- Array of sheets to select, the index is 0-based.
(index - 要选择的工作表数组,索引从 0 开始。)
public void setSelectedTabs(java.util.Collection<java.lang.Integer> indexes)
indexes
.
(选择多个工作表作为一个组。这与“活动”工作表(具有焦点的工作表)不同。取消选择不在索引中的工作表。)
indexes
- Collection of sheets to select, the index is 0-based.
(索引 - 要选择的工作表集合,索引从 0 开始。)
public java.util.Collection<java.lang.Integer> getSelectedTabs()
public void setActiveSheet(int index)
setActiveSheet
in interface
Workbook
(接口 Workbook 中的 setActiveSheet)
index
- index of the active sheet (0-based)
(index - 活动工作表的索引(从 0 开始))
public int getActiveSheetIndex()
getActiveSheetIndex
in interface
Workbook
(接口 Workbook 中的 getActiveSheetIndex)
HSSFSheet.setSelected(boolean)
public void setFirstVisibleTab(int index)
setFirstVisibleTab
in interface
Workbook
(界面 Workbook 中的 setFirstVisibleTab)
index
- the sheet index of the tab that will become the first in the tab-bar
(index - 将成为选项卡栏中的第一个选项卡的工作表索引)
public int getFirstVisibleTab()
getFirstVisibleTab
in interface
Workbook
(接口 Workbook 中的 getFirstVisibleTab)
public void setSheetName(int sheetIx, java.lang.String name)
setSheetName
in interface
Workbook
(工作簿界面中的 setSheetName)
sheetIx
- number (0 based)
(sheetIx - 数字(基于 0))
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 java.lang.String getSheetName(int sheetIndex)
Workbook
getSheetName
in interface
Workbook
(接口 Workbook 中的 getSheetName)
sheetIndex
- sheet number (0 based)
(sheetIndex - 工作表编号(从 0 开始))
public boolean isHidden()
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 - 要设置的工作表可见性)
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 HSSFSheet createSheet()
createSheet
in interface
Workbook
(界面 Workbook 中的 createSheet)
public HSSFSheet cloneSheet(int sheetIndex)
cloneSheet
in interface
Workbook
(界面 Workbook 中的 cloneSheet)
public HSSFSheet 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:
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)
public java.util.Iterator<Sheet> sheetIterator()
sheetIterator
in interface
Workbook
(接口 Workbook 中的 sheetIterator)
public java.util.Iterator<Sheet> iterator()
sheetIterator()
to allow foreach loops
(sheetIterator() 的别名以允许 foreach 循环)
iterator
in interface
java.lang.Iterable<Sheet>
(接口 java.lang.Iterable 中的迭代器
public int getNumberOfSheets()
getNumberOfSheets
in interface
Workbook
(接口 Workbook 中的 getNumberOfSheets)
public HSSFSheet 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 HSSFSheet getSheet(java.lang.String name)
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.
(删除给定索引处的工作表。如果删除的工作表是当前活动的工作表或工作簿中唯一选定的工作表,则必须小心。在某些情况下,Excel 必须具有选择和/或活动工作表。 (例如在打印时 - 请参阅错误 40414)。此方法确保如果删除的工作表处于活动状态,则另一个工作表将在其位置变为活动状态。此外,如果删除的工作表是唯一选定的工作表,则另一个工作表将被选中。新激活/选定的工作表将具有相同的索引,如果删除的工作表是工作簿中的最后一个工作表,则索引会少一个。)removeSheetAt
in interface
Workbook
(界面 Workbook 中的 removeSheetAt)
index
- of the sheet (0-based)
(工作表的索引(从 0 开始))
public void setBackupFlag(boolean backupValue)
backupValue
- true to indicate a backup will be performed.
(backupValue - true 表示将执行备份。)
public boolean getBackupFlag()
public HSSFFont createFont()
createFont
in interface
Workbook
(界面 Workbook 中的 createFont)
public HSSFFont findFont(boolean bold, short color, short fontHeight, java.lang.String name, boolean italic, boolean strikeout, short typeOffset, byte underline)
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 HSSFFont getFontAt(int idx)
Workbook
public HSSFCellStyle createCellStyle()
createCellStyle
in interface
Workbook
(界面 Workbook 中的 createCellStyle)
java.lang.IllegalStateException
- if the number of cell styles exceeded the limit for this type of Workbook.
(java.lang.IllegalStateException - 如果单元格样式的数量超过了此类工作簿的限制。)
public int getNumCellStyles()
getNumCellStyles
in interface
Workbook
(接口 Workbook 中的 getNumCellStyles)
public HSSFCellStyle getCellStyleAt(int idx)
getCellStyleAt
in interface
Workbook
(接口 Workbook 中的 getCellStyleAt)
idx
- index within the set of styles
(idx - 样式集中的索引)
public void close() throws java.io.IOException
POIFSFileSystem
from which the Workbook was read, if any.
Once this has been called, no further operations, updates or reads should be performed on the Workbook.
(关闭从中读取工作簿的基础 POIFSFileSystem(如果有)。一旦调用了它,就不应在工作簿上执行进一步的操作、更新或读取。)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
POIDocument
java.io.IOException
(java.io.IOException)
public void write() throws java.io.IOException
File
via the writeable
POIFSFileSystem
it was opened as.
This will fail (with an IllegalStateException
if the Workbook was opened read-only, opened from an InputStream
instead of a File, or if this is not the root document. For those cases, you must use write(OutputStream)
or write(File)
to write to a brand new document.
write
in class
POIDocument
(写在类 POIDocument)
java.io.IOException
- thrown on errors writing to the file
(java.io.IOException - 写入文件出错时抛出)
public void write(java.io.File newFile) throws java.io.IOException
File
. Constructs a new POI POIFSFileSystem, passes in the workbook binary representation and writes it out. If the file exists, it will be replaced, otherwise a new one will be created.
Note that you cannot write to the currently open File using this method. If you opened your Workbook from a File, you must use the write()
method instead!
write
in class
POIDocument
(写在类 POIDocument)
newFile
- The new File you wish to write the XLS to
(newFile - 您希望将 XLS 写入的新文件)
java.io.IOException
- if anything can't be written.
(java.io.IOException - 如果无法写入任何内容。)
POIFSFileSystem
public void write(java.io.OutputStream stream) throws java.io.IOException
OutputStream
. Constructs a new POI POIFSFileSystem, passes in the workbook binary representation and writes it out.
If stream
is a FileOutputStream
on a networked drive or has a high cost/latency associated with each written byte, consider wrapping the OutputStream in a BufferedOutputStream
to improve write performance.
write
in interface
Workbook
(写在界面工作簿中)
write
in class
POIDocument
(写在类 POIDocument)
stream
- - the java OutputStream you wish to write the XLS to
(流 - - 您希望将 XLS 写入的 java OutputStream)
java.io.IOException
- if anything can't be written.
(java.io.IOException - 如果无法写入任何内容。)
POIFSFileSystem
public byte[] getBytes()
@Internal public InternalWorkbook getWorkbook()
public int getNumberOfNames()
getNumberOfNames
in interface
Workbook
(接口 Workbook 中的 getNumberOfNames)
public HSSFName getName(java.lang.String name)
public java.util.List<HSSFName> getNames(java.lang.String name)
Workbook
public java.util.List<HSSFName> getAllNames()
Workbook
getAllNames
in interface
Workbook
(接口 Workbook 中的 getAllNames)
public NameRecord getNameRecord(int nameIndex)
public java.lang.String getNameName(int index)
index
- the named range index (0 based)
(index - 命名范围索引(基于 0))
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 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 void removePrintArea(int sheetIndex)
removePrintArea
in interface
Workbook
(界面 Workbook 中的 removePrintArea)
sheetIndex
- Zero-based sheet index (0 = First Sheet)
(sheetIndex - 从零开始的工作表索引(0 = 第一个工作表))
public HSSFName createName()
createName
in interface
Workbook
(界面 Workbook 中的 createName)
public HSSFDataFormat createDataFormat()
createDataFormat
in interface
Workbook
(接口 Workbook 中的 createDataFormat)
FormatRecord
,
Record
public void removeName(Name name)
removeName
in interface
Workbook
(界面 Workbook 中的 removeName)
name
- the name to remove.
(name - 要删除的名称。)
public HSSFPalette getCustomPalette()
public void insertChartRecord()
public void dumpDrawingGroupRecords(boolean fat)
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. One of
PICTURE_TYPE_*
(format - 图片的格式。 PICTURE_TYPE_* 之一)
Workbook.PICTURE_TYPE_WMF
,
Workbook.PICTURE_TYPE_EMF
,
Workbook.PICTURE_TYPE_PICT
,
Workbook.PICTURE_TYPE_PNG
,
Workbook.PICTURE_TYPE_JPEG
,
Workbook.PICTURE_TYPE_DIB
public java.util.List<HSSFPictureData> getAllPictures()
getAllPictures
in interface
Workbook
(接口 Workbook 中的 getAllPictures)
HSSFPictureData
objects.)
(图片列表(HSSFPitureData 对象的列表。))
public int addOlePackage(POIFSFileSystem poiData, java.lang.String label, java.lang.String fileName, java.lang.String command) throws java.io.IOException
poiData
- an POIFS containing the embedded document, to be added
(poiData - 包含要添加的嵌入文档的 POIFS)
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 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 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
(工作簿 - 用于从中获取链接所需信息的打开工作簿)
public boolean isWriteProtected()
public void writeProtectWorkbook(java.lang.String password, java.lang.String username)
password
- to set
(密码 - 设置)
public void unwriteProtectWorkbook()
public java.util.List<HSSFObjectData> getAllEmbeddedObjects()
HSSFObjectData
objects.)
(嵌入对象列表(HSSFObjectData 对象列表。))
public HSSFCreationHelper getCreationHelper()
Workbook
getCreationHelper
in interface
Workbook
(接口 Workbook 中的 getCreationHelper)
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)
public boolean changeExternalReference(java.lang.String oldUrl, java.lang.String newUrl)
oldUrl
- The old URL to search for and which is to be replaced
(oldUrl - 要搜索和要替换的旧 URL)
newUrl
- The URL replacement
(newUrl - URL 替换)
@Internal public InternalWorkbook getInternalWorkbook()
public SpreadsheetVersion getSpreadsheetVersion()
getSpreadsheetVersion
in interface
Workbook
(接口 Workbook 中的 getSpreadsheetVersion)
public EncryptionInfo getEncryptionInfo()
getEncryptionInfo
in class
POIDocument
null
(如果文档已加密,则为加密信息,否则为 null)
public HSSFEvaluationWorkbook createEvaluationWorkbook()
createEvaluationWorkbook
in interface
Workbook
(接口 Workbook 中的 createEvaluationWorkbook)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.