Package io.keikai.model
Interface SSheet
-
- All Known Implementing Classes:
AbstractSheetAdv,SheetImpl
public interface SSheetA 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 classSSheet.SheetVisible
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description SChartaddChart(SChart.ChartType type, ViewAnchor anchor)SDataValidationaddDataValidation(CellRegion region)SDataValidationaddDataValidation(CellRegion region, SDataValidation src)voidaddMergedRegion(CellRegion region)Add a merged area, you can't assign a area that overlaps existed merged area.SPictureaddPicture(int index, ViewAnchor anchor)Add a picture into the sheet with known picture data index.SPictureaddPicture(SPicture.Format format, byte[] data, ViewAnchor anchor)Add a picture into this sheet with raw picture data and format.voidaddTable(STable table)Add a new tablevoidclearAutoFilter()Clear auto filter if there is.voidclearCell(int rowIdx, int columnIdx, int lastRowIdx, int lastColumnIdx)voidclearCell(CellRegion region)Clear cells in specified regionSAutoFiltercreateAutoFilter(CellRegion region)Creates a new auto filter, the old one will be drop directly.voiddeleteAutoFilter()Delete current autofilter if it hasvoiddeleteCell(int rowIdx, int columnIdx, int lastRowIndex, int lastColumnIndex, boolean horizontal)voiddeleteCell(CellRegion region, boolean horizontal)Delete a region of cells and shift existing cells.voiddeleteChart(SChart chart)voiddeleteColumn(int columnIdx, int lastColumnIdx)delete columns specified by first and last indexvoiddeleteDataValidation(SDataValidation validation)List<SDataValidation>deleteDataValidationRegion(CellRegion region)Delete data validations that are covered by the specified region.voiddeletePicture(SPicture picture)voiddeleteRow(int rowIdx, int lastRowIdx)delete rows specified by first and last indexList<CellRegion>getAllArrayFormulas()Returns all cell regions of array formula in the given sheetObjectgetAttribute(String name)Get the runtime custom attribute that stored in this sheetMap<String,Object>getAttributes()Get the unmodifiable runtime attributes mapSAutoFiltergetAutoFilter()Gets the auto filter information if there is.SBookgetBook()Get the owner bookSCellgetCell(int rowIdx, int columnIdx)This method always returns not-null cell object.SCellgetCell(String cellRefString)Iterator<SCell>getCellIterator(int row)CellRegiongetCellRegionInArrayFormula(SCell cell)Returns the cell regin if the given cell is in an array formula.SChartgetChart(int idx)SChartgetChart(String chartid)List<SChart>getCharts()SColumngetColumn(int columnIdx)SColumnArraygetColumnArray(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.CellRegiongetDataRegion()Returns the region which contains data(including chart, picture, and fills) in this sheet; return null if empty sheet.SDataValidationgetDataValidation(int idx)SDataValidationgetDataValidation(int row, int column)SDataValidationgetDataValidation(String id)List<SDataValidation>getDataValidations()intgetDefaultColumnWidth()intgetDefaultRowHeight()intgetEndCellIndex(int rowIdx)intgetEndColumnIndex()intgetEndRowIndex()shortgetHashedPassword()Internal Use only.StringgetId()CellRegiongetMergedRegion(int idx)CellRegiongetMergedRegion(int row, int column)CellRegiongetMergedRegion(String cellRefString)List<CellRegion>getMergedRegions()intgetNumOfChart()intgetNumOfDataValidation()intgetNumOfMergedRegion()intgetNumOfPicture()intgetOutlineLevelCol()Returns the maximum outline level for column represent.intgetOutlineLevelRow()Returns the maximum outline level for row represent.List<CellRegion>getOverlapsMergedRegions(CellRegion region, boolean excludeContains)Get the merged region that overlapped the regionSPicturegetPicture(int idx)SPicturegetPicture(String picid)List<SPicture>getPictures()SPrintSetupgetPrintSetup()SRowgetRow(int rowIdx)Iterator<SRow>getRowIterator()Iterator<SRow>getRowIterator(int start, int end)StringgetSheetName()Get the sheet nameSSheetProtectiongetSheetProtection()Gets enhanced protection.SSheet.SheetVisiblegetSheetVisible()Get the sheet current visible state.intgetStartCellIndex(int rowIdx)intgetStartColumnIndex()intgetStartRowIndex()StringgetTabColor()List<STable>getTables()Get tables in this sheetSSheetViewInfogetViewInfo()voidinsertCell(int rowIdx, int columnIdx, int lastRowIndex, int lastColumnIndex, boolean horizontal)voidinsertCell(CellRegion region, boolean horizontal)Insert a region of cells and shift existing cells.voidinsertColumn(int columnIdx, int lastColumnIdx)insert columns specified by first and last indexvoidinsertRow(int rowIdx, int lastRowIdx)insert rows specified by first and last indexbooleanisApplyStyles()Returns whether to apply the styles in outline.booleanisProtected()Check if the sheet is protectedbooleanisShowOutlineSymbols()Returns whether to display outline symbols.booleanisSummaryBelow()Returns whether to display summary below in outline for rows.booleanisSummaryRight()Returns whether to display summary right in outline for columns.voidmoveCell(int rowIdx, int columnIdx, int lastRowIdx, int lastColumnIdx, int rowOffset, int columnOffset)Move a region of cells specified by 4 indexes.voidmoveCell(CellRegion region, int rowOffset, int columnOffset)Move one or more cells.CellRegionpasteCell(SheetRegion src, CellRegion dest, PasteOption option)paste cell from src sheet to this sheet, the sheets must in same bookCellRegionremoveArrayFormula(SCell cell)Remove an Array Formula from this sheet.voidremoveMergedRegion(CellRegion region, boolean removeOverlaps)Remove the merged area that are contained by regionvoidremoveTable(String tableName)Remove the table of the specified table name.voidsetAlgName(String algName)New way of hashing sheet protection password.voidsetApplyStyles(boolean applyStyles)Sets to apply with the styles in outline.CellRegionsetArrayFormula(String formula, CellRegion region)Sets array formula to specified region for result.ObjectsetAttribute(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.voidsetDefaultColumnWidth(int width)set default column width in pixelsvoidsetDefaultRowHeight(int height)set default row height in pixelsvoidsetHashedPassword(short hashpass)Internal User only.voidsetHashValue(String hashValue)New way of hashing sheet protection password.voidsetOutlineLevelCol(int outlineLevelCol)Sets the maximum outline level for column represent of this sheet.voidsetOutlineLevelRow(int outlineLevelRow)Sets the maximum outline level for row represent of this sheet.voidsetPassword(String password)Sets password to protect sheet, set null to unprotect it.voidsetSaltValue(String saltValue)New way of hashing sheet protection password.voidsetSheetVisible(SSheet.SheetVisible state)Set the sheet current visible state.voidsetShowOutlineSymbols(boolean showOutlineSymbols)Sets whether to display outline symbols.voidsetSpinCount(String spinCount)New way of hashing sheet protection password.voidsetSummaryBelow(boolean summaryBelow)Sets to display summary below in outline for rows.voidsetSummaryRight(boolean summaryRight)Sets whether to display summary right in outline for columns.voidsetTabColor(String tabColor)Set sheet tab colorSColumnArraysetupColumnArray(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 unexpectedSColumnArrayfor 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.Formatdata- 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-SPictureDataindexanchor- where to anchor this picture- Returns:
- the
SPictureadded - 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
FormulaEvaluatorinstances based on this workbook- Parameters:
formula- text representation of the formularegion- Region of array formula for result.- Returns:
- the
CellRegionof 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
CellRegionof 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
-
-