Package io.keikai.model
Interface SSheet
-
- All Known Implementing Classes:
AbstractSheetAdv
,SheetImpl
public interface SSheet
A sheet of a book. It's the main class you can manipulate rows, columns, cells, pictures, charts, and data validation.- Since:
- 3.5.0
- Author:
- dennis
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
SSheet.SheetVisible
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description SChart
addChart(SChart.ChartType type, ViewAnchor anchor)
SDataValidation
addDataValidation(CellRegion region)
SDataValidation
addDataValidation(CellRegion region, SDataValidation src)
void
addMergedRegion(CellRegion region)
Add a merged area, you can't assign a area that overlaps existed merged area.SPicture
addPicture(int index, ViewAnchor anchor)
Add a picture into the sheet with known picture data index.SPicture
addPicture(SPicture.Format format, byte[] data, ViewAnchor anchor)
Add a picture into this sheet with raw picture data and format.void
addTable(STable table)
Add a new tablevoid
clearAutoFilter()
Clear auto filter if there is.void
clearCell(int rowIdx, int columnIdx, int lastRowIdx, int lastColumnIdx)
void
clearCell(CellRegion region)
Clear cells in specified regionSAutoFilter
createAutoFilter(CellRegion region)
Creates a new auto filter, the old one will be drop directly.void
deleteAutoFilter()
Delete current autofilter if it hasvoid
deleteCell(int rowIdx, int columnIdx, int lastRowIndex, int lastColumnIndex, boolean horizontal)
void
deleteCell(CellRegion region, boolean horizontal)
Delete a region of cells and shift existing cells.void
deleteChart(SChart chart)
void
deleteColumn(int columnIdx, int lastColumnIdx)
delete columns specified by first and last indexvoid
deleteDataValidation(SDataValidation validation)
List<SDataValidation>
deleteDataValidationRegion(CellRegion region)
Delete data validations that are covered by the specified region.void
deletePicture(SPicture picture)
void
deleteRow(int rowIdx, int lastRowIdx)
delete rows specified by first and last indexList<CellRegion>
getAllArrayFormulas()
Returns all cell regions of array formula in the given sheetObject
getAttribute(String name)
Get the runtime custom attribute that stored in this sheetMap<String,Object>
getAttributes()
Get the unmodifiable runtime attributes mapSAutoFilter
getAutoFilter()
Gets the auto filter information if there is.SBook
getBook()
Get the owner bookSCell
getCell(int rowIdx, int columnIdx)
This method always returns not-null cell object.SCell
getCell(String cellRefString)
Iterator<SCell>
getCellIterator(int row)
CellRegion
getCellRegionInArrayFormula(SCell cell)
Returns the cell regin if the given cell is in an array formula.SChart
getChart(int idx)
SChart
getChart(String chartid)
List<SChart>
getCharts()
SColumn
getColumn(int columnIdx)
SColumnArray
getColumnArray(int columnIdx)
Iterator<SColumnArray>
getColumnArrayIterator()
Iterator<SColumn>
getColumnIterator()
List<SConditionalFormatting>
getConditionalFormattings()
Returns the conditional formatting applied to this sheet.List<CellRegion>
getContainsMergedRegions(CellRegion region)
Get the merged region that are contained by region.CellRegion
getDataRegion()
Returns the region which contains data(including chart, picture, and fills) in this sheet; return null if empty sheet.SDataValidation
getDataValidation(int idx)
SDataValidation
getDataValidation(int row, int column)
SDataValidation
getDataValidation(String id)
List<SDataValidation>
getDataValidations()
int
getDefaultColumnWidth()
int
getDefaultRowHeight()
int
getEndCellIndex(int rowIdx)
int
getEndColumnIndex()
int
getEndRowIndex()
short
getHashedPassword()
Internal Use only.String
getId()
CellRegion
getMergedRegion(int idx)
CellRegion
getMergedRegion(int row, int column)
CellRegion
getMergedRegion(String cellRefString)
List<CellRegion>
getMergedRegions()
int
getNumOfChart()
int
getNumOfDataValidation()
int
getNumOfMergedRegion()
int
getNumOfPicture()
int
getOutlineLevelCol()
Returns the maximum outline level for column represent.int
getOutlineLevelRow()
Returns the maximum outline level for row represent.List<CellRegion>
getOverlapsMergedRegions(CellRegion region, boolean excludeContains)
Get the merged region that overlapped the regionSPicture
getPicture(int idx)
SPicture
getPicture(String picid)
List<SPicture>
getPictures()
SPrintSetup
getPrintSetup()
SRow
getRow(int rowIdx)
Iterator<SRow>
getRowIterator()
Iterator<SRow>
getRowIterator(int start, int end)
String
getSheetName()
Get the sheet nameSSheetProtection
getSheetProtection()
Gets enhanced protection.SSheet.SheetVisible
getSheetVisible()
Get the sheet current visible state.int
getStartCellIndex(int rowIdx)
int
getStartColumnIndex()
int
getStartRowIndex()
String
getTabColor()
List<STable>
getTables()
Get tables in this sheetSSheetViewInfo
getViewInfo()
void
insertCell(int rowIdx, int columnIdx, int lastRowIndex, int lastColumnIndex, boolean horizontal)
void
insertCell(CellRegion region, boolean horizontal)
Insert a region of cells and shift existing cells.void
insertColumn(int columnIdx, int lastColumnIdx)
insert columns specified by first and last indexvoid
insertRow(int rowIdx, int lastRowIdx)
insert rows specified by first and last indexboolean
isApplyStyles()
Returns whether to apply the styles in outline.boolean
isProtected()
Check if the sheet is protectedboolean
isShowOutlineSymbols()
Returns whether to display outline symbols.boolean
isSummaryBelow()
Returns whether to display summary below in outline for rows.boolean
isSummaryRight()
Returns whether to display summary right in outline for columns.void
moveCell(int rowIdx, int columnIdx, int lastRowIdx, int lastColumnIdx, int rowOffset, int columnOffset)
Move a region of cells specified by 4 indexes.void
moveCell(CellRegion region, int rowOffset, int columnOffset)
Move one or more cells.CellRegion
pasteCell(SheetRegion src, CellRegion dest, PasteOption option)
paste cell from src sheet to this sheet, the sheets must in same bookCellRegion
removeArrayFormula(SCell cell)
Remove an Array Formula from this sheet.void
removeMergedRegion(CellRegion region, boolean removeOverlaps)
Remove the merged area that are contained by regionvoid
removeTable(String tableName)
Remove the table of the specified table name.void
setAlgName(String algName)
New way of hashing sheet protection password.void
setApplyStyles(boolean applyStyles)
Sets to apply with the styles in outline.CellRegion
setArrayFormula(String formula, CellRegion region)
Sets array formula to specified region for result.Object
setAttribute(String name, Object value)
Set the runtime custom attribute to stored in this sheet, the attribute is only use for developer to stored runtime data in the sheet, values will not stored to excel when exporting.void
setDefaultColumnWidth(int width)
set default column width in pixelsvoid
setDefaultRowHeight(int height)
set default row height in pixelsvoid
setHashedPassword(short hashpass)
Internal User only.void
setHashValue(String hashValue)
New way of hashing sheet protection password.void
setOutlineLevelCol(int outlineLevelCol)
Sets the maximum outline level for column represent of this sheet.void
setOutlineLevelRow(int outlineLevelRow)
Sets the maximum outline level for row represent of this sheet.void
setPassword(String password)
Sets password to protect sheet, set null to unprotect it.void
setSaltValue(String saltValue)
New way of hashing sheet protection password.void
setSheetVisible(SSheet.SheetVisible state)
Set the sheet current visible state.void
setShowOutlineSymbols(boolean showOutlineSymbols)
Sets whether to display outline symbols.void
setSpinCount(String spinCount)
New way of hashing sheet protection password.void
setSummaryBelow(boolean summaryBelow)
Sets to display summary below in outline for rows.void
setSummaryRight(boolean summaryRight)
Sets whether to display summary right in outline for columns.void
setTabColor(String tabColor)
Set sheet tab colorSColumnArray
setupColumnArray(int colunmIdx, int lastColumnIdx)
Set up a column array, if one array range overlaps another, it throws IllegalStateException.
-
-
-
Method Detail
-
getBook
SBook getBook()
Get the owner book- Returns:
- the owner book
-
getSheetName
String getSheetName()
Get the sheet name- Returns:
- the sheet name
-
getRowIterator
Iterator<SRow> getRowIterator()
- Returns:
- an iterator of existing rows excluding those blank rows
-
getRowIterator
Iterator<SRow> getRowIterator(int start, int end)
- Parameters:
start
- the start indexend
- the end index- Returns:
- an iterator of existing rows excluding those blank rows
- Since:
- 5.0.0
-
getColumnIterator
Iterator<SColumn> getColumnIterator()
- Returns:
- an iterator of existing columns excluding those blank columns
-
getColumnArrayIterator
Iterator<SColumnArray> getColumnArrayIterator()
-
setupColumnArray
SColumnArray setupColumnArray(int colunmIdx, int lastColumnIdx)
Set up a column array, if one array range overlaps another, it throws IllegalStateException. If you setup a column array that is not continuous, (for example, 0~2, 5~6), then it will create a missing column array automatically to make them continuous.(3~4 in the example). It's required to set up in ascending order of starting column index (min), or it will create unexpectedSColumnArray
for columns are not continuous.- Parameters:
colunmIdx
- index of the starting columnlastColumnIdx
- index of the end column- Returns:
- the new created column array
-
getDefaultRowHeight
int getDefaultRowHeight()
- Returns:
- default row height in pixels
-
getDefaultColumnWidth
int getDefaultColumnWidth()
- Returns:
- default column width in pixels
-
setDefaultRowHeight
void setDefaultRowHeight(int height)
set default row height in pixels
-
setDefaultColumnWidth
void setDefaultColumnWidth(int width)
set default column width in pixels
-
getRow
SRow getRow(int rowIdx)
-
getColumnArray
SColumnArray getColumnArray(int columnIdx)
- See Also:
setupColumnArray(int, int)
-
getColumn
SColumn getColumn(int columnIdx)
-
getCell
SCell getCell(int rowIdx, int columnIdx)
This method always returns not-null cell object. UseSCell.isNull()
to know it's null (blank) or not.
-
getCell
SCell getCell(String cellRefString)
- Returns:
- return a cell with specified cell reference, e.g. A2, B3. Area reference, A1:A2, is not acceptable.
- See Also:
getCell(int, int)
-
getId
String getId()
- Returns:
- interal sheet object ID
-
getViewInfo
SSheetViewInfo getViewInfo()
-
getPrintSetup
SPrintSetup getPrintSetup()
-
getStartRowIndex
int getStartRowIndex()
-
getEndRowIndex
int getEndRowIndex()
-
getStartColumnIndex
int getStartColumnIndex()
-
getEndColumnIndex
int getEndColumnIndex()
-
getStartCellIndex
int getStartCellIndex(int rowIdx)
-
getEndCellIndex
int getEndCellIndex(int rowIdx)
-
clearCell
void clearCell(int rowIdx, int columnIdx, int lastRowIdx, int lastColumnIdx)
- See Also:
clearCell(CellRegion)
-
clearCell
void clearCell(CellRegion region)
Clear cells in specified region
-
moveCell
void moveCell(int rowIdx, int columnIdx, int lastRowIdx, int lastColumnIdx, int rowOffset, int columnOffset)
Move a region of cells specified by 4 indexes.- See Also:
moveCell(CellRegion, int, int)
-
moveCell
void moveCell(CellRegion region, int rowOffset, int columnOffset)
Move one or more cells.- Parameters:
region
- the region of cells to moverowOffset
- positive number to move down, negative to move upcolumnOffset
- positive number to move right, negative to move left
-
insertRow
void insertRow(int rowIdx, int lastRowIdx)
insert rows specified by first and last index
-
deleteRow
void deleteRow(int rowIdx, int lastRowIdx)
delete rows specified by first and last index
-
insertColumn
void insertColumn(int columnIdx, int lastColumnIdx)
insert columns specified by first and last index
-
deleteColumn
void deleteColumn(int columnIdx, int lastColumnIdx)
delete columns specified by first and last index
-
insertCell
void insertCell(int rowIdx, int columnIdx, int lastRowIndex, int lastColumnIndex, boolean horizontal)
- See Also:
insertCell(CellRegion, boolean)
-
insertCell
void insertCell(CellRegion region, boolean horizontal)
Insert a region of cells and shift existing cells.- Parameters:
region
- the region of cells to inserthorizontal
- TRUE for shifting right, FALSE for shifting down
-
deleteCell
void deleteCell(CellRegion region, boolean horizontal)
Delete a region of cells and shift existing cells.- Parameters:
region
- the region of cells to deletehorizontal
- TRUE for shifting left, FALSE for shifting up
-
deleteCell
void deleteCell(int rowIdx, int columnIdx, int lastRowIndex, int lastColumnIndex, boolean horizontal)
- See Also:
deleteCell(CellRegion, boolean)
-
addPicture
SPicture addPicture(SPicture.Format format, byte[] data, ViewAnchor anchor)
Add a picture into this sheet with raw picture data and format.- Parameters:
format
- picture format as specified inSPicture.Format
data
- raw byte data of the pictureanchor
- where to anchor this picture- Returns:
- the added
SPicture
-
addPicture
SPicture addPicture(int index, ViewAnchor anchor)
Add a picture into the sheet with known picture data index.- Parameters:
index
-SPictureData
indexanchor
- where to anchor this picture- Returns:
- the
SPicture
added - Since:
- 3.6.0
-
deletePicture
void deletePicture(SPicture picture)
-
getNumOfPicture
int getNumOfPicture()
-
getPicture
SPicture getPicture(int idx)
-
addChart
SChart addChart(SChart.ChartType type, ViewAnchor anchor)
-
deleteChart
void deleteChart(SChart chart)
-
getNumOfChart
int getNumOfChart()
-
getChart
SChart getChart(int idx)
-
getMergedRegions
List<CellRegion> getMergedRegions()
-
removeMergedRegion
void removeMergedRegion(CellRegion region, boolean removeOverlaps)
Remove the merged area that are contained by region- Parameters:
region
-removeOverlaps
- true if you want to remove the merged areas that are just overlapped.
-
addMergedRegion
void addMergedRegion(CellRegion region)
Add a merged area, you can't assign a area that overlaps existed merged area.- Parameters:
region
-
-
getNumOfMergedRegion
int getNumOfMergedRegion()
-
getMergedRegion
CellRegion getMergedRegion(int idx)
-
getOverlapsMergedRegions
List<CellRegion> getOverlapsMergedRegions(CellRegion region, boolean excludeContains)
Get the merged region that overlapped the region- Returns:
- the regions that overlaps
-
getContainsMergedRegions
List<CellRegion> getContainsMergedRegions(CellRegion region)
Get the merged region that are contained by region.- Returns:
- the regions that are contained
-
getMergedRegion
CellRegion getMergedRegion(int row, int column)
-
getMergedRegion
CellRegion getMergedRegion(String cellRefString)
-
addDataValidation
SDataValidation addDataValidation(CellRegion region)
-
addDataValidation
SDataValidation addDataValidation(CellRegion region, SDataValidation src)
-
getDataValidation
SDataValidation getDataValidation(String id)
-
deleteDataValidation
void deleteDataValidation(SDataValidation validation)
-
getNumOfDataValidation
int getNumOfDataValidation()
-
getDataValidation
SDataValidation getDataValidation(int idx)
-
getDataValidations
List<SDataValidation> getDataValidations()
-
deleteDataValidationRegion
List<SDataValidation> deleteDataValidationRegion(CellRegion region)
Delete data validations that are covered by the specified region.- Parameters:
region
- the cover region- Returns:
- the data validations deleted
- Since:
- 3.6.0
-
getDataValidation
SDataValidation getDataValidation(int row, int column)
- Parameters:
row
-column
-- Returns:
- the first data validation at row, column
-
getAttribute
Object getAttribute(String name)
Get the runtime custom attribute that stored in this sheet- Parameters:
name
- the attribute name- Returns:
- the value, or null if not found
-
setAttribute
Object setAttribute(String name, Object value)
Set the runtime custom attribute to stored in this sheet, the attribute is only use for developer to stored runtime data in the sheet, values will not stored to excel when exporting.- Parameters:
name
- name the attribute namevalue
- the attribute value
-
getAttributes
Map<String,Object> getAttributes()
Get the unmodifiable runtime attributes map- Returns:
-
isProtected
boolean isProtected()
Check if the sheet is protected- Returns:
-
setPassword
void setPassword(String password)
Sets password to protect sheet, set null to unprotect it.- Parameters:
password
-
-
getHashedPassword
short getHashedPassword()
Internal Use only.- Returns:
-
setHashedPassword
void setHashedPassword(short hashpass)
Internal User only.
-
getAutoFilter
SAutoFilter getAutoFilter()
Gets the auto filter information if there is.- Returns:
- the auto filter, or null if not found
-
createAutoFilter
SAutoFilter createAutoFilter(CellRegion region)
Creates a new auto filter, the old one will be drop directly.- Parameters:
region
- the auto filter region- Returns:
- the new auto filter.
-
deleteAutoFilter
void deleteAutoFilter()
Delete current autofilter if it has
-
clearAutoFilter
void clearAutoFilter()
Clear auto filter if there is.
-
pasteCell
CellRegion pasteCell(SheetRegion src, CellRegion dest, PasteOption option)
paste cell from src sheet to this sheet, the sheets must in same book- Parameters:
src
- src sheet and it's region to pastedest
- destination region in this sheetoption
- the copy option- Returns:
- the final effected region
-
getSheetProtection
SSheetProtection getSheetProtection()
Gets enhanced protection.
-
getSheetVisible
SSheet.SheetVisible getSheetVisible()
Get the sheet current visible state.- Since:
- 3.7.0
-
setSheetVisible
void setSheetVisible(SSheet.SheetVisible state)
Set the sheet current visible state.- Since:
- 3.7.0
-
addTable
void addTable(STable table)
Add a new table- Parameters:
table
-- Since:
- 3.8.0
-
removeTable
void removeTable(String tableName)
Remove the table of the specified table name.- Parameters:
tableName
-- Since:
- 3.8.0
-
setHashValue
void setHashValue(String hashValue)
New way of hashing sheet protection password.- Parameters:
hashValue
-- Since:
- 3.8.1
-
setSpinCount
void setSpinCount(String spinCount)
New way of hashing sheet protection password.- Parameters:
spinCount
-- Since:
- 3.8.1
-
setSaltValue
void setSaltValue(String saltValue)
New way of hashing sheet protection password.- Parameters:
saltValue
-- Since:
- 3.8.1
-
setAlgName
void setAlgName(String algName)
New way of hashing sheet protection password.- Parameters:
algName
-- Since:
- 3.8.1
-
getConditionalFormattings
List<SConditionalFormatting> getConditionalFormattings()
Returns the conditional formatting applied to this sheet.- Returns:
- Since:
- 3.8.2
-
getDataRegion
CellRegion getDataRegion()
Returns the region which contains data(including chart, picture, and fills) in this sheet; return null if empty sheet.- Returns:
- the region which contains data(including chart, picture, and fills) in this sheet; return null if empty sheet.
- Since:
- 3.8.3
-
setTabColor
void setTabColor(String tabColor)
Set sheet tab color- Since:
- 5.2.0
-
getTabColor
String getTabColor()
- Returns:
- sheet tab color
- Since:
- 5.2.0
-
setArrayFormula
CellRegion setArrayFormula(String formula, CellRegion region)
Sets array formula to specified region for result.Note if there are shared formulas this will invalidate any
FormulaEvaluator
instances based on this workbook- Parameters:
formula
- text representation of the formularegion
- Region of array formula for result.- Returns:
- the
CellRegion
of cells affected by this change - Since:
- 6.0.0
-
removeArrayFormula
CellRegion removeArrayFormula(SCell cell)
Remove an Array Formula from this sheet. All cells contained in the Array Formula range are removed as well- Parameters:
cell
- any cell within Array Formula range- Returns:
- the
CellRegion
of cells affected by this change - Since:
- 6.0.0
-
getCellRegionInArrayFormula
CellRegion getCellRegionInArrayFormula(SCell cell)
Returns the cell regin if the given cell is in an array formula.- Parameters:
cell
-- Since:
- 6.0.0
-
getAllArrayFormulas
List<CellRegion> getAllArrayFormulas()
Returns all cell regions of array formula in the given sheet- Since:
- 6.0.0
-
setOutlineLevelRow
void setOutlineLevelRow(int outlineLevelRow)
Sets the maximum outline level for row represent of this sheet.- Parameters:
outlineLevelRow
-- Since:
- 6.0.0
-
getOutlineLevelRow
int getOutlineLevelRow()
Returns the maximum outline level for row represent.- Since:
- 6.0.0
-
setOutlineLevelCol
void setOutlineLevelCol(int outlineLevelCol)
Sets the maximum outline level for column represent of this sheet.- Parameters:
outlineLevelCol
-- Since:
- 6.0.0
-
getOutlineLevelCol
int getOutlineLevelCol()
Returns the maximum outline level for column represent.- Since:
- 6.0.0
-
isApplyStyles
boolean isApplyStyles()
Returns whether to apply the styles in outline.Default:
false
- Since:
- 6.0.0
-
setApplyStyles
void setApplyStyles(boolean applyStyles)
Sets to apply with the styles in outline.Note: Only used for maintaining model state. (not implemented for UI parts)
- Parameters:
applyStyles
- false not to apply- Since:
- 6.0.0
-
isSummaryBelow
boolean isSummaryBelow()
Returns whether to display summary below in outline for rows.Default:
true
- Since:
- 6.0.0
-
setSummaryBelow
void setSummaryBelow(boolean summaryBelow)
Sets to display summary below in outline for rows.Default:
true
- Parameters:
summaryBelow
- false to display on top.- Since:
- 6.0.0
-
isSummaryRight
boolean isSummaryRight()
Returns whether to display summary right in outline for columns.Default:
true
- Since:
- 6.0.0
-
setSummaryRight
void setSummaryRight(boolean summaryRight)
Sets whether to display summary right in outline for columns.Default:
true
- Parameters:
summaryRight
- false to display on left.- Since:
- 6.0.0
-
isShowOutlineSymbols
boolean isShowOutlineSymbols()
Returns whether to display outline symbols.Default:
true
- Since:
- 6.0.0
-
setShowOutlineSymbols
void setShowOutlineSymbols(boolean showOutlineSymbols)
Sets whether to display outline symbols.Default:
true
- Parameters:
showOutlineSymbols
- false not to show.- Since:
- 6.0.0
-
-