Modifier and Type | Field and Description |
---|---|
protected InternalWorkbook |
_book |
protected HSSFWorkbook |
_workbook |
static int |
INITIAL_CAPACITY
Used for compile-time optimization.
|
BottomMargin, FooterMargin, HeaderMargin, LeftMargin, PANE_LOWER_LEFT, PANE_LOWER_RIGHT, PANE_UPPER_LEFT, PANE_UPPER_RIGHT, RightMargin, TopMargin
Modifier | Constructor and Description |
---|---|
protected |
HSSFSheet(HSSFWorkbook workbook)
Creates new HSSFSheet - called by HSSFWorkbook to create a sheet from
scratch.
|
protected |
HSSFSheet(HSSFWorkbook workbook,
InternalSheet sheet)
Creates an HSSFSheet representing the given Sheet object.
|
Modifier and Type | Method and Description |
---|---|
int |
addMergedRegion(CellRangeAddress region)
Adds a merged region of cells on a sheet.
|
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.
|
HSSFPatriarch |
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).
|
HSSFRow |
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.
|
void |
dumpDrawingRecords(boolean fat,
java.io.PrintWriter pw)
Aggregates the drawing records and dumps the escher record hierarchy
to the standard output.
|
protected HSSFComment |
findCellComment(int row,
int column) |
CellAddress |
getActiveCell()
Return location of the active cell, e.g.
|
boolean |
getAlternateExpression()
whether alternate expression evaluation is on
|
boolean |
getAlternateFormula()
whether alternative formula entry is on
|
boolean |
getAutobreaks()
show automatic page breaks or not
|
HSSFComment |
getCellComment(CellAddress ref)
Returns cell comment for the specified row and column
|
java.util.Map<CellAddress,HSSFComment> |
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.
|
HSSFCellStyle |
getColumnStyle(int column)
Returns the HSSFCellStyle 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 column)
get the width in pixel
|
DataValidationHelper |
getDataValidationHelper() |
java.util.List<HSSFDataValidation> |
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 |
getDialog()
get whether sheet is a dialog sheet or not
|
boolean |
getDisplayGuts()
get whether to display the guts or not
|
EscherAggregate |
getDrawingEscherAggregate()
Returns the agregate escher records for this sheet,
it there is one.
|
HSSFPatriarch |
getDrawingPatriarch()
This will hold any graphics or charts for the sheet.
|
int |
getFirstRowNum()
Gets the first row on the sheet
|
boolean |
getFitToPage()
fit to page option is on
|
HSSFFooter |
getFooter()
Gets the user model for the default document footer.
|
boolean |
getForceFormulaRecalculation()
Whether a record must be inserted or not at generation to indicate that
formula must be recalculated when workbook is opened.
|
HSSFHeader |
getHeader()
Gets the user model for the default document header.
|
boolean |
getHorizontallyCenter()
Determine whether printed output for this sheet will be horizontally centered.
|
HSSFHyperlink |
getHyperlink(CellAddress addr)
Get a Hyperlink in this sheet located in a cell specified by {code addr}
|
HSSFHyperlink |
getHyperlink(int row,
int column)
Get a Hyperlink in this sheet anchored at row, column
|
java.util.List<HSSFHyperlink> |
getHyperlinkList()
Get a list of Hyperlinks in this sheet
|
int |
getLastRowNum()
Gets the number last row on the sheet.
|
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
|
boolean |
getObjectProtect()
Answer whether object protection is enabled or disabled
|
PaneInformation |
getPaneInformation()
Returns the information regarding the currently configured pane (split or freeze).
|
short |
getPassword() |
int |
getPhysicalNumberOfRows()
Returns the number of physically defined rows (NOT the number of rows in the sheet)
|
HSSFPrintSetup |
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.
|
HSSFRow |
getRow(int rowIndex)
Returns the logical row (not physical) 0-based.
|
int[] |
getRowBreaks()
Retrieves all the horizontal page breaks
|
boolean |
getRowSumsBelow()
get if row summaries appear below detail in the outline
|
boolean |
getRowSumsRight()
get if col summaries appear right of the detail in the outline
|
boolean |
getScenarioProtect()
Answer whether scenario protection is enabled or disabled
|
InternalSheet |
getSheet()
used internally in the API to get the low level Sheet record represented by this
Object.
|
HSSFSheetConditionalFormatting |
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.
|
HSSFWorkbook |
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 cell together so that they can be collapsed or expanded
|
protected void |
insertChartRecords(java.util.List<Record> records) |
boolean |
isActive() |
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 |
isGridsPrinted()
get whether gridlines are printed.
|
boolean |
isPrintGridlines()
Returns whether gridlines are printed.
|
boolean |
isPrintRowAndColumnHeadings()
Returns whether row and column headings are printed.
|
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)
|
java.util.Iterator<Row> |
iterator()
Alias for
rowIterator() to allow
foreach loops |
protected void |
preSerialize()
check whether the data of sheet can be serialized
|
void |
protectSheet(java.lang.String password)
Sets the protection enabled as well as the password
|
CellRange<HSSFCell> |
removeArrayFormula(Cell cell)
Remove a Array Formula from this sheet.
|
void |
removeColumnBreak(int column)
Removes a page break at the indicated column
|
protected void |
removeHyperlink(HSSFHyperlink link)
Remove the underlying HyperlinkRecord from this sheet.
|
protected void |
removeHyperlink(HyperlinkRecord link)
Remove the underlying HyperlinkRecord from this sheet
|
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 |
setActive(boolean sel)
Sets whether sheet is selected.
|
void |
setActiveCell(CellAddress address)
Sets location of the active cell
|
void |
setAlternativeExpression(boolean b)
whether alternate expression evaluation is on
|
void |
setAlternativeFormula(boolean b)
whether alternative formula entry is on
|
CellRange<HSSFCell> |
setArrayFormula(java.lang.String formula,
CellRangeAddress range)
Sets array formula to specified region for result.
|
void |
setAutobreaks(boolean b)
show automatic page breaks or not
|
HSSFAutoFilter |
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 |
setDialog(boolean b)
set whether sheet is a dialog sheet or not
|
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 b)
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 b)
fit to page option is on
|
void |
setForceFormulaRecalculation(boolean value)
Control if Excel should be asked to recalculate all formulas on this sheet
when the workbook is opened.
|
void |
setGridsPrinted(boolean value)
set whether gridlines printed.
|
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)
Turns on or off the printing of gridlines.
|
void |
setPrintRowAndColumnHeadings(boolean show)
Turns on or off the printing of row and column headings.
|
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 rowIndex,
boolean collapse)
Set view state of a grouped range of rows
|
void |
setRowSumsBelow(boolean b)
set if row summaries appear below detail in the outline
|
void |
setRowSumsRight(boolean b)
set if col summaries appear right of the detail in the outline
|
void |
setSelected(boolean sel)
Sets whether 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 |
setZoom(int numerator,
int denominator)
Sets the zoom magnification for the sheet.
|
void |
shiftColumns(int startColumn,
int endColumn,
int n)
Shifts columns in range [startColumn, endColumn] for n places to the right.
|
protected void |
shiftMerged(int startRow,
int endRow,
int n,
boolean isRow)
Deprecated.
POI 3.15 beta 2. Use
RowShifter.shiftMergedRegions(int, int, int) . |
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 |
shiftRows(int startRow,
int endRow,
int n,
boolean copyRowHeight,
boolean resetOriginalRowHeight,
boolean moveComments)
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
|
protected void |
validateColumn(int column)
Runs a bounds check for column numbers
|
void |
validateMergedRegions()
Verify that merged regions do not intersect multi-cell array formulas and
no merged regions intersect another merged region in this sheet.
|
protected void |
validateRow(int row)
Runs a bounds check for row numbers
|
public static final int INITIAL_CAPACITY
protected final InternalWorkbook _book
protected final HSSFWorkbook _workbook
protected HSSFSheet(HSSFWorkbook workbook)
workbook
- - The HSSF Workbook object associated with the sheet.HSSFWorkbook.createSheet()
protected HSSFSheet(HSSFWorkbook workbook, InternalSheet sheet)
workbook
- - The HSSF Workbook object associated with the sheet.sheet
- - lowlevel Sheet object this sheet will representHSSFWorkbook.createSheet()
protected void preSerialize()
public HSSFWorkbook getWorkbook()
getWorkbook
in interface Sheet
public HSSFRow createRow(int rownum)
createRow
in interface Sheet
rownum
- row numberHSSFRow
,
removeRow(org.apache.poi.ss.usermodel.Row)
public void removeRow(Row row)
public HSSFRow getRow(int rowIndex)
public int getPhysicalNumberOfRows()
getPhysicalNumberOfRows
in interface Sheet
public int getFirstRowNum()
getFirstRowNum
in interface Sheet
public int getLastRowNum()
getPhysicalNumberOfRows()
to
tell if there is a row at position zero
or not.getLastRowNum
in interface Sheet
public java.util.List<HSSFDataValidation> getDataValidations()
Sheet
getDataValidations
in interface Sheet
public void addValidationData(DataValidation dataValidation)
addValidationData
in interface Sheet
dataValidation
- The Data validation object settingspublic void setColumnHidden(int columnIndex, boolean hidden)
setColumnHidden
in interface Sheet
columnIndex
- - the column to get (0-based)hidden
- - the visiblity state of the columnpublic boolean isColumnHidden(int columnIndex)
isColumnHidden
in interface Sheet
columnIndex
- - the column to set (0-based)false
if the column is visiblepublic 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
.
setColumnWidth
in interface Sheet
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)public int getColumnWidth(int columnIndex)
getColumnWidth
in interface Sheet
columnIndex
- - the column to set (0-based)public float getColumnWidthInPixels(int column)
Sheet
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
getColumnWidthInPixels
in interface Sheet
column
- - the column to set (0-based)public int getDefaultColumnWidth()
getDefaultColumnWidth
in interface Sheet
public void setDefaultColumnWidth(int width)
setDefaultColumnWidth
in interface Sheet
width
- default column widthpublic short getDefaultRowHeight()
getDefaultRowHeight
in interface Sheet
public float getDefaultRowHeightInPoints()
getDefaultRowHeightInPoints
in interface Sheet
public void setDefaultRowHeight(short height)
setDefaultRowHeight
in interface Sheet
height
- default row heightpublic void setDefaultRowHeightInPoints(float height)
setDefaultRowHeightInPoints
in interface Sheet
height
- default row heightpublic HSSFCellStyle getColumnStyle(int column)
getColumnStyle
in interface Sheet
public boolean isGridsPrinted()
public void setGridsPrinted(boolean value)
value
- false if not printed.public int addMergedRegion(CellRangeAddress region)
addMergedRegion
in interface Sheet
region
- to mergejava.lang.IllegalArgumentException
- if region contains fewer than 2 cellsjava.lang.IllegalStateException
- if region intersects with a multi-cell array formulajava.lang.IllegalStateException
- if region intersects with an existing region on this sheetpublic int addMergedRegionUnsafe(CellRangeAddress region)
validateMergedRegions()
, which runs in O(n^2) time.addMergedRegionUnsafe
in interface Sheet
region
- to mergejava.lang.IllegalArgumentException
- if region contains fewer than 2 cellspublic void validateMergedRegions()
validateMergedRegions
in interface Sheet
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 sheetpublic 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.
It is recommended to force recalcuation of formulas on workbook level using
Workbook.setForceFormulaRecalculation(boolean)
to ensure that all cross-worksheet formuals and external dependencies are updated.
setForceFormulaRecalculation
in interface Sheet
value
- true if the application will perform a full recalculation of
this worksheet values when the workbook is openedWorkbook.setForceFormulaRecalculation(boolean)
public boolean getForceFormulaRecalculation()
getForceFormulaRecalculation
in interface Sheet
public void setVerticallyCenter(boolean value)
setVerticallyCenter
in interface Sheet
value
- true to vertically center, false otherwise.public boolean getVerticallyCenter()
getVerticallyCenter
in interface Sheet
public void setHorizontallyCenter(boolean value)
setHorizontallyCenter
in interface Sheet
value
- true to horizontally center, false otherwise.public boolean getHorizontallyCenter()
getHorizontallyCenter
in interface Sheet
public void setRightToLeft(boolean value)
setRightToLeft
in interface Sheet
value
- true for right to left, false otherwise.public boolean isRightToLeft()
isRightToLeft
in interface Sheet
public void removeMergedRegion(int index)
removeMergedRegion
in interface Sheet
index
- of the region to unmergepublic void removeMergedRegions(java.util.Collection<java.lang.Integer> indices)
removeMergedRegions
in interface Sheet
indices
- A set of the regions to unmergepublic int getNumMergedRegions()
getNumMergedRegions
in interface Sheet
public CellRangeAddress getMergedRegion(int index)
Sheet
getMergedRegion
in interface Sheet
public java.util.List<CellRangeAddress> getMergedRegions()
Sheet
getMergedRegions
in interface Sheet
public java.util.Iterator<Row> rowIterator()
Sheet
rowIterator
in interface Sheet
public java.util.Iterator<Row> iterator()
rowIterator()
to allow
foreach loopsiterator
in interface java.lang.Iterable<Row>
@Internal public InternalSheet getSheet()
public void setAlternativeExpression(boolean b)
b
- alternative expression evaluation or notpublic void setAlternativeFormula(boolean b)
b
- alternative formulas or notpublic void setAutobreaks(boolean b)
setAutobreaks
in interface Sheet
b
- whether to show auto page breakspublic void setDialog(boolean b)
b
- isDialog or notpublic void setDisplayGuts(boolean b)
setDisplayGuts
in interface Sheet
b
- guts or no guts (or glory)public void setFitToPage(boolean b)
setFitToPage
in interface Sheet
b
- fit or notpublic void setRowSumsBelow(boolean b)
setRowSumsBelow
in interface Sheet
b
- below or notpublic void setRowSumsRight(boolean b)
setRowSumsRight
in interface Sheet
b
- right or notpublic boolean getAlternateExpression()
public boolean getAlternateFormula()
public boolean getAutobreaks()
getAutobreaks
in interface Sheet
public boolean getDialog()
public boolean getDisplayGuts()
getDisplayGuts
in interface Sheet
public boolean isDisplayZeros()
In Excel 2003 this option can be changed in the Options dialog on the View tab.
isDisplayZeros
in interface Sheet
public void setDisplayZeros(boolean value)
In Excel 2003 this option can be set in the Options dialog on the View tab.
setDisplayZeros
in interface Sheet
value
- whether to display or hide all zero values on the worksheetpublic boolean getFitToPage()
getFitToPage
in interface Sheet
public boolean getRowSumsBelow()
getRowSumsBelow
in interface Sheet
public boolean getRowSumsRight()
getRowSumsRight
in interface Sheet
public boolean isPrintGridlines()
isPrintGridlines
in interface Sheet
to check if gridlines are displayed on screen
public void setPrintGridlines(boolean show)
setPrintGridlines
in interface Sheet
show
- boolean to turn on or off the printing of
gridlinesto display gridlines on screen
public boolean isPrintRowAndColumnHeadings()
isPrintRowAndColumnHeadings
in interface Sheet
public void setPrintRowAndColumnHeadings(boolean show)
setPrintRowAndColumnHeadings
in interface Sheet
show
- boolean to turn on or off the printing of
row and column headingspublic HSSFPrintSetup getPrintSetup()
getPrintSetup
in interface Sheet
public HSSFHeader getHeader()
Sheet
Note that XSSF offers more kinds of document headers than HSSF does
public HSSFFooter getFooter()
Sheet
Note that XSSF offers more kinds of document footers than HSSF does.
public boolean isSelected()
isSelected
in interface Sheet
true
if this sheet is currently selectedpublic void setSelected(boolean sel)
setSelected
in interface Sheet
sel
- Whether to select the sheet or deselect the sheet.Workbook.setActiveSheet(int)
public boolean isActive()
true
if this sheet is currently focusedpublic void setActive(boolean sel)
sel
- Whether to select the sheet or deselect the sheet.public double getMargin(short margin)
public void setMargin(short margin, double size)
public boolean getProtect()
getProtect
in interface Sheet
public short getPassword()
public boolean getObjectProtect()
public boolean getScenarioProtect()
getScenarioProtect
in interface Sheet
public void protectSheet(java.lang.String password)
protectSheet
in interface Sheet
password
- to set for protection. Pass null
to remove protectionpublic void setZoom(int numerator, int denominator)
numerator
- The numerator for the zoom magnification.denominator
- The denominator for the zoom magnification.setZoom(int)
public void setZoom(int scale)
10 - 10% 20 - 20% ... 100 - 100% ... 400 - 400%
public short getTopRow()
public short getLeftCol()
getLeftCol
in interface Sheet
public void showInPane(int topRow, int leftCol)
showInPane
in interface Sheet
topRow
- the top row to show in desktop window paneleftCol
- the left column to show in desktop window paneprotected void shiftMerged(int startRow, int endRow, int n, boolean isRow)
RowShifter.shiftMergedRegions(int, int, int)
.startRow
- the start-index of the rows to shift, zero-basedendRow
- the end-index of the rows to shift, zero-basedn
- how far to shift, negative to shift upisRow
- unused, kept for backwards compatibilitypublic void shiftRows(int startRow, int endRow, int n)
Calls shiftRows(startRow, endRow, n, false, false);
Additionally shifts merged regions that are completely defined in these rows (ie. merged 2 cells on a row to be shifted).
public 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.
TODO Might want to add bounds checking here
shiftRows
in interface Sheet
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 defaultpublic void shiftRows(int startRow, int endRow, int n, boolean copyRowHeight, boolean resetOriginalRowHeight, boolean moveComments)
Additionally shifts merged regions that are completely defined in these rows (ie. merged 2 cells on a row to be shifted).
TODO Might want to add bounds checking here
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 defaultmoveComments
- whether to move comments at the same time as the cells they are attached to@Beta public void shiftColumns(int startColumn, int endColumn, int n)
shiftColumns
in interface Sheet
startColumn
- the column to start shiftingendColumn
- the column to end shiftingn
- the number of columns to shiftprotected void insertChartRecords(java.util.List<Record> records)
public void createFreezePane(int colSplit, int rowSplit, int leftmostColumn, int topRow)
If both colSplit and rowSplit are zero then the existing freeze pane is removed
createFreezePane
in interface Sheet
colSplit
- Horizonatal position of split.rowSplit
- Vertical position of split.leftmostColumn
- Left column visible in right pane.topRow
- Top row visible in bottom panepublic void createFreezePane(int colSplit, int rowSplit)
If both colSplit and rowSplit are zero then the existing freeze pane is removed
createFreezePane
in interface Sheet
colSplit
- Horizonatal position of split.rowSplit
- Vertical position of split.public void createSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane)
createSplitPane
in interface Sheet
xSplitPos
- Horizonatal 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_LEFTSheet.PANE_LOWER_LEFT
,
Sheet.PANE_LOWER_RIGHT
,
Sheet.PANE_UPPER_LEFT
,
Sheet.PANE_UPPER_RIGHT
public PaneInformation getPaneInformation()
getPaneInformation
in interface Sheet
public void setDisplayGridlines(boolean show)
setDisplayGridlines
in interface Sheet
show
- whether to show gridlines or notpublic boolean isDisplayGridlines()
isDisplayGridlines
in interface Sheet
public void setDisplayFormulas(boolean show)
setDisplayFormulas
in interface Sheet
show
- whether to show formulas or notpublic boolean isDisplayFormulas()
isDisplayFormulas
in interface Sheet
public void setDisplayRowColHeadings(boolean show)
setDisplayRowColHeadings
in interface Sheet
show
- whether to show RowColHeadings or notpublic boolean isDisplayRowColHeadings()
isDisplayRowColHeadings
in interface Sheet
public void setRowBreak(int row)
For example, sheet.setColumnBreak(2);
breaks the sheet into two parts
with columns A,B,C in the first and D,E,... in the second. Simuilar, 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.
setRowBreak
in interface Sheet
row
- the row to break, inclusivepublic boolean isRowBroken(int row)
Sheet
isRowBroken
in interface Sheet
row
- FIXME: Document this!true
if there is a page break at the indicated rowpublic void removeRowBreak(int row)
removeRowBreak
in interface Sheet
row
- The 0-based index of the row.public int[] getRowBreaks()
Sheet
getRowBreaks
in interface Sheet
null
public int[] getColumnBreaks()
Sheet
getColumnBreaks
in interface Sheet
null
public void setColumnBreak(int column)
For example, sheet.setColumnBreak(2);
breaks the sheet into two parts
with columns A,B,C in the first and D,E,... in the second. Simuilar, 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.
setColumnBreak
in interface Sheet
column
- the column to break, inclusivepublic boolean isColumnBroken(int column)
isColumnBroken
in interface Sheet
column
- FIXME: Document this!public void removeColumnBreak(int column)
removeColumnBreak
in interface Sheet
column
- The index of the column for which to remove a page-break, zero-basedprotected void validateRow(int row)
row
- the index of the row to validate, zero-basedprotected void validateColumn(int column)
column
- the index of the column to validate, zero-basedpublic void dumpDrawingRecords(boolean fat, java.io.PrintWriter pw)
public EscherAggregate getDrawingEscherAggregate()
public HSSFPatriarch getDrawingPatriarch()
getDrawingPatriarch
in interface Sheet
public HSSFPatriarch 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.
createDrawingPatriarch
in interface Sheet
public void setColumnGroupCollapsed(int columnNumber, boolean collapsed)
setColumnGroupCollapsed
in interface Sheet
columnNumber
- One of the columns in the group.collapsed
- true = collapse group, false = expand group.public void groupColumn(int fromColumn, int toColumn)
groupColumn
in interface Sheet
fromColumn
- beginning of the column range.toColumn
- end of the column range.public void ungroupColumn(int fromColumn, int toColumn)
Sheet
ungroupColumn
in interface Sheet
fromColumn
- start column (0-based)toColumn
- end column (0-based)public void groupRow(int fromRow, int toRow)
public void ungroupRow(int fromRow, int toRow)
Sheet
ungroupRow
in interface Sheet
fromRow
- start row (0-based)toRow
- end row (0-based)public void setRowGroupCollapsed(int rowIndex, boolean collapse)
Sheet
setRowGroupCollapsed
in interface Sheet
rowIndex
- start row of a grouped range of rows (0-based)collapse
- whether to expand/collapse the detail rowspublic void setDefaultColumnStyle(int column, CellStyle style)
setDefaultColumnStyle
in interface Sheet
column
- the column indexstyle
- the style to setpublic 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.
autoSizeColumn
in interface Sheet
column
- the column indexpublic 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.
autoSizeColumn
in interface Sheet
column
- the column indexuseMergedCells
- whether to use the contents of merged cells when calculating the width of the columnpublic HSSFComment getCellComment(CellAddress ref)
getCellComment
in interface Sheet
null
if not foundpublic HSSFHyperlink getHyperlink(int row, int column)
getHyperlink
in interface Sheet
row
- The index of the row of the hyperlink, zero-basedcolumn
- the index of the column of the hyperlink, zero-basedpublic HSSFHyperlink getHyperlink(CellAddress addr)
getHyperlink
in interface Sheet
addr
- The address of the cell containing the hyperlinkaddr
; otherwise returns null
public java.util.List<HSSFHyperlink> getHyperlinkList()
getHyperlinkList
in interface Sheet
protected void removeHyperlink(HSSFHyperlink link)
link
- the HSSFHyperlink wrapper around the HyperlinkRecord to removeprotected void removeHyperlink(HyperlinkRecord link)
link
- the underlying HyperlinkRecord to remove from this sheetpublic HSSFSheetConditionalFormatting getSheetConditionalFormatting()
Sheet
getSheetConditionalFormatting
in interface Sheet
public java.lang.String getSheetName()
getSheetName
in interface Sheet
public CellRange<HSSFCell> setArrayFormula(java.lang.String formula, CellRangeAddress range)
Sheet
Note if there are shared formulas this will invalidate any
FormulaEvaluator
instances based on this workbook
setArrayFormula
in interface Sheet
formula
- text representation of the formularange
- Region of array formula for result.CellRange
of cells affected by this changepublic CellRange<HSSFCell> removeArrayFormula(Cell cell)
Sheet
removeArrayFormula
in interface Sheet
cell
- any cell within Array Formula rangeCellRange
of cells affected by this changepublic DataValidationHelper getDataValidationHelper()
getDataValidationHelper
in interface Sheet
public HSSFAutoFilter setAutoFilter(CellRangeAddress range)
Sheet
setAutoFilter
in interface Sheet
range
- the range of cells to filterprotected HSSFComment findCellComment(int row, int column)
public java.util.Map<CellAddress,HSSFComment> getCellComments()
getCellComments
in interface Sheet
public CellRangeAddress getRepeatingRows()
Sheet
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.
getRepeatingRows
in interface Sheet
CellRangeAddress
containing the repeating rows for the
Sheet, or null.public CellRangeAddress getRepeatingColumns()
Sheet
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.
getRepeatingColumns
in interface Sheet
CellRangeAddress
containing the repeating columns for
the Sheet, or null.public void setRepeatingRows(CellRangeAddress rowRangeRef)
Sheet
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);
setRepeatingRows
in interface Sheet
rowRangeRef
- a CellRangeAddress
containing the repeating
rows for the Sheet, or null.public void setRepeatingColumns(CellRangeAddress columnRangeRef)
Sheet
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);
setRepeatingColumns
in interface Sheet
columnRangeRef
- a CellRangeAddress
containing the repeating
columns for the Sheet, or null.public int getColumnOutlineLevel(int columnIndex)
getColumnOutlineLevel
in interface Sheet
public CellAddress getActiveCell()
A1
.getActiveCell
in interface Sheet
public void setActiveCell(CellAddress address)
setActiveCell
in interface Sheet
address
- the location of the active cell, e.g. A1
.Copyright 2020 The Apache Software Foundation or its licensors, as applicable.