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 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCellRegionValueChangeListener(CellRegion cellRegion, SerializableConsumer<CellRegion> listener) Adds the listener when specific cell region value change.addChart(SChart.ChartType type, ViewAnchor anchor) addChart(String name, SChart.ChartType type, ViewAnchor anchor) Add a chart with name, type and anchoraddDataValidation(CellRegion region) addDataValidation(CellRegion region, SDataValidation src) voidaddMergedRegion(CellRegion region) Add a merged area, you can't assign a area that overlaps existed merged area.addPicture(int index, ViewAnchor anchor) Add a picture into the sheet with known picture data index.addPicture(SPicture.Format format, byte[] data, ViewAnchor anchor) Add a picture into this sheet with raw picture data and format.voidAdd a new tablevoidClear auto filter if there is.voidclearCell(int rowIdx, int columnIdx, int lastRowIdx, int lastColumnIdx) voidclearCell(CellRegion region) Clear cells in specified regioncreateAutoFilter(CellRegion region) Creates a new auto filter, the old one will be drop directly.voidDelete 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) 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 indexReturns all cell regions of array formula in the given sheetgetAttribute(String name) Get the runtime custom attribute that stored in this sheetGet the unmodifiable runtime attributes mapGets the auto filter information if there is.getBook()Get the owner bookgetCell(int rowIdx, int columnIdx) This method always returns not-null cell object.getCellIterator(int row) Returns the cell regin if the given cell is in an array formula.getChart(int idx) getChartByName(String name) Returns the first chart with specific namegetChartsByName(String name) Returns the charts with specific namegetColumn(int columnIdx) getColumnArray(int columnIdx) Returns the conditional formatting applied to this sheet.getContainsMergedRegions(CellRegion region) Get the merged region that are contained by region.Returns the region which contains data(including chart, picture, and fills) in this sheet; return null if empty sheet.getDataValidation(int idx) getDataValidation(int row, int column) intintintgetEndCellIndex(int rowIdx) intintshortInternal Use only.getId()getMergedRegion(int idx) getMergedRegion(int row, int column) getMergedRegion(String cellRefString) intintintintintReturns the maximum outline level for column represent.intReturns the maximum outline level for row represent.getOverlapsMergedRegions(CellRegion region, boolean excludeContains) Get the merged region that overlapped the regiongetPicture(int idx) getPicture(String picid) getRow(int rowIdx) getRowIterator(int start, int end) Get the sheet nameGets enhanced protection.Get the sheet current visible state.intgetStartCellIndex(int rowIdx) intintGet tables in this sheetvoidinsertCell(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 indexbooleanReturns whether to apply the styles in outline.booleanCheck if the sheet is protectedbooleanReturns whether to display outline symbols.booleanReturns whether to display summary below in outline for rows.booleanReturns 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.pasteCell(SheetRegion src, CellRegion dest, PasteOption option) paste cell from src sheet to this sheet, the sheets must in same bookremoveArrayFormula(SCell cell) Remove an Array Formula from this sheet.booleanremoveCellRegionValueChangeListener(CellRegion cellRegion) Remove all cell region value change listeners of specific cell region.booleanRemove the cell region value change listener.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.setArrayFormula(String formula, CellRegion region) Sets array formula to specified region for result.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.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.voidSet 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 colorsetupColumnArray(int colunmIdx, int lastColumnIdx) Set up a column array, if one array range overlaps another, it throws IllegalStateException.
-
Method Details
-
getBook
SBook getBook()Get the owner book- Returns:
- the owner book
-
getSheetName
String getSheetName()Get the sheet name- Returns:
- the sheet name
-
getRowIterator
- Returns:
- an iterator of existing rows excluding those blank rows
-
getRowIterator
- Parameters:
start- the start indexend- the end index- Returns:
- an iterator of existing rows excluding those blank rows
- Since:
- 5.0.0
-
getColumnIterator
- Returns:
- an iterator of existing columns excluding those blank columns
-
getColumnArrayIterator
Iterator<SColumnArray> getColumnArrayIterator() -
setupColumnArray
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
-
getCellIterator
-
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
-
getColumnArray
- See Also:
-
getColumn
-
getCell
This method always returns not-null cell object. UseSCell.isNull()to know it's null (blank) or not. -
getCell
- Returns:
- return a cell with specified cell reference, e.g. A2, B3. Area reference, A1:A2, is not acceptable.
- See Also:
-
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
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
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
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
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:
-
addPicture
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
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
-
getPicture
-
deletePicture
-
getNumOfPicture
int getNumOfPicture() -
getPicture
-
getPictures
-
addChart
-
getChart
-
deleteChart
-
getNumOfChart
int getNumOfChart() -
getChart
-
getCharts
-
getMergedRegions
List<CellRegion> getMergedRegions() -
removeMergedRegion
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
Add a merged area, you can't assign a area that overlaps existed merged area.- Parameters:
region-
-
getNumOfMergedRegion
int getNumOfMergedRegion() -
getMergedRegion
-
getOverlapsMergedRegions
Get the merged region that overlapped the region- Returns:
- the regions that overlaps
-
getContainsMergedRegions
Get the merged region that are contained by region.- Returns:
- the regions that are contained
-
getMergedRegion
-
getMergedRegion
-
addDataValidation
-
addDataValidation
-
getDataValidation
-
deleteDataValidation
-
getNumOfDataValidation
int getNumOfDataValidation() -
getDataValidation
-
getDataValidations
List<SDataValidation> getDataValidations() -
deleteDataValidationRegion
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
- Parameters:
row-column-- Returns:
- the first data validation at row, column
-
getAttribute
Get the runtime custom attribute that stored in this sheet- Parameters:
name- the attribute name- Returns:
- the value, or null if not found
-
setAttribute
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
Get the unmodifiable runtime attributes map- Returns:
-
isProtected
boolean isProtected()Check if the sheet is protected- Returns:
-
setPassword
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
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
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
Set the sheet current visible state.- Since:
- 3.7.0
-
addTable
Add a new table- Parameters:
table-- Since:
- 3.8.0
-
getTables
Get tables in this sheet- Returns:
- Since:
- 3.8.0
-
removeTable
Remove the table of the specified table name.- Parameters:
tableName-- Since:
- 3.8.0
-
setHashValue
New way of hashing sheet protection password.- Parameters:
hashValue-- Since:
- 3.8.1
-
setSpinCount
New way of hashing sheet protection password.- Parameters:
spinCount-- Since:
- 3.8.1
-
setSaltValue
New way of hashing sheet protection password.- Parameters:
saltValue-- Since:
- 3.8.1
-
setAlgName
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
Set sheet tab color- Since:
- 5.2.0
-
getTabColor
String getTabColor()- Returns:
- sheet tab color
- Since:
- 5.2.0
-
setArrayFormula
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
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
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
-
addCellRegionValueChangeListener
void addCellRegionValueChangeListener(CellRegion cellRegion, SerializableConsumer<CellRegion> listener) Adds the listener when specific cell region value change.- Parameters:
cellRegion-listener-- Since:
- 6.2.0
-
removeCellRegionValueChangeListener
Remove all cell region value change listeners of specific cell region.- Parameters:
cellRegion-- Returns:
- whether the listeners are removed successfully.
- Since:
- 6.2.0
-
removeCellRegionValueChangeListener
Remove the cell region value change listener.- Parameters:
listener-- Returns:
- whether the listener is removed successfully.
- Since:
- 6.2.0
-
addChart
Add a chart with name, type and anchor- Parameters:
name-type-anchor-- Returns:
- the created chart
- Since:
- 6.2.0
-
getChartByName
Returns the first chart with specific name- Parameters:
name-- Returns:
- the chart with specific name
- Since:
- 6.2.0
-
getChartsByName
Returns the charts with specific name- Parameters:
name-- Returns:
- the charts with specific name
- Since:
- 6.2.0
-