Package io.keikai.api.impl
Class RangeImpl
java.lang.Object
io.keikai.api.impl.RangeImpl
- All Implemented Interfaces:
Range,Serializable
1.Range does not handle the protection issue. By calling
isSheetProtected() and getSheetProtection(), you can handle
it easily.- Since:
- 3.0.0
- Author:
- dennis
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.keikai.api.Range
Range.ApplyBorderType, Range.AutoFillType, Range.AutoFilterOperation, Range.CellAttribute, Range.CellStyleHelper, Range.DeleteShift, Range.InsertCopyOrigin, Range.InsertShift, Range.PasteOperation, Range.PasteType, Range.SheetVisible, Range.SortDataOption -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddChart(SheetAnchor anchor, Chart.Type type, Chart.Grouping grouping, Chart.LegendPosition pos) Adds chart to sheetaddChart(String name, SheetAnchor anchor, Chart.Type type, Chart.Grouping grouping, Chart.LegendPosition pos) Adds chart to sheetaddPicture(SheetAnchor anchor, byte[] image, Picture.Format format) Adds picture to sheetvoidre-apply existing criteria of filtersvoidapplyBorders(Range.ApplyBorderType type, CellStyle.BorderType borderType, String htmlColor) apply bordersvoidapplyBordersAround(CellStyle.BorderType borderType, String htmlColor) asString()get formatted string of this rangevoidautoFill(Range dest, Range.AutoFillType fillType) According to current range, fills data to destination range automaticallyvoidclearAll()Clears contents, styles and unmerge this range.voidClears contentsvoidClears all outline level for all groups that intersect with the range.voidClears stylesvoidClears the current tracing.cloneSheet(String name) Clone this sheet; create a sheet and copy the contents of this sheet; then add it as the last sheet.cloneSheetFrom(String name, Sheet sheet) Clone from the specified source sheet to the owner book of this range.cloneSheetFrom(String name, Sheet sheet, boolean valueOnly) Clone from the specified source sheet to the owner book of this range.voidcollapse()Collapses one group by matching with the range at a time (not affected its descendant).voidcreateName(String nameName) Create a name that refers to this range.createSheet(String name) Creates a new sheet and appends it as the last sheet.voiddelete(Range.DeleteShift shift) Delete cells of the range.voiddeleteChart(Chart chart) Deletes chartvoiddeletePicture(Picture picture) Deletes picture that in sheetvoidDeletes sheet.voidDelete theValidationassociated in the specified range.voidenableAutoFilter(boolean enable) enable/disable autofilter of the sheetvoidenableAutoFilter(int field, Range.AutoFilterOperation filterOp, Object criteria1, Object criteria2, Boolean showButton) enable filter with conditionbooleanvoidexpand()Expands one group by matching with the range at a time (not affected its descendant).voidfillDown()Fills cells by copying from first/top row datavoidfillLeft()Fills cells by copying from last/right column datavoidFills cells by copying from first/left column datavoidfillUp()Fills cells by copying from bottom row dataTo find a range of cells for applying auto filter according to this range.getBook()Gets the book of this rangeGets the first cell(top-left) data of this rangeGets the first cell(top-left) format of this rangeGets the first cell(top-left) edit text of this rangeGets the first cell(top-left) formatted text of this rangeGets the first cell(top-left)Hyperlinkobject of this range.Returns text in html format; null if not a rich text.get the first cell style of this rangeGets cell-style-helper, this helper helps you to create new style, font or colorGets the first cell(top-left) value of this rangeGets all cell values from left to right and top to bottom of this range in one dimensional list.intGets the left column of this rangeintGets the column count of this rangeReturns all group ranges for columns, which intersect with this range.getColumnGroups(int outlineLevel) Returns all group ranges matched the given outline level for columns, which intersect with this range.getColumnGroups(int fromOutlineLevel, int toOutlineLevel) Returns all group ranges matched between fromOutlineLevel and toOutlineLevel for columns, which intersect with this range.Return the comment rich edit text of the left top cell of this Range.Returns the region which contains data(including chart, picture, and fills) in the sheet of this Range; return null if empty sheet.Returns all Range(s) that are the direct or indirect dependents of this cell Range.Returns Range(s) that are the direct dependents of this cell Range.Returns Range(s) that are the direct precedents of this cell Range.Get internal range implementationintGets the right/last column of this rangeintGets the bottom/last row of this rangeget the top-left cell range of this rangegetLock()Returns the merged region of the left top cell of this Range if any; otherwise, returns null if not a merged region.getOrCreateFont(Font.Boldweight boldweight, Color color, int fontHeight, String fontName, boolean italic, boolean strikeout, Font.TypeOffset typeOffset, Font.Underline underline) Get font if exists or create font if not exists from the book of this range and return it.intReturns the outline of the group by matching with the range.Returns all Range(s) that are the direct or indirect precedents of this cell Range.intgetRow()Gets the top row of this rangeintGets the row count of this rangeReturns all group ranges for rows, which intersect with this range.getRowGroups(int outlineLevel) Returns all group ranges matched the given outline level for rows, which intersect with this range.getRowGroups(int fromOutlineLevel, int toOutlineLevel) Returns all group ranges matched between fromOutlineLevel and toOutlineLevel for rows, which intersect with this range.getSheet()Gets the sheet of this rangeGets the sheet nameintGets the sheet orderGetsSheetProtectionwhich tells what are allowed operations for a protected sheet of this range.Gets read-onlyValidationassociated with the left-top cell of this range; return null if no associated validation.voidgroup()Groups the rows or columns by matching the range, which increases their outline level.inthashCode()booleanvoidinsert(Range.InsertShift shift, Range.InsertCopyOrigin copyOrigin) Insert new cells to the area of this range.
To insert a row, you have to callRange.toRowRange()first, to insert a column, you have to callRange.toColumnRange()first.booleanbooleancheck if auto filter is enable or not.booleanReturns whether the group by matching with the range has collapsed or not.booleanReturns whether the comment is always visible at the left top cell of this range; if no comment at the cell, it returns false.booleanbooleanbooleanbooleanbooleanReturns whether to display group summary as below for rows.booleanReturns whether to display group summary as right for columns.booleanCheck if this range represents a whole column, which mean all rows are included,booleanCheck if this range represents a whole row, which mean all column are included,booleanCheck if this range represents a whole sheet, which mean all column and row are included,voidmerge(boolean across) Merges the rangevoidmoveChart(SheetAnchor anchor, Chart chart) Moves chart to new locationvoidmovePicture(SheetAnchor anchor, Picture picture) Moves pictureReturns a n-order cell range stream which treats a merged cell as one range.voidNotify this range has been changed, then spreadsheet will render the changed cells to a browser.voidnotifyChange(Range.CellAttribute cellAttr) Notify this range has been changed on the specifield attribute.voidnotifyChange(String[] variables) Notify the whole book of specified variables change.Pastes to destination.Cut and paste to destination.pasteSpecial(Range dest, Range.PasteType type, Range.PasteOperation op, boolean skipBlanks, boolean transpose) Pastes to destination.voidprotectSheet(SheetProtection protection) Protect aSheetso that it cannot be modified.voidprotectSheet(String password, boolean allowSelectingLockedCells, boolean allowSelectingUnlockedCells, boolean allowFormattingCells, boolean allowFormattingColumns, boolean allowFormattingRows, boolean allowInsertColumns, boolean allowInsertRows, boolean allowInsertingHyperlinks, boolean allowDeletingColumns, boolean allowDeletingRows, boolean allowSorting, boolean allowFiltering, boolean allowUsingPivotTables, boolean drawingObjects, boolean scenarios) Protect aSheetso that it cannot be modified.voidrefresh(boolean includeDependants) Enforce evaluation(if not cached) and refresh UI of this range and its dependent cells if the includeDependents is true.voidrefresh(boolean includeDependants, boolean clearCache, boolean enforceEval) Update data model and refresh UI of this range and its dependent cells if the argument includeDependents is true.voidclear criteria of all filters, show all the datavoidsetArrayFormula(String editText) Works like a user entering an array formula in a cell or a range via a browser.booleansetAutoRefresh(boolean auto) Turn on(true)/off(false) of auto refresh of this range and return previous on/off status; default is true.voidsetCellEditText(String editText) Works like a user entering a text in a cell via a browser.voidsetCellHyperlink(Hyperlink.HyperlinkType type, String address, String display) Sets cell hyperlink, applies it too all cellsvoidsetCellRichText(String html) Set into the left top cell of this Range the specified text in html format.voidsetCellStyle(CellStyle nstyle) Sets cell style, applies it to all cells of this rangevoidsetCellValue(Object value) Sets cell data value and type.voidsetCellValues(Object... values) Sets cell data values, applies them to all cells from left to right and top to bottom consistently.voidsetColumnWidth(int widthPx) Sets the width (in pixels) of the columns in this range.voidsetCommentRichText(String html) Set comment rich text into the left top cell of this range; null to delete it.voidsetCommentVisible(boolean visible) Set comment visibility into the left top cell of this range; if no comment at the cell, it simply ignored.voidsetDisplaySheetGridlines(boolean enable) Displays sheet grid-lines or notvoidsetFreezePanel(int rowfreeze, int columnfreeze) Set the freeze panelvoidsetHidden(boolean hidden) Hide or unhide rows or columns.
To hide/unhide a row, you have to callRange.toRowRange()first, to hide/un-hide a column, you have to callRange.toColumnRange()or a whole column range.voidsetNameName(String namename, String newname) Set(Rename) the name of the Name(or Table) as specified in this Range(a Book or a Sheet).voidsetRowHeight(int heightPx) Sets the height(in pixel) of row in this range, it effect to whole row.voidsetRowHeight(int heightPx, boolean isCustom) Sets the height(in pixel) of row in this range and specify it's custom size or not.voidsetSheetName(String name) Sets the sheet namevoidsetSheetOrder(int pos) Sets the sheet ordervoidsetSheetVisible(Range.SheetVisible visible) Setup sheet's visibility; can be VISIBLE, HIDDEN, or VERY_HIDDEN.voidsetStringValue(String text) Save the specified value into this range as a String no matter the value is prefixed with '=' or not.voidsetSummaryBelow(boolean summaryBelow) Sets to be true to display summary group as below or to be false to display summary group as above for rows.voidsetSummaryRight(boolean summaryRight) Sets to be true to display summary group as right or to be false to display summary group as left for columns.voidsetValidation(Validation.ValidationType validationType, boolean ignoreBlank, Validation.OperatorType operatorType, boolean inCellDropDown, String formula1, String formula2, boolean showInput, String inputTitle, String inputMessage, boolean showError, Validation.AlertStyle alertStyle, String errorTitle, String errorMessage) Add if not exist or modify an existingValidationto this range.voidshift(int rowOffset, int colOffset) shift this range with a offset row and columnvoidsort(boolean desc) Sort rangevoidsort(boolean desc, boolean hasHeader, boolean matchCase, boolean sortByRows, Range.SortDataOption dataOption) Sort rangevoidsort(Range key1, boolean desc1, Range.SortDataOption dataOption1, Range key2, boolean desc2, Range.SortDataOption dataOption2, Range key3, boolean desc3, Range.SortDataOption dataOption3, boolean header, boolean matchCase, boolean sortByRows) Sort rangevoidsync(RangeRunner run) Runs runer under synchronization protectiontoCellRange(int rowOffset, int colOffset) Returns a new range having one cell according to the offset based on the left-top corner.Return a range that represents all rows and between the first-column and last-column of this rangeReturn a range that represents all columns and between the first-row and last-row of this rangetoShiftedRange(int rowOffset, int colOffset) Return a new range by shifting the current Range according to the offsets but still keep the original height and width e.g.toString()voidTrace the dependents of this range.voidTrace the precedents of this range.voidungroup()Ungroups the rows or columns by matching the range, which decreases their outline level.voidunmerge()Unmerge the rangebooleanunprotectSheet(String password) Removes protection from a sheet.voidupdateChart(Chart chart) Notify the component that a chart has change, e.g.voidupdateChart(Chart chart, SheetAnchor.AnchorType anchorType) Notify the component that a chart has change, e.g.voidupdatePicture(Picture picture, SheetAnchor.AnchorType anchorType) Updates picture with anchor typevalidate the user's input.voidvisit(CellVisitor visitor) visit all cells in this range, make sure you call this in a limited range, don't use it for all row/column selection, it will spend much time to iterate the cellReturns a z-order cell range stream which treats a merged cell as one range.
-
Constructor Details
-
RangeImpl
-
RangeImpl
-
-
Method Details
-
getLock
-
getCellStyleHelper
Description copied from interface:RangeGets cell-style-helper, this helper helps you to create new style, font or color- Specified by:
getCellStyleHelperin interfaceRange- Returns:
-
getCellData
Description copied from interface:RangeGets the first cell(top-left) data of this range- Specified by:
getCellDatain interfaceRange- Returns:
-
getNative
-
hashCode
public int hashCode() -
equals
-
isProtected
public boolean isProtected()- Specified by:
isProtectedin interfaceRange- Returns:
- true if the specified range is protected; i.e. sheet is protected and some cells in the range are locked
-
isSheetProtected
public boolean isSheetProtected()- Specified by:
isSheetProtectedin interfaceRange- Returns:
- true if the sheet is protected
-
isAnyCellProtected
public boolean isAnyCellProtected() -
paste
Description copied from interface:RangeCut and paste to destination. Support pasting cells among 2 books. -
paste
Description copied from interface:RangePastes to destination. Support pasting cells among 2 books. -
pasteSpecial
public Range pasteSpecial(Range dest, Range.PasteType type, Range.PasteOperation op, boolean skipBlanks, boolean transpose) Description copied from interface:RangePastes to destination. Support pasting cells among 2 books.- Specified by:
pasteSpecialin interfaceRange- Parameters:
dest- the destination. It can be a range of a different book.type- the paste typeop- the paste operationskipBlanks- skip blanks or nottranspose- transpose the cell or not- Returns:
- a Range contains the final pasted range. paste to a protected sheet will always cause paste return null.
-
clearContents
public void clearContents()Description copied from interface:RangeClears contents- Specified by:
clearContentsin interfaceRange
-
clearAll
public void clearAll()Description copied from interface:RangeClears contents, styles and unmerge this range. -
getSheet
Description copied from interface:RangeGets the sheet of this range -
clearStyles
public void clearStyles()Description copied from interface:RangeClears styles- Specified by:
clearStylesin interfaceRange
-
setCellStyle
Description copied from interface:RangeSets cell style, applies it to all cells of this range- Specified by:
setCellStylein interfaceRange- Parameters:
nstyle- new cell style- See Also:
-
getColumn
public int getColumn()Description copied from interface:RangeGets the left column of this range -
getRow
public int getRow()Description copied from interface:RangeGets the top row of this range -
getLastColumn
public int getLastColumn()Description copied from interface:RangeGets the right/last column of this range- Specified by:
getLastColumnin interfaceRange- Returns:
-
getLastRow
public int getLastRow()Description copied from interface:RangeGets the bottom/last row of this range- Specified by:
getLastRowin interfaceRange- Returns:
-
sync
Description copied from interface:RangeRuns runer under synchronization protection -
visit
visit all cells in this range, make sure you call this in a limited range, don't use it for all row/column selection, it will spend much time to iterate the cell -
getBook
Description copied from interface:RangeGets the book of this range -
applyBordersAround
-
applyBorders
public void applyBorders(Range.ApplyBorderType type, CellStyle.BorderType borderType, String htmlColor) Description copied from interface:Rangeapply borders- Specified by:
applyBordersin interfaceRange- Parameters:
type- the apply typeborderType- the border typehtmlColor- the color (#rgb-hex-code, e.x #FF00FF)
-
hasMergedCell
public boolean hasMergedCell()- Specified by:
hasMergedCellin interfaceRange- Returns:
- true if any merged cell inside (fully contains or overlaps) this range
-
isMergedCell
public boolean isMergedCell()- Specified by:
isMergedCellin interfaceRange- Returns:
- true if entire range is a merged cell.
-
getMergedRegion
Description copied from interface:RangeReturns the merged region of the left top cell of this Range if any; otherwise, returns null if not a merged region.- Specified by:
getMergedRegionin interfaceRange- Returns:
- the merged region of the left top cell of this Range if any
-
getDataRegion
Description copied from interface:RangeReturns the region which contains data(including chart, picture, and fills) in the sheet of this Range; return null if empty sheet.- Specified by:
getDataRegionin interfaceRange- Returns:
- the region which contains data(including chart, picture, and fills) in the sheet of this Range; return null if empty sheet.
-
merge
public void merge(boolean across) Description copied from interface:RangeMerges the range -
unmerge
public void unmerge()Description copied from interface:RangeUnmerge the range -
toShiftedRange
Description copied from interface:RangeReturn a new range by shifting the current Range according to the offsets but still keep the original height and width e.g.// range is A1:B2 range.toShiftedRange(1, 0); //returns A2:B3- Specified by:
toShiftedRangein interfaceRange- Parameters:
rowOffset- row offset of the new range. Positive number shifts it down, negative number shifts it up.colOffset- column offset of the new range. Positive number shifts it right, negative number shifts it left.- Returns:
- the new shifted range
-
toCellRange
Description copied from interface:RangeReturns a new range having one cell according to the offset based on the left-top corner. For example://range is A1:B2 range.toCellRange(0, 0); // returns A1- Specified by:
toCellRangein interfaceRange- Parameters:
rowOffset- row offset of the cell.colOffset- column offset of the cell.- Returns:
- the new range of the cell
-
getLeftTop
get the top-left cell range of this range -
toRowRange
Return a range that represents all columns and between the first-row and last-row of this range- Specified by:
toRowRangein interfaceRange
-
toColumnRange
Return a range that represents all rows and between the first-column and last-column of this range- Specified by:
toColumnRangein interfaceRange
-
isWholeColumn
public boolean isWholeColumn()Check if this range represents a whole column, which mean all rows are included,- Specified by:
isWholeColumnin interfaceRange
-
isWholeRow
public boolean isWholeRow()Check if this range represents a whole row, which mean all column are included,- Specified by:
isWholeRowin interfaceRange
-
isWholeSheet
public boolean isWholeSheet()Check if this range represents a whole sheet, which mean all column and row are included,- Specified by:
isWholeSheetin interfaceRange
-
insert
Description copied from interface:RangeInsert new cells to the area of this range.
To insert a row, you have to callRange.toRowRange()first, to insert a column, you have to callRange.toColumnRange()first. -
delete
Description copied from interface:RangeDelete cells of the range.
To delete a row, you have to callRange.toRowRange()first, to delete a column, you have to callRange.toColumnRange()first. -
sort
public void sort(boolean desc) Description copied from interface:RangeSort range -
sort
public void sort(boolean desc, boolean hasHeader, boolean matchCase, boolean sortByRows, Range.SortDataOption dataOption) Description copied from interface:RangeSort range -
sort
public void sort(Range key1, boolean desc1, Range.SortDataOption dataOption1, Range key2, boolean desc2, Range.SortDataOption dataOption2, Range key3, boolean desc3, Range.SortDataOption dataOption3, boolean header, boolean matchCase, boolean sortByRows) Description copied from interface:RangeSort range- Specified by:
sortin interfaceRange- Parameters:
key1- the sort index 1desc1- true for descent, false for ascent of index 1dataOption1- data option 1 for sortkey2- the sort index 2desc2- true for descent, false for ascent of index 2dataOption2- data option 2 for sortkey3- the sort index 3desc3- true for descent, false for ascent of index 3dataOption3- data option31 for sortheader- includes header or notmatchCase- matches character chase of notsortByRows- sorts by row or not
-
isAutoFilterEnabled
public boolean isAutoFilterEnabled()check if auto filter is enable or not.- Specified by:
isAutoFilterEnabledin interfaceRange- Returns:
- true if auto filter is enabled.
-
findAutoFilterRange
Description copied from interface:RangeTo find a range of cells for applying auto filter according to this range. Usually, these two ranges are different. This method searches the filtering range through a specific rules.- Specified by:
findAutoFilterRangein interfaceRange- Returns:
- a range of cells for applying auto filter or null if can't find one from this Range.
-
enableAutoFilter
public void enableAutoFilter(boolean enable) enable/disable autofilter of the sheet- Specified by:
enableAutoFilterin interfaceRange- Parameters:
enable- true to enable
-
enableAutoFilter
public void enableAutoFilter(int field, Range.AutoFilterOperation filterOp, Object criteria1, Object criteria2, Boolean showButton) enable filter with condition- Specified by:
enableAutoFilterin interfaceRange- Parameters:
field- the filed index (according to current range, 1 base)filterOp- auto filter operationcriteria1- criteria for autofiltercriteria2- criteria for autofiltershowButton- true/false for show/hide dropdown button, null will keep the original setting.
-
resetAutoFilter
public void resetAutoFilter()clear criteria of all filters, show all the data- Specified by:
resetAutoFilterin interfaceRange
-
applyAutoFilter
public void applyAutoFilter()re-apply existing criteria of filters- Specified by:
applyAutoFilterin interfaceRange
-
autoFill
Description copied from interface:RangeAccording to current range, fills data to destination range automatically -
fillDown
public void fillDown()Description copied from interface:RangeFills cells by copying from first/top row data -
fillLeft
public void fillLeft()Description copied from interface:RangeFills cells by copying from last/right column data -
fillUp
public void fillUp()Description copied from interface:RangeFills cells by copying from bottom row data -
fillRight
public void fillRight()Description copied from interface:RangeFills cells by copying from first/left column data -
shift
public void shift(int rowOffset, int colOffset) shift this range with a offset row and column -
getCellEditText
Description copied from interface:RangeGets the first cell(top-left) edit text of this range- Specified by:
getCellEditTextin interfaceRange- Returns:
- edit text
- See Also:
-
setCellEditText
Description copied from interface:RangeWorks like a user entering a text in a cell via a browser. So, this method supports "Smart Input", and it will parse the text and turn the text into a String, Number, Date, or Boolean according to the supported input format pattern. To enter a formula, the text should stat with=.
This method applies all cells of this range.- Specified by:
setCellEditTextin interfaceRange- Parameters:
editText- the text to enter, it can be a string, integer string, date string or a formula (start with '=')
-
setArrayFormula
Description copied from interface:RangeWorks like a user entering an array formula in a cell or a range via a browser. So, this method supports "Smart Input", and it will parse the text and turn the text into a String, Number, Date, or Boolean according to the supported input format pattern. To enter a formula, the text should stat with=.
This method applies all cells of this range.- Specified by:
setArrayFormulain interfaceRange- Parameters:
editText- the text to enter, it can be a string, integer string, date string or a formula (start with '=')
-
getCellFormatText
Description copied from interface:RangeGets the first cell(top-left) formatted text of this range- Specified by:
getCellFormatTextin interfaceRange- Returns:
- format text
- See Also:
-
getCellDataFormat
Description copied from interface:RangeGets the first cell(top-left) format of this range- Specified by:
getCellDataFormatin interfaceRange- Returns:
-
getCellValue
Description copied from interface:RangeGets the first cell(top-left) value of this range- Specified by:
getCellValuein interfaceRange- Returns:
- value object or null for a blank cell
- See Also:
-
getCellValues
Description copied from interface:RangeGets all cell values from left to right and top to bottom of this range in one dimensional list. Blank cell will be null value instead.
If the range is A1:C3, the method will return you a list of cell values like:
A1, B1, C1, A2, B2, C2, A3, B3, C3- Specified by:
getCellValuesin interfaceRange- Returns:
- values a object list
-
setDisplaySheetGridlines
public void setDisplaySheetGridlines(boolean enable) Description copied from interface:RangeDisplays sheet grid-lines or not- Specified by:
setDisplaySheetGridlinesin interfaceRange- Parameters:
enable- true to display
-
isDisplaySheetGridlines
public boolean isDisplaySheetGridlines()- Specified by:
isDisplaySheetGridlinesin interfaceRange- Returns:
- true if display sheet grid-lines is enabled
-
setHidden
public void setHidden(boolean hidden) Description copied from interface:RangeHide or unhide rows or columns.
To hide/unhide a row, you have to callRange.toRowRange()first, to hide/un-hide a column, you have to callRange.toColumnRange()or a whole column range. -
setCellHyperlink
Description copied from interface:RangeSets cell hyperlink, applies it too all cells- Specified by:
setCellHyperlinkin interfaceRange- Parameters:
type- the hyperlink typeaddress- the address, e.x http://www.zkoss.orgdisplay- the label to display
-
getCellHyperlink
Description copied from interface:RangeGets the first cell(top-left)Hyperlinkobject of this range.- Specified by:
getCellHyperlinkin interfaceRange- Returns:
-
setSheetName
Description copied from interface:RangeSets the sheet name- Specified by:
setSheetNamein interfaceRange- Parameters:
name- new sheet name, it must be not same as another sheet name in it's owner book.
-
getSheetName
Description copied from interface:RangeGets the sheet name- Specified by:
getSheetNamein interfaceRange- Returns:
- sheet name
-
setSheetOrder
public void setSheetOrder(int pos) Description copied from interface:RangeSets the sheet order- Specified by:
setSheetOrderin interfaceRange- Parameters:
pos- the position
-
getSheetOrder
public int getSheetOrder()Description copied from interface:RangeGets the sheet order- Specified by:
getSheetOrderin interfaceRange- Returns:
-
setCellValue
Description copied from interface:RangeSets cell data value and type. Notice that it doesn't parse the specified String object. If you call:setCellValue("100"), it will produce a text cell instead of an integer, one hundred. If you need a number cell, you need to callsetCellValue(100). The same rule applies to Date and Boolean.
This method applies all cells of this range.- Specified by:
setCellValuein interfaceRange- Parameters:
value- the cell value, could be null, String, Number, Date or Boolean- See Also:
-
setCellValues
Description copied from interface:RangeSets cell data values, applies them to all cells from left to right and top to bottom consistently. For example:Set values in a row
The result is [3,2,1] from A1 to C1Range rA1C1 = Ranges.range("A1:C1"); rA1C1.setCellValues(3,2,1);Set values in a column
The result is [1,2,3] from A1 to A3Range rA1A3 = Ranges.range("A1:A3"); rA1A3.setCellValues(1,2,3);
Set values in an area
The result is [9, 8, 7, 6, 5, 4, 3, 2, 1] from A1, B1, C1, A2, ... to C3Range rA1C3 = Ranges.range("A1:C3"); rA1C3.setCellValues(9, 8, 7, 6, 5, 4, 3,2,1);
Cell and values count mismatch
If you pass more values than cell number, then it just sets cells in this range, not over-fill.
The result is [1,2,3] from A1 to C1.rA1C1.setCellValues(1, 2, 3, 4, 5);
If you pass fewer values than cell number, then it just set cells according the number of values.
The result is [1,2] from A1 to B1.rA1C1.setCellValues(1, 2);
Transpose 2D Array when necessary
Since this method sets cells row by row, if you have a 2D array that contains column by column data. Then you can transpose the array first and pass to the method.- Specified by:
setCellValuesin interfaceRange- Parameters:
values- all cell values, could be null, String, Number, Date or Boolean
-
getCellStyle
get the first cell style of this range- Specified by:
getCellStylein interfaceRange- Returns:
- cell style if cell is exist, the check row style and column cell style if cell not found, if row and column style is not exist, then return default style of sheet
-
addPicture
Description copied from interface:RangeAdds picture to sheet- Specified by:
addPicturein interfaceRange- Parameters:
anchor- the anchor for pictureimage- the image binary arrayformat- the image format- Returns:
- the new added picture
-
deletePicture
Description copied from interface:RangeDeletes picture that in sheet- Specified by:
deletePicturein interfaceRange
-
movePicture
Description copied from interface:RangeMoves picture- Specified by:
movePicturein interfaceRange- Parameters:
anchor- the anchor to re-allocatepicture- the picture to re-allocate
-
updatePicture
Description copied from interface:RangeUpdates picture with anchor type- Specified by:
updatePicturein interfaceRange
-
addChart
public Chart addChart(SheetAnchor anchor, Chart.Type type, Chart.Grouping grouping, Chart.LegendPosition pos) Description copied from interface:RangeAdds chart to sheet -
addChart
public Chart addChart(String name, SheetAnchor anchor, Chart.Type type, Chart.Grouping grouping, Chart.LegendPosition pos) Description copied from interface:RangeAdds chart to sheet -
deleteChart
Description copied from interface:RangeDeletes chart- Specified by:
deleteChartin interfaceRange- Parameters:
chart- the chart to delete
-
moveChart
Description copied from interface:RangeMoves chart to new location -
updateChart
Description copied from interface:RangeNotify the component that a chart has change, e.g. call it after chart data changes.- Specified by:
updateChartin interfaceRange- Parameters:
chart- the chart that contains change
-
updateChart
Description copied from interface:RangeNotify the component that a chart has change, e.g. call it after chart data changes.- Specified by:
updateChartin interfaceRange- Parameters:
chart- the chart that contains change
-
createSheet
Description copied from interface:RangeCreates a new sheet and appends it as the last sheet. To move the new sheet to the specific position, seeRange.setSheetOrder(int).- Specified by:
createSheetin interfaceRange- Parameters:
name- the sheet name, it must not be same as another sheet name in book of this range. Otherwise, it takes no effect.- Returns:
- the new created sheet
-
cloneSheet
Description copied from interface:RangeClone this sheet; create a sheet and copy the contents of this sheet; then add it as the last sheet.- Specified by:
cloneSheetin interfaceRange- Parameters:
name- the sheet name, it must not be the same as another sheet name in book of this range- Returns:
- the new created sheet
-
deleteSheet
public void deleteSheet()Description copied from interface:RangeDeletes sheet. Note: You couldn't delete last sheet of a book.- Specified by:
deleteSheetin interfaceRange
-
setColumnWidth
public void setColumnWidth(int widthPx) Description copied from interface:RangeSets the width (in pixels) of the columns in this range.Visibility effect:
- If
widthPxis 0, it hides the columns implicitly. - If
widthPxis a positive value, it unhides the columns automatically. - It affects entire columns even if the range only contains some cells (implicitly calls
Range.toColumnRange()). - The column width will be marked as custom and disables "best fit".
- It may trigger re-refresh of cell contents (e.g., changing displayed number precision).
- Specified by:
setColumnWidthin interfaceRange- Parameters:
widthPx- width in pixels. A value of 0 hides the columns, while a positive value unhides them and sets their width.- See Also:
- If
-
setRowHeight
public void setRowHeight(int heightPx) Description copied from interface:RangeSets the height(in pixel) of row in this range, it effect to whole row.- Specified by:
setRowHeightin interfaceRange- Parameters:
heightPx- height in pixel- See Also:
-
setRowHeight
public void setRowHeight(int heightPx, boolean isCustom) Description copied from interface:RangeSets the height(in pixel) of row in this range and specify it's custom size or not.- Specified by:
setRowHeightin interfaceRange- Parameters:
heightPx- height in pixelisCustom- true if it's set by users manually, false if it's determined by the system automatically
-
group
public void group()Description copied from interface:RangeGroups the rows or columns by matching the range, which increases their outline level.Note: The maximum level is up to 7.
-
ungroup
public void ungroup()Description copied from interface:RangeUngroups the rows or columns by matching the range, which decreases their outline level.Note: The minimum level is down to 0.
-
toString
-
notifyChange
public void notifyChange()Description copied from interface:RangeNotify this range has been changed, then spreadsheet will render the changed cells to a browser. It's usually used withRange.setAutoRefresh(boolean).- Specified by:
notifyChangein interfaceRange
-
notifyChange
Description copied from interface:RangeNotify the whole book of specified variables change. Then spreadsheet will re-evaluate those cells that reference to these variables.- Specified by:
notifyChangein interfaceRange- Parameters:
variables- changed variables
-
setFreezePanel
public void setFreezePanel(int rowfreeze, int columnfreeze) Description copied from interface:RangeSet the freeze panel- Specified by:
setFreezePanelin interfaceRange- Parameters:
rowfreeze- the number of row to freeze, 0 means no freezecolumnfreeze- the number of column to freeze, 0 means no freeze
-
getRowCount
public int getRowCount()Description copied from interface:RangeGets the row count of this range- Specified by:
getRowCountin interfaceRange- Returns:
- count of row of this range
-
getColumnCount
public int getColumnCount()Description copied from interface:RangeGets the column count of this range- Specified by:
getColumnCountin interfaceRange- Returns:
- count of column of this range
-
asString
Description copied from interface:Rangeget formatted string of this range -
getInternalRange
Description copied from interface:RangeGet internal range implementation- Specified by:
getInternalRangein interfaceRange
-
createName
Description copied from interface:RangeCreate a name that refers to this range. You can get this named ranage byRanges.rangeByName(Sheet, String).- Specified by:
createNamein interfaceRange- Parameters:
nameName- name of the range that you can refer in formulas.
-
protectSheet
public void protectSheet(String password, boolean allowSelectingLockedCells, boolean allowSelectingUnlockedCells, boolean allowFormattingCells, boolean allowFormattingColumns, boolean allowFormattingRows, boolean allowInsertColumns, boolean allowInsertRows, boolean allowInsertingHyperlinks, boolean allowDeletingColumns, boolean allowDeletingRows, boolean allowSorting, boolean allowFiltering, boolean allowUsingPivotTables, boolean drawingObjects, boolean scenarios) Description copied from interface:RangeProtect aSheetso that it cannot be modified. You can call this method on a protected sheet to change its allowed options if the same password is supplied; otherwise, it is ignored. A protected sheet can be unprotected by callingRange.unprotectSheet(String password). change the protection options; make sure provide- Specified by:
protectSheetin interfaceRange- Parameters:
password- a case-sensitive password for the sheet; null or empty string means protect the sheet without password.allowSelectingLockedCells- true to allow select locked cells; default to true.allowSelectingUnlockedCells- true to allow select unlocked cells; default to true.allowFormattingCells- true to allow user to format any cell on the protected sheet; default false.allowFormattingColumns- true to allow user to format any columns on the protected sheet; default false.allowFormattingRows- true to allow user to format any rows on the protected sheet; default false.allowInsertColumns- true to allow user to insert columns on the protected sheet; default false.allowInsertRows- true to allow user to insert rows on the protected sheet; default false.allowInsertingHyperlinks- true to allow user to insert hyperlinks on the protected sheet; default false.allowDeletingColumns- true to allow user to delete columns on the protected sheet; default false.allowDeletingRows- true to allow user to delete rows on the protected sheet; default false.allowSorting- true to allow user to sort on the protected sheet; default false.allowFiltering- true to allow user to set filters on the protected sheet; default false.allowUsingPivotTables- true to allow user to use pivot table reports on the protected sheet; default false.drawingObjects- true to protect objects; default to false.scenarios- true to protect scenarios; default to true.- See Also:
-
protectSheet
Description copied from interface:RangeProtect aSheetso that it cannot be modified.- Specified by:
protectSheetin interfaceRange- See Also:
-
unprotectSheet
Description copied from interface:RangeRemoves protection from a sheet. This method has no effect if the sheet isn't protected.- Specified by:
unprotectSheetin interfaceRange- Parameters:
password- a case-sensitive password used to unprotect the sheet. If the sheet isn't protected with a password, this argument is ignored. If you omit this argument for a sheet that is protected with a password, you'll be prompted for the password.
-
getSheetProtection
Description copied from interface:RangeGetsSheetProtectionwhich tells what are allowed operations for a protected sheet of this range.- Specified by:
getSheetProtectionin interfaceRange- Returns:
-
validate
Description copied from interface:Rangevalidate the user's input. -
setValidation
public void setValidation(Validation.ValidationType validationType, boolean ignoreBlank, Validation.OperatorType operatorType, boolean inCellDropDown, String formula1, String formula2, boolean showInput, String inputTitle, String inputMessage, boolean showError, Validation.AlertStyle alertStyle, String errorTitle, String errorMessage) Description copied from interface:RangeAdd if not exist or modify an existingValidationto this range. There are two ways to input list items for data validation in argument "formula1" and "formula2". One is to specify a range via a formula such as "=A1:A4" where the values in the cells of the range is the constrained value list; another is to input literally the constrained value list delimited by comma such as "1, 2, 3, 4". Note that when you input a formula, must lead the formula with an equal sign('=').- Specified by:
setValidationin interfaceRange- Parameters:
validationType- the type of this validationignoreBlank- true if blank values are permitted.operatorType- the operator for this validationinCellDropDown- true if want to display dropdown list for acceptable values.formula1- the value or expression associated with conditional format or data validation.formula2- the 2nd part of a conditional format or data validation. Useful only when operatorType is BETWEEN or NOT_BETWEEN.showInput- true to show the input message.inputTitle- title for the data-validation input dialog box.inputMessage- message for the data-validation input dialog box.showError- true to show the error message.alertStyle- validation alert style.errorTitle- title of the data validation error dialog.errorMessage- data validation error message.
-
getValidations
Description copied from interface:RangeGets read-onlyValidationassociated with the left-top cell of this range; return null if no associated validation. -
deleteValidation
public void deleteValidation()Description copied from interface:RangeDelete theValidationassociated in the specified range.- Specified by:
deleteValidationin interfaceRange
-
setCellRichText
Description copied from interface:RangeSet into the left top cell of this Range the specified text in html format.- Specified by:
setCellRichTextin interfaceRange
-
getCellRichText
Description copied from interface:RangeReturns text in html format; null if not a rich text.- Specified by:
getCellRichTextin interfaceRange
-
getOrCreateFont
public Font getOrCreateFont(Font.Boldweight boldweight, Color color, int fontHeight, String fontName, boolean italic, boolean strikeout, Font.TypeOffset typeOffset, Font.Underline underline) Description copied from interface:RangeGet font if exists or create font if not exists from the book of this range and return it.- Specified by:
getOrCreateFontin interfaceRange- Returns:
- font of the specified font metrics
-
refresh
public void refresh(boolean includeDependants) Description copied from interface:RangeEnforce evaluation(if not cached) and refresh UI of this range and its dependent cells if the includeDependents is true. This method is equal to {@link Range#refresh(boolean includeDependents, boolean false, boolean true)}. -
setAutoRefresh
public boolean setAutoRefresh(boolean auto) Description copied from interface:RangeTurn on(true)/off(false) of auto refresh of this range and return previous on/off status; default is true. If you turn off auto refresh, you need to callRange.notifyChange()manually at the proper moment.- Specified by:
setAutoRefreshin interfaceRange- Parameters:
auto- whether refresh automatically- Returns:
- previous status
-
refresh
public void refresh(boolean includeDependants, boolean clearCache, boolean enforceEval) Description copied from interface:RangeUpdate data model and refresh UI of this range and its dependent cells if the argument includeDependents is true. Note that when you set parameter clearCache to true, the cached formula result in data model will be cleared first. If you set parameter enforceEval to true, data model associated with this range will be evaluated immediately; otherwise will be evaluated on demand. -
setSheetVisible
Description copied from interface:RangeSetup sheet's visibility; can be VISIBLE, HIDDEN, or VERY_HIDDEN.- VISIBLE: the sheet is visible
- HIDDEN: the sheet is hidden but can be unhidden using UI
- VERY_HIDDEN: the sheet is hidden but can be unhidden only via this API.
- Specified by:
setSheetVisiblein interfaceRange- See Also:
-
getCommentRichText
Description copied from interface:RangeReturn the comment rich edit text of the left top cell of this Range.- Specified by:
getCommentRichTextin interfaceRange- Returns:
- the rich edit text of this Range.
-
setCommentRichText
Description copied from interface:RangeSet comment rich text into the left top cell of this range; null to delete it.- Specified by:
setCommentRichTextin interfaceRange
-
setCommentVisible
public void setCommentVisible(boolean visible) Description copied from interface:RangeSet comment visibility into the left top cell of this range; if no comment at the cell, it simply ignored.- Specified by:
setCommentVisiblein interfaceRange
-
isCommentVisible
public boolean isCommentVisible()Description copied from interface:RangeReturns whether the comment is always visible at the left top cell of this range; if no comment at the cell, it returns false.- Specified by:
isCommentVisiblein interfaceRange- Returns:
-
notifyChange
Description copied from interface:RangeNotify this range has been changed on the specifield attribute.- Specified by:
notifyChangein interfaceRange
-
setNameName
Description copied from interface:RangeSet(Rename) the name of the Name(or Table) as specified in this Range(a Book or a Sheet).- Specified by:
setNameNamein interfaceRange- Parameters:
namename- name of the Name(or Table)newname- new name for the Name(or Table)
-
setStringValue
Description copied from interface:RangeSave the specified value into this range as a String no matter the value is prefixed with '=' or not.- Specified by:
setStringValuein interfaceRange
-
cloneSheetFrom
Description copied from interface:RangeClone from the specified source sheet to the owner book of this range. The book can be different between the owner book of this range and of the specified source sheet.- Specified by:
cloneSheetFromin interfaceRange- Parameters:
name- the name of the new created sheet; null would try to use the sheet name of the specified source sheet; if the same sheet name already used in the owner book of this range then use default "SheetX" name where X is the next sheet number of the owner book of this range.sheet- the source sheet to clone from to the owner book of this range.- Returns:
- the new created sheet
- See Also:
-
cloneSheetFrom
Description copied from interface:RangeClone from the specified source sheet to the owner book of this range. The book can be different between the owner book of this range and of the specified source sheet.- Specified by:
cloneSheetFromin interfaceRange- Parameters:
name- the name of the new created sheet; null would try to use the sheet name of the specified source sheet; if the same sheet name already used in the owner book of this range then use default "SheetX" name where X is the next sheet number of the owner book of this range.sheet- the source sheet to clone from to the owner book of this range.valueOnly- true to copy the cell value only- Returns:
- the new created sheet
-
zOrderStream
Description copied from interface:RangeReturns a z-order cell range stream which treats a merged cell as one range. For example,// Data: // | A | B | C | D | E | // ---+---+---+---+---+---+ // 1 | 1 | | 3 | | // ---+---+ +---+---+ // 2 | | | | | // ---+ + + 5 +---+ // 3 | 4 | 2 | | | // ---+ + +---+---+ // 4 | | | 6 | | // ---+---+ +---+---+ // 5 | 7 | | 8 | | // ---+---+-------+---+---+ StreamzOrder = Ranges.range("A1:D5").zOrderStream(); zOrder.map(Range::getCellValue) .map(Object::toString) .collect(Collectors.joining(", ")); // Result: 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0- Specified by:
zOrderStreamin interfaceRange
-
nOrderStream
Description copied from interface:RangeReturns a n-order cell range stream which treats a merged cell as one range. For example,// Data: // | A | B | C | D | E | // ---+---+---+---+---+---+ // 1 | 1 | | 3 | | // ---+---+ +---+---+ // 2 | | | | | // ---+ + + 5 +---+ // 3 | 4 | 2 | | | // ---+ + +---+---+ // 4 | | | 6 | | // ---+---+ +---+---+ // 5 | 7 | | 8 | | // ---+---+-------+---+---+ StreamnOrder = Ranges.range("A1:D5").nOrderStream(); nOrder.map(Range::getCellValue) .map(Object::toString) .collect(Collectors.joining(", ")); // Result: 1.0, 4.0, 7.0, 2.0, 3.0, 5.0, 6.0, 8.0- Specified by:
nOrderStreamin interfaceRange
-
getDirectPrecedents
Description copied from interface:RangeReturns Range(s) that are the direct precedents of this cell Range. If this Range covers more than one cell, the left-top one is used.- Specified by:
getDirectPrecedentsin interfaceRange
-
getPrecedents
Description copied from interface:RangeReturns all Range(s) that are the direct or indirect precedents of this cell Range. If this Range covers more than one cell, the left-top one is used.- Specified by:
getPrecedentsin interfaceRange
-
getDirectDependents
Description copied from interface:RangeReturns Range(s) that are the direct dependents of this cell Range. If this Range covers more than one cell, the left-top one is used.- Specified by:
getDirectDependentsin interfaceRange
-
getDependents
Description copied from interface:RangeReturns all Range(s) that are the direct or indirect dependents of this cell Range. If this Range covers more than one cell, the left-top one is used.- Specified by:
getDependentsin interfaceRange
-
tracePrecedents
public void tracePrecedents()Description copied from interface:RangeTrace the precedents of this range.- Specified by:
tracePrecedentsin interfaceRange
-
traceDependents
public void traceDependents()Description copied from interface:RangeTrace the dependents of this range.- Specified by:
traceDependentsin interfaceRange
-
clearTrace
public void clearTrace()Description copied from interface:RangeClears the current tracing.- Specified by:
clearTracein interfaceRange
-
getRowGroups
Description copied from interface:RangeReturns all group ranges for rows, which intersect with this range.- Specified by:
getRowGroupsin interfaceRange- Returns:
- an empty list if not matched.
-
getRowGroups
Description copied from interface:RangeReturns all group ranges matched the given outline level for rows, which intersect with this range.- Specified by:
getRowGroupsin interfaceRange- Parameters:
outlineLevel- a valid value in a range is from 1 to 7 (inclusive).- Returns:
- an empty list if not matched.
-
getRowGroups
Description copied from interface:RangeReturns all group ranges matched between fromOutlineLevel and toOutlineLevel for rows, which intersect with this range.- Specified by:
getRowGroupsin interfaceRange- Parameters:
fromOutlineLevel- 1~7 (inclusive)toOutlineLevel- 2~8 (exclusive)- Returns:
- an empty list if not matched.
-
getColumnGroups
Description copied from interface:RangeReturns all group ranges for columns, which intersect with this range.- Specified by:
getColumnGroupsin interfaceRange- Returns:
- an empty list if not matched.
-
getColumnGroups
Description copied from interface:RangeReturns all group ranges matched the given outline level for columns, which intersect with this range.- Specified by:
getColumnGroupsin interfaceRange- Parameters:
outlineLevel- a valid value in a range is from 1 to 7 (inclusive).- Returns:
- an empty list if not matched.
-
getColumnGroups
Description copied from interface:RangeReturns all group ranges matched between fromOutlineLevel and toOutlineLevel for columns, which intersect with this range.- Specified by:
getColumnGroupsin interfaceRange- Parameters:
fromOutlineLevel- 1~7 (inclusive)toOutlineLevel- 2~8 (exclusive)- Returns:
- an empty list if not matched.
-
setSummaryBelow
public void setSummaryBelow(boolean summaryBelow) Description copied from interface:RangeSets to be true to display summary group as below or to be false to display summary group as above for rows.Note: One setting to affect whole sheet, if the value is up-side-down against the previous value, it will clear all outline level for rows and columns.
Default:
true- Specified by:
setSummaryBelowin interfaceRange- Parameters:
summaryBelow- true to display as below for rows.
-
isSummaryBelow
public boolean isSummaryBelow()Description copied from interface:RangeReturns whether to display group summary as below for rows.Default:
true- Specified by:
isSummaryBelowin interfaceRange
-
setSummaryRight
public void setSummaryRight(boolean summaryRight) Description copied from interface:RangeSets to be true to display summary group as right or to be false to display summary group as left for columns.Note: One setting to affect whole sheet, if the value is up-side-down against the previous value, it will clear all outline level for rows and columns.
Default:
true- Specified by:
setSummaryRightin interfaceRange- Parameters:
summaryRight- true to display as right for columns.
-
isSummaryRight
public boolean isSummaryRight()Description copied from interface:RangeReturns whether to display group summary as right for columns.Default:
true- Specified by:
isSummaryRightin interfaceRange
-
collapse
public void collapse()Description copied from interface:RangeCollapses one group by matching with the range at a time (not affected its descendant). -
expand
public void expand()Description copied from interface:RangeExpands one group by matching with the range at a time (not affected its descendant). -
clearOutlineLevel
public void clearOutlineLevel()Description copied from interface:RangeClears all outline level for all groups that intersect with the range.2:4for rows andC:Efor columns- Specified by:
clearOutlineLevelin interfaceRange
-
isCollapsed
public boolean isCollapsed()Description copied from interface:RangeReturns whether the group by matching with the range has collapsed or not. Otherwise, returns false instead.- Specified by:
isCollapsedin interfaceRange
-
getOutlineLevel
public int getOutlineLevel()Description copied from interface:RangeReturns the outline of the group by matching with the range. Otherwise, returns 0 instead.- Specified by:
getOutlineLevelin interfaceRange
-