public interface Sheet extends java.lang.Iterable<Row>
Sheets are the central structures within a workbook, and are where a user does most of his spreadsheet work. The most common type of sheet is the worksheet, which is represented as a grid of cells. Worksheet cells can contain text, numbers, dates, and formulas. Cells can also be formatted.
(Excel 工作表的高级表示。工作表是工作簿中的中心结构,是用户进行大部分电子表格工作的地方。最常见的工作表类型是工作表,它表示为单元格网格。工作表单元格可以包含文本、数字、日期和公式。单元格也可以被格式化。)Modifier and Type | Field and Description |
---|---|
static short |
BottomMargin |
static short |
FooterMargin |
static short |
HeaderMargin |
static short |
LeftMargin |
static byte |
PANE_LOWER_LEFT |
static byte |
PANE_LOWER_RIGHT |
static byte |
PANE_UPPER_LEFT |
static byte |
PANE_UPPER_RIGHT |
static short |
RightMargin |
static short |
TopMargin |
Modifier and Type | Method and Description |
---|---|
int |
addMergedRegion(CellRangeAddress region)
Adds a merged region of cells (hence those cells form one)
(添加单元格的合并区域(因此这些单元格形成一个))
|
int |
addMergedRegionUnsafe(CellRangeAddress region)
Adds a merged region of cells (hence those cells form one).
(添加单元格的合并区域(因此这些单元格形成一个)。)
|
void |
addValidationData(DataValidation dataValidation)
Creates a data validation object
(创建数据验证对象)
|
void |
autoSizeColumn(int column)
Adjusts the column width to fit the contents.
(调整列宽以适合内容。)
|
void |
autoSizeColumn(int column, boolean useMergedCells)
Adjusts the column width to fit the contents.
(调整列宽以适合内容。)
|
Drawing<?> |
createDrawingPatriarch()
Creates the top-level drawing patriarch.
(创建顶级图形族长。)
|
void |
createFreezePane(int colSplit, int rowSplit)
Creates a split (freezepane).
(创建一个拆分(冻结窗格)。)
|
void |
createFreezePane(int colSplit, int rowSplit, int leftmostColumn, int topRow)
Creates a split (freezepane).
(创建一个拆分(冻结窗格)。)
|
Row |
createRow(int rownum)
Create a new row within the sheet and return the high level representation
(在工作表中创建一个新行并返回高级表示)
|
void |
createSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane)
Creates a split pane.
(创建一个拆分窗格。)
|
CellAddress |
getActiveCell()
Return location of the active cell, e.g.
(返回活动小区的位置,例如)
|
boolean |
getAutobreaks()
Flag indicating whether the sheet displays Automatic Page Breaks.
(指示工作表是否显示自动分页符的标志。)
|
Comment |
getCellComment(CellAddress ref)
Returns cell comment for the specified location
(返回指定位置的单元格注释)
|
java.util.Map<CellAddress,? extends Comment> |
getCellComments()
Returns all cell comments on this sheet.
(返回此工作表上的所有单元格注释。)
|
int[] |
getColumnBreaks()
Retrieves all the vertical page breaks
(检索所有垂直分页符)
|
int |
getColumnOutlineLevel(int columnIndex)
Returns the column outline level.
(返回列大纲级别。)
|
CellStyle |
getColumnStyle(int column)
Returns the CellStyle that applies to the given (0 based) column, or null if no style has been set for that column
(返回应用于给定(基于 0)列的 CellStyle,如果没有为该列设置样式,则返回 null)
|
int |
getColumnWidth(int columnIndex)
get the width (in units of 1/256th of a character width )
(获取宽度(以字符宽度的 1/256 为单位))
|
float |
getColumnWidthInPixels(int columnIndex)
get the width in pixel
(获取像素宽度)
|
DataValidationHelper |
getDataValidationHelper() |
java.util.List<? extends DataValidation> |
getDataValidations()
Returns the list of DataValidation in the sheet.
(返回工作表中的 DataValidation 列表。)
|
int |
getDefaultColumnWidth()
Get the default column width for the sheet (if the columns do not define their own width) in characters
(以字符为单位获取工作表的默认列宽(如果列未定义自己的宽度))
|
short |
getDefaultRowHeight()
Get the default row height for the sheet (if the rows do not define their own height) in twips (1/20 of a point)
(获取工作表的默认行高(如果行没有定义自己的高度)以缇为单位(点的 1/20))
|
float |
getDefaultRowHeightInPoints()
Get the default row height for the sheet (if the rows do not define their own height) in points.
(获取工作表的默认行高(如果行没有定义自己的高度),以磅为单位。)
|
boolean |
getDisplayGuts()
Get whether to display the guts or not, default value is true
(获取是否显示胆量,默认值为true)
|
Drawing<?> |
getDrawingPatriarch()
Return the sheet's existing drawing, or null if there isn't yet one.
(返回工作表的现有绘图,如果还没有,则返回 null。)
|
int |
getFirstRowNum()
Gets the first row on the sheet.
(获取工作表上的第一行。)
|
boolean |
getFitToPage()
Flag indicating whether the Fit to Page print option is enabled.
(指示是否启用适合页面打印选项的标志。)
|
Footer |
getFooter()
Gets the user model for the default document footer.
(获取默认文档页脚的用户模型。)
|
boolean |
getForceFormulaRecalculation()
Whether Excel will be asked to recalculate all formulas in this sheet when the workbook is opened.
(打开工作簿时是否会要求 Excel 重新计算此工作表中的所有公式。)
|
Header |
getHeader()
Gets the user model for the default document header.
(获取默认文档标题的用户模型。)
|
boolean |
getHorizontallyCenter()
Determine whether printed output for this sheet will be horizontally centered.
(确定此工作表的打印输出是否水平居中。)
|
Hyperlink |
getHyperlink(CellAddress addr)
Get a Hyperlink in this sheet located in a cell specified by {code addr}
(在此工作表中获取位于 {code addr} 指定的单元格中的超链接)
|
Hyperlink |
getHyperlink(int row, int column)
Get a Hyperlink in this sheet anchored at row, column
(在此工作表中获取锚定在行、列的超链接)
|
java.util.List<? extends Hyperlink> |
getHyperlinkList()
Get a list of Hyperlinks in this sheet
(获取此工作表中的超链接列表)
|
int |
getLastRowNum()
Gets the last row on the sheet Note: rows which had content before and were set to empty later might still be counted as rows by Excel and Apache POI, so the result of this method will include such rows and thus the returned value might be higher than expected!
(获取工作表上的最后一行 注意:之前有内容并稍后设置为空的行可能仍被 Excel 和 Apache POI 计为行,因此此方法的结果将包含此类行,因此返回值可能更高超出预期!)
|
short |
getLeftCol()
The left col in the visible view when the sheet is first viewed after opening it in a viewer
(在查看器中打开工作表后首次查看工作表时可见视图中的左列)
|
double |
getMargin(short margin)
Gets the size of the margin in inches.
(以英寸为单位获取边距的大小。)
|
CellRangeAddress |
getMergedRegion(int index)
Returns the merged region at the specified index
(返回指定索引处的合并区域)
|
java.util.List<CellRangeAddress> |
getMergedRegions()
Returns the list of merged regions.
(返回合并区域的列表。)
|
int |
getNumMergedRegions()
Returns the number of merged regions
(返回合并区域的数量)
|
PaneInformation |
getPaneInformation()
Returns the information regarding the currently configured pane (split or freeze)
(返回有关当前配置的窗格的信息(拆分或冻结))
|
int |
getPhysicalNumberOfRows()
Returns the number of physically defined rows (NOT the number of rows in the sheet)
(返回物理定义的行数(不是工作表中的行数))
|
PrintSetup |
getPrintSetup()
Gets the print setup object.
(获取打印设置对象。)
|
boolean |
getProtect()
Answer whether protection is enabled or disabled
(回答保护是启用还是禁用)
|
CellRangeAddress |
getRepeatingColumns()
Gets the repeating columns used when printing the sheet, as found in File->PageSetup->Sheet.
(获取打印工作表时使用的重复列,如 File->PageSetup->Sheet 中所示。)
|
CellRangeAddress |
getRepeatingRows()
Gets the repeating rows used when printing the sheet, as found in File->PageSetup->Sheet.
(获取打印工作表时使用的重复行,如 File->PageSetup->Sheet 中所示。)
|
Row |
getRow(int rownum)
Returns the logical row (not physical) 0-based.
(返回基于 0 的逻辑行(非物理行)。)
|
int[] |
getRowBreaks()
Retrieves all the horizontal page breaks
(检索所有水平分页符)
|
boolean |
getRowSumsBelow()
Flag indicating whether summary rows appear below detail in an outline, when applying an outline.
(应用大纲时,指示摘要行是否出现在大纲中的详细信息下方的标志。)
|
boolean |
getRowSumsRight()
Flag indicating whether summary columns appear to the right of detail in an outline, when applying an outline.
(应用大纲时,指示摘要列是否显示在大纲中详细信息右侧的标志。)
|
boolean |
getScenarioProtect()
Answer whether scenario protection is enabled or disabled
(回答是否启用或禁用场景保护)
|
SheetConditionalFormatting |
getSheetConditionalFormatting()
The 'Conditional Formatting' facet for this
Sheet
(此工作表的“条件格式”方面)
|
java.lang.String |
getSheetName()
Returns the name of this sheet
(返回此工作表的名称)
|
short |
getTopRow()
The top row in the visible view when the sheet is first viewed after opening it in a viewer
(在查看器中打开工作表后首次查看工作表时可见视图中的顶行)
|
boolean |
getVerticallyCenter()
Determine whether printed output for this sheet will be vertically centered.
(确定此工作表的打印输出是否垂直居中。)
|
Workbook |
getWorkbook()
Return the parent workbook
(返回父工作簿)
|
void |
groupColumn(int fromColumn, int toColumn)
Create an outline for the provided column range.
(为提供的列范围创建大纲。)
|
void |
groupRow(int fromRow, int toRow)
Tie a range of rows together so that they can be collapsed or expanded
(将一系列行捆绑在一起,以便它们可以折叠或展开)
|
boolean |
isColumnBroken(int column)
Determines if there is a page break at the indicated column
(确定指示的列是否有分页符)
|
boolean |
isColumnHidden(int columnIndex)
Get the hidden state for a given column
(获取给定列的隐藏状态)
|
boolean |
isDisplayFormulas()
Returns if formulas are displayed
(返回是否显示公式)
|
boolean |
isDisplayGridlines()
Returns if gridlines are displayed
(返回是否显示网格线)
|
boolean |
isDisplayRowColHeadings()
Returns if RowColHeadings are displayed.
(如果显示 RowColHeadings,则返回。)
|
boolean |
isDisplayZeros()
Gets the flag indicating whether the window should show 0 (zero) in cells containing zero value.
(获取指示窗口是否应在包含零值的单元格中显示 0(零)的标志。)
|
boolean |
isPrintGridlines()
Gets the flag indicating whether this sheet displays the lines between rows and columns to make editing and reading easier.
(获取指示此工作表是否显示行和列之间的线条以使编辑和阅读更容易的标志。)
|
boolean |
isPrintRowAndColumnHeadings()
Gets the flag indicating whether this sheet prints the row and column headings when printing.
(获取指示此工作表在打印时是否打印行标题和列标题的标志。)
|
boolean |
isRightToLeft()
Whether the text is displayed in right-to-left mode in the window
(文本是否在窗口中以从右到左的方式显示)
|
boolean |
isRowBroken(int row)
Determines if there is a page break at the indicated row
(确定指示行是否有分页符)
|
boolean |
isSelected()
Note - this is not the same as whether the sheet is focused (isActive)
(注意 - 这与工作表是否聚焦(isActive)不同)
|
void |
protectSheet(java.lang.String password)
Sets the protection enabled as well as the password
(设置启用的保护以及密码)
|
CellRange<? extends Cell> |
removeArrayFormula(Cell cell)
Remove a Array Formula from this sheet.
(从此工作表中删除一个数组公式。)
|
void |
removeColumnBreak(int column)
Removes a page break at the indicated column
(删除指定列的分页符)
|
void |
removeMergedRegion(int index)
Removes a merged region of cells (hence letting them free)
(删除合并的单元格区域(因此让它们自由))
|
void |
removeMergedRegions(java.util.Collection<java.lang.Integer> indices)
Removes a number of merged regions of cells (hence letting them free)
(删除许多合并的单元格区域(因此让它们自由))
|
void |
removeRow(Row row)
Remove a row from this sheet.
(从此工作表中删除一行。)
|
void |
removeRowBreak(int row)
Removes the page break at the indicated row
(删除指定行的分页符)
|
java.util.Iterator<Row> |
rowIterator()
Returns an iterator of the physical rows
(返回物理行的迭代器)
|
void |
setActiveCell(CellAddress address)
Sets location of the active cell
(设置活动单元格的位置)
|
CellRange<? extends Cell> |
setArrayFormula(java.lang.String formula, CellRangeAddress range)
Sets array formula to specified region for result.
(将数组公式设置为结果的指定区域。)
|
void |
setAutobreaks(boolean value)
Flag indicating whether the sheet displays Automatic Page Breaks.
(指示工作表是否显示自动分页符的标志。)
|
AutoFilter |
setAutoFilter(CellRangeAddress range)
Enable filtering for a range of cells
(为一系列单元格启用过滤)
|
void |
setColumnBreak(int column)
Sets a page break at the indicated column.
(在指示的列处设置分页符。)
|
void |
setColumnGroupCollapsed(int columnNumber, boolean collapsed)
Expands or collapses a column group.
(展开或折叠列组。)
|
void |
setColumnHidden(int columnIndex, boolean hidden)
Get the visibility state for a given column
(获取给定列的可见性状态)
|
void |
setColumnWidth(int columnIndex, int width)
Set the width (in units of 1/256th of a character width)
(设置宽度(以字符宽度的 1/256 为单位))
|
void |
setDefaultColumnStyle(int column, CellStyle style)
Sets the default column style for a given column.
(设置给定列的默认列样式。)
|
void |
setDefaultColumnWidth(int width)
Set the default column width for the sheet (if the columns do not define their own width) in characters
(以字符为单位设置工作表的默认列宽(如果列未定义自己的宽度))
|
void |
setDefaultRowHeight(short height)
Set the default row height for the sheet (if the rows do not define their own height) in twips (1/20 of a point)
(设置工作表的默认行高(如果行没有定义自己的高度)以缇为单位(1/20 点))
|
void |
setDefaultRowHeightInPoints(float height)
Set the default row height for the sheet (if the rows do not define their own height) in points
(以磅为单位设置工作表的默认行高(如果行没有定义自己的高度))
|
void |
setDisplayFormulas(boolean show)
Sets whether the formulas are shown in a viewer
(设置公式是否显示在查看器中)
|
void |
setDisplayGridlines(boolean show)
Sets whether the gridlines are shown in a viewer
(设置是否在查看器中显示网格线)
|
void |
setDisplayGuts(boolean value)
Set whether to display the guts or not
(设置是否显示胆量)
|
void |
setDisplayRowColHeadings(boolean show)
Sets whether the RowColHeadings are shown in a viewer
(设置 RowColHeadings 是否显示在查看器中)
|
void |
setDisplayZeros(boolean value)
Set whether the window should show 0 (zero) in cells containing zero value.
(设置窗口是否应在包含零值的单元格中显示 0(零)。)
|
void |
setFitToPage(boolean value)
Flag indicating whether the Fit to Page print option is enabled.
(指示是否启用适合页面打印选项的标志。)
|
void |
setForceFormulaRecalculation(boolean value)
Control if Excel should be asked to recalculate all formulas on this sheet when the workbook is opened.
(控制打开工作簿时是否应要求 Excel 重新计算此工作表上的所有公式。)
|
void |
setHorizontallyCenter(boolean value)
Determines whether the output is horizontally centered on the page.
(确定输出是否在页面上水平居中。)
|
void |
setMargin(short margin, double size)
Sets the size of the margin in inches.
(以英寸为单位设置边距的大小。)
|
void |
setPrintGridlines(boolean show)
Sets the flag indicating whether this sheet should print the lines between rows and columns to make editing and reading easier.
(设置标志,指示此工作表是否应打印行和列之间的行以使编辑和阅读更容易。)
|
void |
setPrintRowAndColumnHeadings(boolean show)
Sets the flag indicating whether this sheet should print row and columns headings when printing.
(设置标志,指示此工作表在打印时是否应打印行和列标题。)
|
void |
setRepeatingColumns(CellRangeAddress columnRangeRef)
Sets the repeating columns used when printing the sheet, as found in File->PageSetup->Sheet.
(设置打印工作表时使用的重复列,如 File->PageSetup->Sheet 中所示。)
|
void |
setRepeatingRows(CellRangeAddress rowRangeRef)
Sets the repeating rows used when printing the sheet, as found in File->PageSetup->Sheet.
(设置打印工作表时使用的重复行,如 File->PageSetup->Sheet 中所示。)
|
void |
setRightToLeft(boolean value)
Sets whether the worksheet is displayed from right to left instead of from left to right.
(设置工作表是否从右到左而不是从左到右显示。)
|
void |
setRowBreak(int row)
Sets a page break at the indicated row Breaks occur above the specified row and left of the specified column inclusive.
(在指示的行处设置分页符 分页符发生在指定行的上方和指定列的左侧(含)。)
|
void |
setRowGroupCollapsed(int row, boolean collapse)
Set view state of a grouped range of rows
(设置一组行的视图状态)
|
void |
setRowSumsBelow(boolean value)
Flag indicating whether summary rows appear below detail in an outline, when applying an outline.
(应用大纲时,指示摘要行是否出现在大纲中的详细信息下方的标志。)
|
void |
setRowSumsRight(boolean value)
Flag indicating whether summary columns appear to the right of detail in an outline, when applying an outline.
(应用大纲时,指示摘要列是否显示在大纲中详细信息右侧的标志。)
|
void |
setSelected(boolean value)
Sets a flag indicating whether this sheet is selected.
(设置一个标志,指示此工作表是否被选中。)
|
void |
setVerticallyCenter(boolean value)
Determines whether the output is vertically centered on the page.
(确定输出是否在页面上垂直居中。)
|
void |
setZoom(int scale)
Window zoom magnification for current view representing percent values.
(表示百分比值的当前视图的窗口缩放比例。)
|
void |
shiftColumns(int startColumn, int endColumn, int n)
Shifts columns between startColumn and endColumn, n number of columns.
(在 startColumn 和 endColumn 之间移动列,n 列。)
|
void |
shiftRows(int startRow, int endRow, int n)
Shifts rows between startRow and endRow n number of rows.
(在 startRow 和 endRow 之间移动行 n 行。)
|
void |
shiftRows(int startRow, int endRow, int n, boolean copyRowHeight, boolean resetOriginalRowHeight)
Shifts rows between startRow and endRow n number of rows.
(在 startRow 和 endRow 之间移动行 n 行。)
|
void |
showInPane(int topRow, int leftCol)
Sets desktop window pane display area, when the file is first opened in a viewer.
(当文件第一次在查看器中打开时,设置桌面窗口窗格的显示区域。)
|
void |
ungroupColumn(int fromColumn, int toColumn)
Ungroup a range of columns that were previously grouped
(取消组合之前分组的一系列列)
|
void |
ungroupRow(int fromRow, int toRow)
Ungroup a range of rows that were previously grouped
(取消组合之前分组的一系列行)
|
void |
validateMergedRegions()
Verify that merged regions do not intersect multi-cell array formulas and no merged regions intersect another merged region in this sheet.
(验证合并区域不会与多单元格数组公式相交,并且没有合并区域与此工作表中的另一个合并区域相交。)
|
static final short LeftMargin
static final short RightMargin
static final short TopMargin
static final short BottomMargin
static final short HeaderMargin
static final short FooterMargin
static final byte PANE_LOWER_RIGHT
static final byte PANE_UPPER_RIGHT
static final byte PANE_LOWER_LEFT
static final byte PANE_UPPER_LEFT
Row createRow(int rownum)
rownum
- row number
(rownum - 行号)
removeRow(Row)
void removeRow(Row row)
row
- representing a row to remove.
(row - 表示要删除的行。)
Row getRow(int rownum)
rownum
- row to get (0-based)
(rownum - 要获取的行(从 0 开始))
int getPhysicalNumberOfRows()
int getFirstRowNum()
int getLastRowNum()
void setColumnHidden(int columnIndex, boolean hidden)
columnIndex
- - the column to get (0-based)
(columnIndex - - 要获取的列(从 0 开始))
hidden
- - the visibility state of the column
(hidden - 列的可见性状态)
boolean isColumnHidden(int columnIndex)
columnIndex
- - the column to set (0-based)
(columnIndex - - 要设置的列(从 0 开始))
false
if the column is visible
(hidden - 如果该列可见,则为 false)
void setRightToLeft(boolean value)
value
- true for right to left, false otherwise.
(value - 从右到左为 true,否则为 false。)
boolean isRightToLeft()
void setColumnWidth(int columnIndex, int width)
The maximum column width for an individual cell is 255 characters. This value represents the number of characters that can be displayed in a cell that is formatted with the standard font (first font in the workbook).
Character width is defined as the maximum digit width of the numbers 0, 1, 2, ... 9
as rendered using the default font (first font in the workbook).
Unless you are using a very special font, the default character is '0' (zero), this is true for Arial (default font font in HSSF) and Calibri (default font in XSSF)
Please note, that the width set by this method includes 4 pixels of margin padding (two on each side), plus 1 pixel padding for the gridlines (Section 3.3.1.12 of the OOXML spec). This results is a slightly less value of visible characters than passed to this method (approx. 1/2 of a character).
To compute the actual number of visible characters, Excel uses the following formula (Section 3.3.1.12 of the OOXML spec):
width = Truncate([{Number of Visible Characters} * {Maximum Digit Width} + {5 pixel padding}]/{Maximum Digit Width}*256)/256
Using the Calibri font as an example, the maximum digit width of 11 point font size is 7 pixels (at 96 dpi). If you set a column width to be eight characters wide, e.g. setColumnWidth(columnIndex, 8*256)
, then the actual value of visible characters (the value shown in Excel) is derived from the following equation: Truncate([numChars*7+5]/7*256)/256 = 8;
which gives 7.29
.
columnIndex
- - the column to set (0-based)
(columnIndex - - 要设置的列(从 0 开始))
width
- - the width in units of 1/256th of a character width
(width - 以字符宽度的 1/256 为单位的宽度)
java.lang.IllegalArgumentException
- if width > 255*256 (the maximum column width in Excel is 255 characters)
(java.lang.IllegalArgumentException - 如果宽度 > 255*256(Excel 中的最大列宽为 255 个字符))
int getColumnWidth(int columnIndex)
Character width is defined as the maximum digit width of the numbers 0, 1, 2, ... 9
as rendered using the default font (first font in the workbook)
columnIndex
- - the column to get (0-based)
(columnIndex - - 要获取的列(从 0 开始))
float getColumnWidthInPixels(int columnIndex)
Please note, that this method works correctly only for workbooks with the default font size (Arial 10pt for .xls and Calibri 11pt for .xlsx). If the default font is changed the column width can be stretched
(以像素为单位获取宽度 请注意,此方法仅适用于具有默认字体大小的工作簿(.xls 为 Arial 10pt,.xlsx 为 Calibri 11pt)。如果更改默认字体,则可以拉伸列宽)columnIndex
- - the column to set (0-based)
(columnIndex - - 要设置的列(从 0 开始))
void setDefaultColumnWidth(int width)
width
- default column width measured in characters
(width - 以字符为单位的默认列宽)
int getDefaultColumnWidth()
short getDefaultRowHeight()
float getDefaultRowHeightInPoints()
void setDefaultRowHeight(short height)
height
- default row height measured in twips (1/20 of a point)
(height - 以缇为单位的默认行高(1/20 点))
void setDefaultRowHeightInPoints(float height)
height
- default row height
(height - 默认行高)
CellStyle getColumnStyle(int column)
int addMergedRegion(CellRangeAddress region)
region
- (rowfrom/colfrom-rowto/colto) to merge
(region - (rowfrom/colfrom-rowto/colto) 合并)
int addMergedRegionUnsafe(CellRangeAddress region)
validateMergedRegions()
, which runs in O(n^2) time.
(添加单元格的合并区域(因此这些单元格形成一个)。跳过验证。可以创建重叠的合并区域或创建与此公式相交的多单元格数组公式的合并区域,这可能会导致工作簿损坏。要在调用 addMergedRegionUnsafe 后检查合并区域是否与数组公式重叠或其他合并区域,请调用 validateMergedRegions(),它在 O(n^2) 时间内运行。)
region
- to merge
(区域 - 合并)
java.lang.IllegalArgumentException
- if region contains fewer than 2 cells
(java.lang.IllegalArgumentException - 如果区域包含少于 2 个单元格)
void validateMergedRegions()
java.lang.IllegalStateException
- if region intersects with a multi-cell array formula
(java.lang.IllegalStateException - 如果区域与多单元格数组公式相交)
java.lang.IllegalStateException
- if at least one region intersects with another merged region in this sheet
(java.lang.IllegalStateException - 如果至少一个区域与此工作表中的另一个合并区域相交)
void setVerticallyCenter(boolean value)
value
- true to vertically center, false otherwise.
(value - 垂直居中为真,否则为假。)
void setHorizontallyCenter(boolean value)
value
- true to horizontally center, false otherwise.
(value - 水平居中为真,否则为假。)
boolean getHorizontallyCenter()
boolean getVerticallyCenter()
void removeMergedRegion(int index)
index
- of the region to unmerge
(index - 要取消合并的区域)
void removeMergedRegions(java.util.Collection<java.lang.Integer> indices)
indices
- A set of the regions to unmerge
(索引 - 一组要取消合并的区域)
int getNumMergedRegions()
CellRangeAddress getMergedRegion(int index)
java.util.List<CellRangeAddress> getMergedRegions()
java.util.Iterator<Row> rowIterator()
void setForceFormulaRecalculation(boolean value)
Calculating the formula values with FormulaEvaluator
is the recommended solution, but this may be used for certain cases where evaluation in POI is not possible.
Workbook.setForceFormulaRecalculation(boolean)
instead.
(控制打开工作簿时是否应要求 Excel 重新计算此工作表上的所有公式。使用 FormulaEvaluator 计算公式值是推荐的解决方案,但这可能用于无法在 POI 中进行评估的某些情况。要强制重新计算整个工作簿中的公式,请改用 Workbook.setForceFormulaRecalculation(boolean)。)
value
- true if the application will perform a full recalculation of this worksheet values when the workbook is opened
(value - 如果应用程序将在打开工作簿时完全重新计算此工作表值,则为 true)
Workbook.setForceFormulaRecalculation(boolean)
boolean getForceFormulaRecalculation()
void setAutobreaks(boolean value)
value
-
true
if the sheet displays Automatic Page Breaks.
(value - 如果工作表显示自动分页符,则为 true。)
void setDisplayGuts(boolean value)
value
- - guts or no guts
(价值 - - 有胆量或没有胆量)
void setDisplayZeros(boolean value)
value
- whether to display or hide all zero values on the worksheet
(value - 是否在工作表上显示或隐藏所有零值)
boolean isDisplayZeros()
void setFitToPage(boolean value)
value
-
true
if the Fit to Page print option is enabled.
(value - 如果启用了适合页面打印选项,则为 true。)
void setRowSumsBelow(boolean value)
When true a summary row is inserted below the detailed data being summarized and a new outline level is established on that row.
When false a summary row is inserted above the detailed data being summarized and a new outline level is established on that row.
(应用大纲时,指示摘要行是否出现在大纲中的详细信息下方的标志。如果为真,则在要汇总的详细数据下方插入汇总行,并在该行上建立新的大纲级别。如果为 false,则在要汇总的详细数据上方插入汇总行,并在该行上建立新的大纲级别。)value
-
true
if row summaries appear below detail in the outline
(value - 如果行摘要出现在大纲中的详细信息下方,则为 true)
void setRowSumsRight(boolean value)
When true a summary column is inserted to the right of the detailed data being summarized and a new outline level is established on that column.
When false a summary column is inserted to the left of the detailed data being summarized and a new outline level is established on that column.
(应用大纲时,指示摘要列是否显示在大纲中详细信息右侧的标志。如果为真,则在要汇总的详细数据的右侧插入汇总列,并在该列上建立新的大纲级别。如果为 false,则在要汇总的详细数据的左侧插入汇总列,并在该列上建立新的大纲级别。)value
-
true
if col summaries appear right of the detail in the outline
(value - 如果 col 摘要出现在大纲中详细信息的右侧,则为 true)
boolean getAutobreaks()
true
if the sheet displays Automatic Page Breaks.
(如果工作表显示自动分页符,则为 true。)
boolean getDisplayGuts()
boolean getFitToPage()
true
if the Fit to Page print option is enabled.
(如果启用了适合页面打印选项,则为 true。)
boolean getRowSumsBelow()
When true a summary row is inserted below the detailed data being summarized and a new outline level is established on that row.
When false a summary row is inserted above the detailed data being summarized and a new outline level is established on that row.
(应用大纲时,指示摘要行是否出现在大纲中的详细信息下方的标志。如果为真,则在要汇总的详细数据下方插入汇总行,并在该行上建立新的大纲级别。如果为 false,则在要汇总的详细数据上方插入汇总行,并在该行上建立新的大纲级别。)true
if row summaries appear below detail in the outline
(如果行摘要出现在大纲中的详细信息下方,则为 true)
boolean getRowSumsRight()
When true a summary column is inserted to the right of the detailed data being summarized and a new outline level is established on that column.
When false a summary column is inserted to the left of the detailed data being summarized and a new outline level is established on that column.
(应用大纲时,指示摘要列是否显示在大纲中详细信息右侧的标志。如果为真,则在要汇总的详细数据的右侧插入汇总列,并在该列上建立新的大纲级别。如果为 false,则在要汇总的详细数据的左侧插入汇总列,并在该列上建立新的大纲级别。)true
if col summaries appear right of the detail in the outline
(如果 col 摘要出现在大纲中详细信息的右侧,则为 true)
boolean isPrintGridlines()
true
if this sheet prints gridlines.
(如果此工作表打印网格线,则为 true。)
to check if gridlines are displayed on screen
void setPrintGridlines(boolean show)
show
-
true
if this sheet should print gridlines.
(show - 如果此工作表应打印网格线,则为 true。)
to display gridlines on screen
boolean isPrintRowAndColumnHeadings()
true
if this sheet prints row and column headings.
(如果此工作表打印行和列标题,则为 true。)
void setPrintRowAndColumnHeadings(boolean show)
show
-
true
if this sheet should print row and column headings.
(show - 如果此工作表应打印行和列标题,则为 true。)
PrintSetup getPrintSetup()
Header getHeader()
Note that XSSF offers more kinds of document headers than HSSF does
(获取默认文档标题的用户模型。请注意,XSSF 提供比 HSSF 更多种类的文档标题)null
(文档标题。从不为空)
Footer getFooter()
Note that XSSF offers more kinds of document footers than HSSF does.
(获取默认文档页脚的用户模型。请注意,XSSF 提供的文档页脚种类比 HSSF 多。)null
(文档页脚。从不为空)
void setSelected(boolean value)
Note: multiple sheets can be selected, but only one sheet can be active at one time.
(设置一个标志,指示此工作表是否被选中。注意:可以选择多张工作表,但一次只能激活一张工作表。)value
-
true
if this sheet is selected
(value - 如果选择了此工作表,则为 true)
Workbook.setActiveSheet(int)
double getMargin(short margin)
margin
- which margin to get
(保证金 - 要获得的保证金)
void setMargin(short margin, double size)
margin
- which margin to get
(保证金 - 要获得的保证金)
size
- the size of the margin
(size - 边距的大小)
boolean getProtect()
void protectSheet(java.lang.String password)
password
- to set for protection. Pass
null
to remove protection
(密码 - 设置保护。传递 null 以删除保护)
boolean getScenarioProtect()
void setZoom(int scale)
10 - 10% 20 - 20% ... 100 - 100% ... 400 - 400%(表示百分比值的当前视图的窗口缩放比例。有效值范围从 10 到 400。水平和垂直比例一起。例如:10 - 10% 20 - 20% ... 100 - 100% ... 400 - 400%)
scale
- window zoom magnification
(scale - 窗口缩放倍率)
java.lang.IllegalArgumentException
- if scale is invalid
(java.lang.IllegalArgumentException - 如果比例无效)
short getTopRow()
short getLeftCol()
void showInPane(int topRow, int leftCol)
topRow
- the top row to show in desktop window pane
(topRow - 在桌面窗口窗格中显示的第一行)
leftCol
- the left column to show in desktop window pane
(leftCol - 要在桌面窗口窗格中显示的左列)
void shiftRows(int startRow, int endRow, int n)
Additionally shifts merged regions that are completely defined in these rows (ie. merged 2 cells on a row to be shifted).
(在 startRow 和 endRow 之间移动行 n 行。如果您使用负数,它将向上移动行。代码确保行不会环绕。调用 shiftRows(startRow, endRow, n, false, false);另外移动在这些行中完全定义的合并区域(即,在要移动的行上合并 2 个单元格)。)startRow
- the row to start shifting
(startRow - 开始移动的行)
endRow
- the row to end shifting
(endRow - 结束移位的行)
n
- the number of rows to shift
(n - 要移动的行数)
void shiftRows(int startRow, int endRow, int n, boolean copyRowHeight, boolean resetOriginalRowHeight)
Additionally shifts merged regions that are completely defined in these rows (ie. merged 2 cells on a row to be shifted). All merged regions that are completely overlaid by shifting will be deleted.
(在 startRow 和 endRow 之间移动行 n 行。如果您使用负数,它将向上移动行。代码确保行不会环绕另外移动在这些行中完全定义的合并区域(即,在要移动的行上合并 2 个单元格)。所有被移位完全覆盖的合并区域将被删除。)startRow
- the row to start shifting
(startRow - 开始移动的行)
endRow
- the row to end shifting
(endRow - 结束移位的行)
n
- the number of rows to shift
(n - 要移动的行数)
copyRowHeight
- whether to copy the row height during the shift
(copyRowHeight - 是否在班次期间复制行高)
resetOriginalRowHeight
- whether to set the original row's height to the default
(resetOriginalRowHeight - 是否将原始行的高度设置为默认值)
void shiftColumns(int startColumn, int endColumn, int n)
startColumn
- the column to start shifting
(startColumn - 开始移动的列)
endColumn
- the column to end shifting
(endColumn - 结束移位的列)
n
- the number of columns to shift
(n - 要移动的列数)
void createFreezePane(int colSplit, int rowSplit, int leftmostColumn, int topRow)
If both colSplit and rowSplit are zero then the existing freeze pane is removed
(创建一个拆分(冻结窗格)。任何现有的冻结窗格或拆分窗格都会被覆盖。如果 colSplit 和 rowSplit 都为零,则删除现有的冻结窗格)colSplit
- Horizontal position of split.
(colSplit - 拆分的水平位置。)
rowSplit
- Vertical position of split.
(rowSplit - 拆分的垂直位置。)
leftmostColumn
- Left column visible in right pane.
(leftmostColumn - 在右窗格中可见的左列。)
topRow
- Top row visible in bottom pane
(topRow - 在底部窗格中可见的顶行)
void createFreezePane(int colSplit, int rowSplit)
If both colSplit and rowSplit are zero then the existing freeze pane is removed
(创建一个拆分(冻结窗格)。任何现有的冻结窗格或拆分窗格都会被覆盖。如果 colSplit 和 rowSplit 都为零,则删除现有的冻结窗格)colSplit
- Horizontal position of split.
(colSplit - 拆分的水平位置。)
rowSplit
- Vertical position of split.
(rowSplit - 拆分的垂直位置。)
void createSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane)
xSplitPos
- Horizontal position of split (in 1/20th of a point).
(xSplitPos - 分割的水平位置(点的 1/20)。)
ySplitPos
- Vertical position of split (in 1/20th of a point).
(ySplitPos - 分割的垂直位置(点的 1/20)。)
topRow
- Top row visible in bottom pane
(topRow - 在底部窗格中可见的顶行)
leftmostColumn
- Left column visible in right pane.
(leftmostColumn - 在右窗格中可见的左列。)
activePane
- Active pane. One of: PANE_LOWER_RIGHT, PANE_UPPER_RIGHT, PANE_LOWER_LEFT, PANE_UPPER_LEFT
(activePane - 活动窗格。以下之一:PANE_LOWER_RIGHT、PANE_UPPER_RIGHT、PANE_LOWER_LEFT、PANE_UPPER_LEFT)
PANE_LOWER_LEFT
,
PANE_LOWER_RIGHT
,
PANE_UPPER_LEFT
,
PANE_UPPER_RIGHT
PaneInformation getPaneInformation()
void setDisplayGridlines(boolean show)
show
- whether to show gridlines or not
(show - 是否显示网格线)
boolean isDisplayGridlines()
void setDisplayFormulas(boolean show)
show
- whether to show formulas or not
(show - 是否显示公式)
boolean isDisplayFormulas()
void setDisplayRowColHeadings(boolean show)
show
- whether to show RowColHeadings or not
(show - 是否显示 RowColHeadings)
boolean isDisplayRowColHeadings()
void setRowBreak(int row)
sheet.setColumnBreak(2);
breaks the sheet into two parts with columns A,B,C in the first and D,E,... in the second. Similar,
sheet.setRowBreak(2);
breaks the sheet into two parts with first three rows (rownum=1...3) in the first part and rows starting with rownum=4 in the second.
(在指示的行处设置分页符 分页符发生在指定行的上方和指定列的左侧(含)。例如 sheet.setColumnBreak(2);将工作表分成两部分,第一部分为 A、B、C 列,第二部分为 D、E、...。类似的, sheet.setRowBreak(2);将工作表分成两部分,第一部分为前三行 (rownum=1...3),第二部分为以 rownum=4 开头的行。)
row
- the row to break, inclusive
(row - 要中断的行,包括)
boolean isRowBroken(int row)
row
- FIXME: Document this!
(行 - FIXME:记录这个!)
void removeRowBreak(int row)
row
- The 0-based index of the row.
(row - 行的从 0 开始的索引。)
int[] getRowBreaks()
int[] getColumnBreaks()
void setColumnBreak(int column)
sheet.setColumnBreak(2);
breaks the sheet into two parts with columns A,B,C in the first and D,E,... in the second. Similar,
sheet.setRowBreak(2);
breaks the sheet into two parts with first three rows (rownum=1...3) in the first part and rows starting with rownum=4 in the second.
(在指示的列处设置分页符。中断发生在指定行的上方和指定列的左侧(含)。例如 sheet.setColumnBreak(2);将工作表分成两部分,第一部分为 A、B、C 列,第二部分为 D、E、...。类似的, sheet.setRowBreak(2);将工作表分成两部分,第一部分为前三行 (rownum=1...3),第二部分为以 rownum=4 开头的行。)
column
- the column to break, inclusive
(column - 要中断的列,包括)
boolean isColumnBroken(int column)
column
- FIXME: Document this!
(专栏 - FIXME:记录这个!)
void removeColumnBreak(int column)
column
- The 0-based index of the column.
(column - 列的从 0 开始的索引。)
void setColumnGroupCollapsed(int columnNumber, boolean collapsed)
columnNumber
- One of the columns in the group.
(columnNumber - 组中的列之一。)
collapsed
- true = collapse group, false = expand group.
(折叠 - true = 折叠组,false = 展开组。)
void groupColumn(int fromColumn, int toColumn)
fromColumn
- beginning of the column range.
(fromColumn - 列范围的开始。)
toColumn
- end of the column range.
(toColumn - 列范围的结尾。)
void ungroupColumn(int fromColumn, int toColumn)
fromColumn
- start column (0-based)
(fromColumn - 起始列(从 0 开始))
toColumn
- end column (0-based)
(toColumn - 结束列(从 0 开始))
void groupRow(int fromRow, int toRow)
fromRow
- start row (0-based)
(fromRow - 起始行(从 0 开始))
toRow
- end row (0-based)
(toRow - 结束行(从 0 开始))
void ungroupRow(int fromRow, int toRow)
fromRow
- start row (0-based)
(fromRow - 起始行(从 0 开始))
toRow
- end row (0-based)
(toRow - 结束行(从 0 开始))
void setRowGroupCollapsed(int row, boolean collapse)
row
- start row of a grouped range of rows (0-based)
(row - 一组行的开始行(从 0 开始))
collapse
- whether to expand/collapse the detail rows
(折叠 - 是否展开/折叠详细信息行)
void setDefaultColumnStyle(int column, CellStyle style)
column
- the column index
(column - 列索引)
style
- the style to set
(style - 要设置的样式)
void autoSizeColumn(int column)
This process can be relatively slow on large sheets, so this should normally only be called once per column, at the end of your processing.
You can specify whether the content of merged cells should be considered or ignored. Default is to ignore merged cells. (调整列宽以适合内容。此过程在大型工作表上可能相对较慢,因此通常在处理结束时每列只调用一次。您可以指定是否应考虑或忽略合并单元格的内容。默认是忽略合并的单元格。)column
- the column index
(column - 列索引)
void autoSizeColumn(int column, boolean useMergedCells)
This process can be relatively slow on large sheets, so this should normally only be called once per column, at the end of your processing.
You can specify whether the content of merged cells should be considered or ignored. Default is to ignore merged cells. (调整列宽以适合内容。此过程在大型工作表上可能相对较慢,因此通常在处理结束时每列只调用一次。您可以指定是否应考虑或忽略合并单元格的内容。默认是忽略合并的单元格。)column
- the column index
(column - 列索引)
useMergedCells
- whether to use the contents of merged cells when calculating the width of the column
(useMergedCells - 计算列宽时是否使用合并单元格的内容)
Comment getCellComment(CellAddress ref)
null
if not found
(单元格注释或 null 如果未找到)
java.util.Map<CellAddress,? extends Comment> getCellComments()
Drawing<?> getDrawingPatriarch()
createDrawingPatriarch()
to get or create
(返回工作表的现有绘图,如果还没有,则返回 null。使用 createDrawingPatriarch() 获取或创建)
Drawing<?> createDrawingPatriarch()
This may then be used to add graphics or charts.
Note that this will normally have the effect of removing any existing drawings on this sheet.
(创建顶级图形族长。然后可以使用它来添加图形或图表。请注意,这通常会删除此工作表上的任何现有图纸。)Workbook getWorkbook()
java.lang.String getSheetName()
boolean isSelected()
true
if this sheet is currently selected
(如果当前选择了此工作表,则为 true)
CellRange<? extends Cell> setArrayFormula(java.lang.String formula, CellRangeAddress range)
Note if there are shared formulas this will invalidate any FormulaEvaluator
instances based on this workbook
formula
- text representation of the formula
(公式 - 公式的文本表示)
range
- Region of array formula for result.
(range - 结果的数组公式区域。)
CellRange
of cells affected by this change
(受此更改影响的单元格的 CellRange)
CellRange<? extends Cell> removeArrayFormula(Cell cell)
cell
- any cell within Array Formula range
(单元格 - 数组公式范围内的任何单元格)
CellRange
of cells affected by this change
(受此更改影响的单元格的 CellRange)
DataValidationHelper getDataValidationHelper()
java.util.List<? extends DataValidation> getDataValidations()
void addValidationData(DataValidation dataValidation)
dataValidation
- The Data validation object settings
(dataValidation - 数据验证对象设置)
AutoFilter setAutoFilter(CellRangeAddress range)
range
- the range of cells to filter
(range - 要过滤的单元格范围)
SheetConditionalFormatting getSheetConditionalFormatting()
CellRangeAddress getRepeatingRows()
Repeating rows cover a range of contiguous rows, e.g.:
Sheet1!$1:$1 Sheet2!$5:$8The
CellRangeAddress
returned contains a column part which spans all columns, and a row part which specifies the contiguous range of repeating rows.
If the Sheet does not have any repeating rows defined, null is returned.
(获取打印工作表时使用的重复行,如 File->PageSetup->Sheet 中所示。重复行覆盖一系列连续行,例如: Sheet1!$1:$1 Sheet2!$5:$8 返回的 CellRangeAddress 包含一个跨所有列的列部分和一个指定重复行的连续范围的行部分。如果工作表没有定义任何重复行,则返回 null。)CellRangeAddress
containing the repeating rows for the Sheet, or null.
(包含工作表的重复行的 CellRangeAddress,或 null。)
CellRangeAddress getRepeatingColumns()
Repeating columns cover a range of contiguous columns, e.g.:
Sheet1!$A:$A Sheet2!$C:$FThe
CellRangeAddress
returned contains a row part which spans all rows, and a column part which specifies the contiguous range of repeating columns.
If the Sheet does not have any repeating columns defined, null is returned.
(获取打印工作表时使用的重复列,如 File->PageSetup->Sheet 中所示。重复列覆盖一系列连续列,例如: Sheet1!$A:$A Sheet2!$C:$F 返回的 CellRangeAddress 包含一个跨所有行的行部分和一个指定重复列的连续范围的列部分。如果工作表没有定义任何重复的列,则返回 null。)CellRangeAddress
containing the repeating columns for the Sheet, or null.
(包含工作表的重复列的 CellRangeAddress,或 null。)
void setRepeatingRows(CellRangeAddress rowRangeRef)
Repeating rows cover a range of contiguous rows, e.g.:
Sheet1!$1:$1 Sheet2!$5:$8The parameter
CellRangeAddress
should specify a column part which spans all columns, and a row part which specifies the contiguous range of repeating rows, e.g.:
sheet.setRepeatingRows(CellRangeAddress.valueOf("2:3"));A null parameter value indicates that repeating rows should be removed from the Sheet:
sheet.setRepeatingRows(null);(设置打印工作表时使用的重复行,如 File->PageSetup->Sheet 中所示。重复行覆盖一系列连续行,例如:Sheet1!$1:$1 Sheet2!$5:$8 参数 CellRangeAddress 应指定跨越所有列的列部分,以及指定重复行的连续范围的行部分,例如:sheet .setRepeatingRows(CellRangeAddress.valueOf("2:3"));空参数值表示应从工作表中删除重复行: sheet.setRepeatingRows(null);)
rowRangeRef
- a
CellRangeAddress
containing the repeating rows for the Sheet, or null.
(rowRangeRef - 包含工作表的重复行的 CellRangeAddress,或 null。)
void setRepeatingColumns(CellRangeAddress columnRangeRef)
Repeating columns cover a range of contiguous columns, e.g.:
Sheet1!$A:$A Sheet2!$C:$FThe parameter
CellRangeAddress
should specify a row part which spans all rows, and a column part which specifies the contiguous range of repeating columns, e.g.:
sheet.setRepeatingColumns(CellRangeAddress.valueOf("B:C"));A null parameter value indicates that repeating columns should be removed from the Sheet:
sheet.setRepeatingColumns(null);(设置打印工作表时使用的重复列,如 File->PageSetup->Sheet 中所示。重复列覆盖一系列连续列,例如: Sheet1!$A:$A Sheet2!$C:$F 参数 CellRangeAddress 应指定跨越所有行的行部分,以及指定重复列的连续范围的列部分,例如: sheet.setRepeatingColumns(CellRangeAddress.valueOf("B:C"));空参数值表示应从工作表中删除重复列: sheet.setRepeatingColumns(null);)
columnRangeRef
- a
CellRangeAddress
containing the repeating columns for the Sheet, or null.
(columnRangeRef - 包含工作表的重复列的 CellRangeAddress,或 null。)
int getColumnOutlineLevel(int columnIndex)
Hyperlink getHyperlink(int row, int column)
row
- The 0-based index of the row to look at.
(row - 要查看的行的从 0 开始的索引。)
column
- The 0-based index of the column to look at.
(column - 要查看的列的从 0 开始的索引。)
Hyperlink getHyperlink(CellAddress addr)
addr
- The address of the cell containing the hyperlink
(addr - 包含超链接的单元格的地址)
addr
; otherwise returns
null
(超链接,如果有一个超链接锚定在 addr;否则返回 null)
java.util.List<? extends Hyperlink> getHyperlinkList()
CellAddress getActiveCell()
A1
.
(返回活动单元格的位置,例如 A1。)
void setActiveCell(CellAddress address)
address
- the location of the active cell, e.g.
A1
.
(地址 - 活动单元的位置,例如 A1。)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.