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.
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
|
int |
getColumnWidth(int columnIndex)
get the width (in units of 1/256th of a character width )
|
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.
|
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)
|
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
|
Drawing<?> |
getDrawingPatriarch()
Return the sheet's existing drawing, or null if there isn't yet one.
|
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.
|
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}
|
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!
|
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.
|
CellRangeAddress |
getRepeatingRows()
Gets the repeating rows used when printing the sheet, as found in
File->PageSetup->Sheet.
|
Row |
getRow(int rownum)
Returns the logical row (not physical) 0-based.
|
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.
|
boolean |
isDisplayZeros()
Gets the flag indicating whether the window should show 0 (zero) in cells containing zero value.
|
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)
|
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)
|
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)
|
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
|
void |
setDisplayZeros(boolean value)
Set whether the window should show 0 (zero) in cells containing zero value.
|
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.
|
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.
|
void |
setRepeatingRows(CellRangeAddress rowRangeRef)
Sets the repeating rows used when printing the sheet, as found in
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.
|
void |
shiftRows(int startRow,
int endRow,
int n)
Shifts rows between startRow and endRow n number of rows.
|
void |
shiftRows(int startRow,
int endRow,
int n,
boolean copyRowHeight,
boolean resetOriginalRowHeight)
Shifts rows between startRow and endRow n number of rows.
|
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 numberremoveRow(Row)
void removeRow(Row row)
row
- representing a row to remove.Row getRow(int rownum)
rownum
- row to get (0-based)int getPhysicalNumberOfRows()
int getFirstRowNum()
int getLastRowNum()
void setColumnHidden(int columnIndex, boolean hidden)
columnIndex
- - the column to get (0-based)hidden
- - the visibility state of the columnboolean isColumnHidden(int columnIndex)
columnIndex
- - the column to set (0-based)false
if the column is visiblevoid setRightToLeft(boolean value)
value
- true for right to left, false otherwise.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)width
- - the width in units of 1/256th of a character widthjava.lang.IllegalArgumentException
- if width > 255*256 (the maximum column width in Excel is 255 characters)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)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
columnIndex
- - the column to set (0-based)void setDefaultColumnWidth(int width)
width
- default column width measured in charactersint getDefaultColumnWidth()
short getDefaultRowHeight()
float getDefaultRowHeightInPoints()
void setDefaultRowHeight(short height)
height
- default row height measured in twips (1/20 of a point)void setDefaultRowHeightInPoints(float height)
height
- default row heightCellStyle getColumnStyle(int column)
int addMergedRegion(CellRangeAddress region)
region
- (rowfrom/colfrom-rowto/colto) to mergeint addMergedRegionUnsafe(CellRangeAddress region)
validateMergedRegions()
, which runs in O(n^2) time.region
- to mergejava.lang.IllegalArgumentException
- if region contains fewer than 2 cellsvoid validateMergedRegions()
java.lang.IllegalStateException
- if region intersects with a multi-cell array formulajava.lang.IllegalStateException
- if at least one region intersects with another merged region in this sheetvoid setVerticallyCenter(boolean value)
value
- true to vertically center, false otherwise.void setHorizontallyCenter(boolean value)
value
- true to horizontally center, false otherwise.boolean getHorizontallyCenter()
boolean getVerticallyCenter()
void removeMergedRegion(int index)
index
- of the region to unmergevoid removeMergedRegions(java.util.Collection<java.lang.Integer> indices)
indices
- A set of the regions to unmergeint 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.value
- true if the application will perform a full recalculation of
this worksheet values when the workbook is openedWorkbook.setForceFormulaRecalculation(boolean)
boolean getForceFormulaRecalculation()
void setAutobreaks(boolean value)
value
- true
if the sheet displays Automatic Page Breaks.void setDisplayGuts(boolean value)
value
- - guts or no gutsvoid setDisplayZeros(boolean value)
value
- whether to display or hide all zero values on the worksheetboolean isDisplayZeros()
void setFitToPage(boolean value)
value
- true
if the Fit to Page print option is enabled.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.
value
- true
if row summaries appear below detail in the outlinevoid 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.
value
- true
if col summaries appear right of the detail in the outlineboolean getAutobreaks()
true
if the sheet displays Automatic Page Breaks.boolean getDisplayGuts()
boolean getFitToPage()
true
if the Fit to Page print option is enabled.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.
true
if row summaries appear below detail in the outlineboolean 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.
true
if col summaries appear right of the detail in the outlineboolean isPrintGridlines()
true
if this sheet prints gridlines.to check if gridlines are displayed on screen
void setPrintGridlines(boolean show)
show
- true
if this sheet should print gridlines.to display gridlines on screen
boolean isPrintRowAndColumnHeadings()
true
if this sheet prints row and column headings.void setPrintRowAndColumnHeadings(boolean show)
show
- true
if this sheet should print row and column headings.PrintSetup getPrintSetup()
Header getHeader()
Note that XSSF offers more kinds of document headers than HSSF does
null
Footer getFooter()
Note that XSSF offers more kinds of document footers than HSSF does.
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 selectedWorkbook.setActiveSheet(int)
double getMargin(short margin)
margin
- which margin to getvoid setMargin(short margin, double size)
margin
- which margin to getsize
- the size of the marginboolean getProtect()
void protectSheet(java.lang.String password)
password
- to set for protection. Pass null
to remove protectionboolean getScenarioProtect()
void setZoom(int scale)
10 - 10% 20 - 20% ... 100 - 100% ... 400 - 400%
scale
- window zoom magnificationjava.lang.IllegalArgumentException
- if scale is invalidshort getTopRow()
short getLeftCol()
void showInPane(int toprow, int leftcol)
toprow
- the top row to show in desktop window paneleftcol
- the left column to show in desktop window panevoid 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
- the row to start shiftingendRow
- the row to end shiftingn
- the number of rows to shiftvoid 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
- the row to start shiftingendRow
- the row to end shiftingn
- the number of rows to shiftcopyRowHeight
- whether to copy the row height during the shiftresetOriginalRowHeight
- whether to set the original row's height to the defaultvoid shiftColumns(int startColumn, int endColumn, int n)
startColumn
- the column to start shiftingendColumn
- the column to end shiftingn
- the number of columns to shiftvoid createFreezePane(int colSplit, int rowSplit, int leftmostColumn, int topRow)
If both colSplit and rowSplit are zero then the existing freeze pane is removed
colSplit
- Horizontal position of split.rowSplit
- Vertical position of split.leftmostColumn
- Left column visible in right pane.topRow
- Top row visible in bottom panevoid createFreezePane(int colSplit, int rowSplit)
If both colSplit and rowSplit are zero then the existing freeze pane is removed
colSplit
- Horizontal position of split.rowSplit
- Vertical position of split.void createSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane)
xSplitPos
- Horizontal position of split (in 1/20th of a point).ySplitPos
- Vertical position of split (in 1/20th of a point).topRow
- Top row visible in bottom paneleftmostColumn
- Left column visible in right pane.activePane
- Active pane. One of: PANE_LOWER_RIGHT,
PANE_UPPER_RIGHT, PANE_LOWER_LEFT, PANE_UPPER_LEFTPANE_LOWER_LEFT
,
PANE_LOWER_RIGHT
,
PANE_UPPER_LEFT
,
PANE_UPPER_RIGHT
PaneInformation getPaneInformation()
void setDisplayGridlines(boolean show)
show
- whether to show gridlines or notboolean isDisplayGridlines()
void setDisplayFormulas(boolean show)
show
- whether to show formulas or notboolean isDisplayFormulas()
void setDisplayRowColHeadings(boolean show)
show
- whether to show RowColHeadings or notboolean 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.row
- the row to break, inclusiveboolean isRowBroken(int row)
row
- FIXME: Document this!void removeRowBreak(int row)
row
- The 0-based index of the row.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.column
- the column to break, inclusiveboolean isColumnBroken(int column)
column
- FIXME: Document this!void removeColumnBreak(int column)
column
- The 0-based index of the column.void setColumnGroupCollapsed(int columnNumber, boolean collapsed)
columnNumber
- One of the columns in the group.collapsed
- true = collapse group, false = expand group.void groupColumn(int fromColumn, int toColumn)
fromColumn
- beginning of the column range.toColumn
- end of the column range.void ungroupColumn(int fromColumn, int toColumn)
fromColumn
- start column (0-based)toColumn
- end column (0-based)void groupRow(int fromRow, int toRow)
fromRow
- start row (0-based)toRow
- end row (0-based)void ungroupRow(int fromRow, int toRow)
fromRow
- start row (0-based)toRow
- end row (0-based)void setRowGroupCollapsed(int row, boolean collapse)
row
- start row of a grouped range of rows (0-based)collapse
- whether to expand/collapse the detail rowsvoid setDefaultColumnStyle(int column, CellStyle style)
column
- the column indexstyle
- the style to setvoid 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 indexvoid 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 indexuseMergedCells
- whether to use the contents of merged cells when calculating the width of the columnComment getCellComment(CellAddress ref)
null
if not foundjava.util.Map<CellAddress,? extends Comment> getCellComments()
Drawing<?> getDrawingPatriarch()
createDrawingPatriarch()
to get or createDrawing<?> 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 selectedCellRange<? 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 formularange
- Region of array formula for result.CellRange
of cells affected by this changeCellRange<? extends Cell> removeArrayFormula(Cell cell)
cell
- any cell within Array Formula rangeCellRange
of cells affected by this changeDataValidationHelper getDataValidationHelper()
java.util.List<? extends DataValidation> getDataValidations()
void addValidationData(DataValidation dataValidation)
dataValidation
- The Data validation object settingsAutoFilter setAutoFilter(CellRangeAddress range)
range
- the range of cells to filterSheetConditionalFormatting 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.
CellRangeAddress
containing the repeating rows for the
Sheet, or 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.
CellRangeAddress
containing the repeating columns for
the Sheet, or 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);
rowRangeRef
- a CellRangeAddress
containing the repeating
rows for the Sheet, or 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);
columnRangeRef
- a CellRangeAddress
containing the repeating
columns for the Sheet, or null.int getColumnOutlineLevel(int columnIndex)
Hyperlink getHyperlink(int row, int column)
row
- The 0-based index of the row to look at.column
- The 0-based index of the column to look at.Hyperlink getHyperlink(CellAddress addr)
addr
- The address of the cell containing the hyperlinkaddr
; otherwise returns null
java.util.List<? extends Hyperlink> getHyperlinkList()
CellAddress getActiveCell()
A1
.void setActiveCell(CellAddress address)
address
- the location of the active cell, e.g. A1
.Copyright 2018 The Apache Software Foundation or its licensors, as applicable.