UnionRange
UnionRange class
Represents union range.
class UnionRange;
Properties
| Property | Type | Description |
|---|---|---|
| firstRow | number | Readonly. Gets the index of the first row of the range. |
| firstColumn | number | Readonly. Gets the index of the first column of the range. |
| rowCount | number | Readonly. Gets the count of rows in the range. |
| columnCount | number | Readonly. Gets the count of rows in the range. |
| value | VObject | Gets and sets the values of the range. |
| name | string | Gets or sets the name of the range. |
| refersTo | string | Readonly. Gets the range’s refers to. |
| hasRange | boolean | Readonly. Indicates whether this has range. |
| hyperlinks | Hyperlink[] | Readonly. Gets all hyperlink in the range. |
| cellCount | number | Readonly. Gets all cell count in the range. |
| rangeCount | number | Readonly. Gets the count of the ranges. |
| ranges | Range[] | Readonly. Gets all union ranges. |
Methods
| Method | Description |
|---|---|
| merge() | Combines a range of cells into a single cell. |
| unMerge() | Unmerges merged cells of this range. |
| putValue(string, boolean, boolean) | Puts a value into the range, if appropriate the value will be converted to other data type and cell’s number format will be reset. |
| setStyle(Style) | Sets the style of the range. |
| applyStyle(Style, StyleFlag) | Applies formats for a whole range. |
| copy(UnionRange, PasteOptions) | Copying the range with paste special options. |
| getEnumerator() | Gets the enumerator for cells in this Range. |
| setOutlineBorders(CellBorderType[], Color[]) | Sets out line borders around a range of cells. |
| setOutlineBorders(CellBorderType, Color) | Sets the outline borders around a range of cells with same border style and color. |
| intersect(string) | Intersects another range. |
| intersect(UnionRange) | Intersects another range. |
| intersect(Range[]) | Intersects another range. |
| union(string) | Union another range. |
| union(UnionRange) | Union another range. |
| union(Range[]) | Union the ranges. |
firstRow
Readonly. Gets the index of the first row of the range.
firstRow : number;
Remarks
Only effects when it only contains one range.
firstColumn
Readonly. Gets the index of the first column of the range.
firstColumn : number;
Remarks
Only effects when it only contains one range.
rowCount
Readonly. Gets the count of rows in the range.
rowCount : number;
Remarks
Only effects when it only contains one range.
columnCount
Readonly. Gets the count of rows in the range.
columnCount : number;
Remarks
Only effects when it only contains one range.
value
Gets and sets the values of the range.
value : VObject;
name
Gets or sets the name of the range.
name : string;
Remarks
Named range is supported. For example,
range.Name = “Sheet1!MyRange”;
refersTo
Readonly. Gets the range’s refers to.
refersTo : string;
hasRange
Readonly. Indicates whether this has range.
hasRange : boolean;
hyperlinks
Readonly. Gets all hyperlink in the range.
hyperlinks : Hyperlink[];
cellCount
Readonly. Gets all cell count in the range.
cellCount : number;
rangeCount
Readonly. Gets the count of the ranges.
rangeCount : number;
ranges
Readonly. Gets all union ranges.
ranges : Range[];
merge()
Combines a range of cells into a single cell.
merge() : void;
Remarks
Reference the merged cell via the address of the upper-left cell in the range.
unMerge()
Unmerges merged cells of this range.
unMerge() : void;
putValue(string, boolean, boolean)
Puts a value into the range, if appropriate the value will be converted to other data type and cell’s number format will be reset.
putValue(stringValue: string, isConverted: boolean, setStyle: boolean) : void;
Parameters:
| Parameter | Type | Description |
|---|---|---|
| stringValue | string | Input value |
| isConverted | boolean | True: converted to other data type if appropriate. |
| setStyle | boolean | True: set the number format to cell’s style when converting to other data type |
setStyle(Style)
Sets the style of the range.
setStyle(style: Style) : void;
Parameters:
| Parameter | Type | Description |
|---|---|---|
| style | Style | The Style object. |
applyStyle(Style, StyleFlag)
Applies formats for a whole range.
applyStyle(style: Style, flag: StyleFlag) : void;
Parameters:
| Parameter | Type | Description |
|---|---|---|
| style | Style | The style object which will be applied. |
| flag | StyleFlag | Flags which indicates applied formatting properties. |
Remarks
Each cell in this range will contains a Style object. So this is a memory-consuming method. Please use it carefully.
copy(UnionRange, PasteOptions)
Copying the range with paste special options.
copy(range: UnionRange, options: PasteOptions) : void;
Parameters:
| Parameter | Type | Description |
|---|---|---|
| range | UnionRange | The source range. |
| options | PasteOptions | The paste special options. |
getEnumerator()
Gets the enumerator for cells in this Range.
getEnumerator() : CellEnumerator;
Returns
The cells enumerator
Remarks
When traversing elements by the returned Enumerator, the cells collection should not be modified(such as operations that will cause new Cell/Row be instantiated or existing Cell/Row be deleted). Otherwise the enumerator may not be able to traverse all cells correctly(some elements may be traversed repeatedly or skipped).
setOutlineBorders(CellBorderType[], Color[])
Sets out line borders around a range of cells.
setOutlineBorders(borderStyles: CellBorderType[], borderColors: Color[]) : void;
Parameters:
| Parameter | Type | Description |
|---|---|---|
| borderStyles | CellBorderType[] | Border styles. |
| borderColors | Color[] | Border colors. |
Remarks
Both the length of borderStyles and borderStyles must be 4. The order of borderStyles and borderStyles must be top,bottom,left,right
setOutlineBorders(CellBorderType, Color)
Sets the outline borders around a range of cells with same border style and color.
setOutlineBorders(borderStyle: CellBorderType, borderColor: Color) : void;
Parameters:
| Parameter | Type | Description |
|---|---|---|
| borderStyle | CellBorderType | Border style. |
| borderColor | Color | Border color. |
intersect(string)
Intersects another range.
intersect(range: string) : UnionRange;
Parameters:
| Parameter | Type | Description |
|---|---|---|
| range | string | The range. |
Returns
Remarks
If the two union ranges are not intersected, returns null.
intersect(UnionRange)
Intersects another range.
intersect(unionRange: UnionRange) : UnionRange;
Parameters:
| Parameter | Type | Description |
|---|---|---|
| unionRange | UnionRange | The range. |
Returns
Remarks
If the two union ranges are not intersected, returns null.
intersect(Range[])
Intersects another range.
intersect(ranges: Range[]) : UnionRange;
Parameters:
| Parameter | Type | Description |
|---|---|---|
| ranges | Range[] | The range. |
Returns
Remarks
If the two union ranges are not intersected, returns null.
union(string)
Union another range.
union(range: string) : UnionRange;
Parameters:
| Parameter | Type | Description |
|---|---|---|
| range | string | The range. |
Returns
union(UnionRange)
Union another range.
union(unionRange: UnionRange) : UnionRange;
Parameters:
| Parameter | Type | Description |
|---|---|---|
| unionRange | UnionRange | The range. |
Returns
union(Range[])
Union the ranges.
union(ranges: Range[]) : UnionRange;
Parameters:
| Parameter | Type | Description |
|---|---|---|
| ranges | Range[] | The ranges. |
Returns