public abstract class AbstractRange extends Object implements com.gembox.spreadsheet.internal.inlinestyles.FormattedStringProvider
Modifier and Type | Method and Description |
---|---|
abstract void |
calculate()
Calculates formula for one or more excel cells.
|
void |
clear(EnumSet<ClearOptions> options)
Clears the range (content, formatting, comment, hyperlink or all).
|
Iterable<FormattedCharacterRange> |
getCharacterRanges()
Returns all
FormattedCharacterRange objects that represents a range of characters within the cell text. |
FormattedCharacterRange |
getCharacters(int startIndex)
Returns a
FormattedCharacterRange object that represents a range of characters within the cell text. |
FormattedCharacterRange |
getCharacters(int startIndex,
int length)
Returns a
FormattedCharacterRange object that represents a range of characters within the cell text. |
abstract ExcelComment |
getComment()
Gets comment.
|
abstract String |
getFormula()
Gets formula string.
|
abstract SpreadsheetHyperlink |
getHyperlink()
Gets hyperlink.
|
String |
getName()
Gets the name of
AbstractRange instance. |
CellStyle |
getStyle()
Gets the cell formatting of one or more cells.
|
abstract Object |
getValue()
Gets cell value on one or more excel cells.
|
abstract void |
insert(InsertShiftDirection direction)
Inserts a range by shifting cells in the specified direction.
|
abstract void |
remove(RemoveShiftDirection direction)
Removes a range by shifting cells in the specified direction.
|
boolean |
replaceText(Pattern pattern,
String replacement)
Replaces all matches of the specified Pattern with specified text in the current
AbstractRange . |
boolean |
replaceText(String oldValue,
String newValue)
Replaces all occurrences of the specified text with another text in the current
AbstractRange . |
boolean |
replaceText(String oldValue,
String newValue,
boolean matchCase)
Replaces all occurrences of the specified text with another text in the current
AbstractRange . |
boolean |
replaceText(String oldValue,
String newValue,
boolean matchCase,
boolean matchEntireCellContents)
Replaces all occurrences of the specified text with another text in the current
AbstractRange . |
abstract void |
setComment(ExcelComment value)
Sets comment.
|
abstract void |
setFormula(String value)
Sets formula string.
|
abstract void |
setHyperlink(SpreadsheetHyperlink value)
Sets hyperlink.
|
void |
setStyle(CellStyle value)
Sets the cell formatting of one or more cells.
|
abstract void |
setValue(Object value)
Gets cell value on one or more excel cells.
|
String |
toString()
Returns a
String that represents this AbstractRange instance. |
public abstract void calculate()
public final void clear(EnumSet<ClearOptions> options)
options
- The clear options.public final Iterable<FormattedCharacterRange> getCharacterRanges()
FormattedCharacterRange
objects that represents a range of characters within the cell text.FormattedCharacterRange
objects that represents a range of characters within the cell text.public final FormattedCharacterRange getCharacters(int startIndex)
FormattedCharacterRange
object that represents a range of characters within the cell text.
The range starts at a specified character position.
Not supported in ODS.
This method only works on cell with string value.
startIndex
- The zero-based starting character position.FormattedCharacterRange
object.IndexOutOfBoundsException
- Argument startIndex
is less than zero or is equal to or greater than 32767.public final FormattedCharacterRange getCharacters(int startIndex, int length)
FormattedCharacterRange
object that represents a range of characters within the cell text.
The range starts at a specified character position and has a specified length.
Not supported in ODS.
This method only works on cell with string value.
getCharacters
in interface com.gembox.spreadsheet.internal.inlinestyles.FormattedStringProvider
startIndex
- The zero-based starting character position.length
- The number of characters.FormattedCharacterRange
object.IndexOutOfBoundsException
- Argument startIndex
is less than zero or is equal to or greater than 32767.IndexOutOfBoundsException
- Argument length
is equal to or less than zero or is greater than 32767.public abstract ExcelComment getComment()
public abstract String getFormula()
public abstract SpreadsheetHyperlink getHyperlink()
public final String getName()
AbstractRange
instance.
A cell name includes its column letter and row number. For example, the name of a cell in row 0 and column 0 is "A1". A cell range name includes the column letter and row number of first (top-left) and last (bottom-right) cell. For example, the name of range [0, 0]...[4, 4] is "A1:E5", of range [0, 0]...[4, MaxColumns-1] is "1:5", of range [0, 0]...[MaxRows-1, 4] is "A:E", of single cell range [4, 4]...[4, 4] is "E5".
public final CellStyle getStyle()
setStyle for more information about styles
,
CellStyle for examples
public abstract Object getValue()
public abstract void insert(InsertShiftDirection direction)
direction
- The shift direction.public abstract void remove(RemoveShiftDirection direction)
direction
- The shift direction.public boolean replaceText(Pattern pattern, String replacement)
AbstractRange
.pattern
- The Regex which should be matched.replacement
- The text which should replace all matches of searched Pattern.true
if text is found, false
otherwise.public final boolean replaceText(String oldValue, String newValue)
AbstractRange
.oldValue
- The text to be replaced.newValue
- The text to replace all occurrences of oldValue
.true
if text is found, false
otherwise.public final boolean replaceText(String oldValue, String newValue, boolean matchCase)
AbstractRange
.oldValue
- The text to be replaced.newValue
- The text to replace all occurrences of oldValue
.matchCase
- true
to match exact case, false
otherwise.true
if text is found, false
otherwise.public final boolean replaceText(String oldValue, String newValue, boolean matchCase, boolean matchEntireCellContents)
AbstractRange
.oldValue
- The text to be replaced.newValue
- The text to replace all occurrences of oldValue
.matchCase
- true
to match exact case, false
otherwise.matchEntireCellContents
- true
to match entire cell contents, false
otherwise.true
if text is found, false
otherwise.public abstract void setComment(ExcelComment value)
public abstract void setFormula(String value)
public abstract void setHyperlink(SpreadsheetHyperlink value)
public final void setStyle(CellStyle value)
Conceptually, cell formatting is divided into following groups:
CellStyle.setNumberFormat(java.lang.String)
.
CellStyle.setHorizontalAlignment(com.gembox.spreadsheet.HorizontalAlignmentStyle)
, CellStyle.setVerticalAlignment(com.gembox.spreadsheet.VerticalAlignmentStyle)
, CellStyle.setIndent(int)
, CellStyle.setRotation(int)
, CellStyle.setTextVertical(boolean)
, CellStyle.setWrapText(boolean)
and CellStyle.setShrinkToFit(boolean)
.
CellStyle.setFont(com.gembox.spreadsheet.ExcelFont)
.
CellStyle.setBorders(com.gembox.spreadsheet.CellBorders)
.
CellStyle.setFillPattern(com.gembox.spreadsheet.ExcelFillPattern)
.
CellStyle.setLocked(boolean)
and CellStyle.setFormulaHidden(boolean)
.
Additional CellStyle
methods not associated with any formatting group are:
CellStyle.getName()
- name of the referenced workbook style
.
CellStyle.setQuotePrefix(boolean)
- true
to store numeric value of a cell as text; otherwise, false
.
CellStyle.isDefault()
- true
if referenced
workbook style
is default (
CellStyleCollection.getNormal()
) and there are no additional modifications of cell formatting; otherwise, false
.
Workbook
contains a set of master styles
which can be referenced by multiple cells.
Workbook
must always contain at least one master style
which cannot be removed and is, by default, referenced by all cells. This default style is
CellStyleCollection.getNormal()
.
Workbook style
can either be built-in or user-defined. Built-in style is accessible from workbook styles
via BuiltInCellStyleName
enumeration.
Cell formatting group (Number, Alignment, Font, Border, Fill or Protection) (and its associated methods) is resolved from referenced
workbook (master) style
, unless cell formatting group or its associated method is modified.
Cell formatting is available for one or more cells through setStyle(com.gembox.spreadsheet.CellStyle)
method which is available on ExcelCell
and CellRange
types.
Cell formatting specified on ExcelColumn
and ExcelRow
types through ExcelColumnRowBase.setStyle(com.gembox.spreadsheet.CellStyle)
method is simply propagated to cell formatting of its ExcelColumnRowBase.getCells()
.
For performance reasons, cell formatting on CellRange
is resolved based just on its top-left cell formatting, except borders which are resolved based on corner cells depending on border side.
Setting cell formatting method on CellRange
is propagated to each cell in a range.
To set workbook (master) style
to one or more cells, simply assign it to setStyle(com.gembox.spreadsheet.CellStyle)
method.
Preferable way to modify formatting method of multiple cells is to get CellRange
to which all those cells belong, and use setStyle(com.gembox.spreadsheet.CellStyle)
method of that range to make the modification.
If modifying multiple formatting properties of a CellRange
, without preserving unmodified formatting properties, preferable way is to create new instance of CellStyle
, make modifications on it, and assign it using setStyle(com.gembox.spreadsheet.CellStyle)
method of that range.
GemBox.Spreadsheet internally takes care not to allocate unnecessary cells when formatting a range of cells (for example, when formatting all worksheet cells
) and to cache formatting information of equally formatted cells, at the appropriate time, to reduce memory footprint.
value
- The cell formatting of one or more cells.CellStyle for examples
public abstract void setValue(Object value)
public String toString()
String
that represents this AbstractRange
instance.
This method should be used primarily for debugging purposes and should be considered volatile (format of its return value might change in future versions).
toString
in class Object
String
that represents this AbstractRange
instance.© GemBox d.o.o. — All rights reserved.