UnionRange

UnionRange class

Represents union range.

class UnionRange;

Properties

PropertyTypeDescription
firstRownumberReadonly. Gets the index of the first row of the range.
firstColumnnumberReadonly. Gets the index of the first column of the range.
rowCountnumberReadonly. Gets the count of rows in the range.
columnCountnumberReadonly. Gets the count of rows in the range.
valueObjectGets and sets the values of the range.
namestringGets or sets the name of the range.
refersTostringReadonly. Gets the range’s refers to.
hasRangebooleanReadonly. Indicates whether this has range.
hyperlinksHyperlink[]Readonly. Gets all hyperlink in the range.
cellCountnumberReadonly. Gets all cell count in the range.
rangeCountnumberReadonly. Gets the count of the ranges.
rangesRange[]Readonly. Gets all union ranges.

Methods

MethodDescription
getFirstRow()@deprecated. Please use the ‘firstRow’ property instead. Gets the index of the first row of the range.
getFirstColumn()@deprecated. Please use the ‘firstColumn’ property instead. Gets the index of the first column of the range.
getRowCount()@deprecated. Please use the ‘rowCount’ property instead. Gets the count of rows in the range.
getColumnCount()@deprecated. Please use the ‘columnCount’ property instead. Gets the count of rows in the range.
getValue()@deprecated. Please use the ‘value’ property instead. Gets and sets the values of the range.
setValue(Object)@deprecated. Please use the ‘value’ property instead. Gets and sets the values of the range.
getName()@deprecated. Please use the ’name’ property instead. Gets or sets the name of the range.
setName(string)@deprecated. Please use the ’name’ property instead. Gets or sets the name of the range.
getRefersTo()@deprecated. Please use the ‘refersTo’ property instead. Gets the range’s refers to.
getHasRange()@deprecated. Please use the ‘hasRange’ property instead. Indicates whether this has range.
getHyperlinks()@deprecated. Please use the ‘hyperlinks’ property instead. Gets all hyperlink in the range.
getCellCount()@deprecated. Please use the ‘cellCount’ property instead. Gets all cell count in the range.
getRangeCount()@deprecated. Please use the ‘rangeCount’ property instead. Gets the count of the ranges.
getRanges()@deprecated. Please use the ‘ranges’ property instead. Gets all union ranges.
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.
isNull()Checks whether the implementation object is null.

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 : Object;

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;

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[];

getFirstRow()

@deprecated. Please use the ‘firstRow’ property instead. Gets the index of the first row of the range.

getFirstRow() : number;

Remarks

Only effects when it only contains one range.

getFirstColumn()

@deprecated. Please use the ‘firstColumn’ property instead. Gets the index of the first column of the range.

getFirstColumn() : number;

Remarks

Only effects when it only contains one range.

getRowCount()

@deprecated. Please use the ‘rowCount’ property instead. Gets the count of rows in the range.

getRowCount() : number;

Remarks

Only effects when it only contains one range.

getColumnCount()

@deprecated. Please use the ‘columnCount’ property instead. Gets the count of rows in the range.

getColumnCount() : number;

Remarks

Only effects when it only contains one range.

getValue()

@deprecated. Please use the ‘value’ property instead. Gets and sets the values of the range.

getValue() : Object;

setValue(Object)

@deprecated. Please use the ‘value’ property instead. Gets and sets the values of the range.

setValue(value: Object) : void;

Parameters:

ParameterTypeDescription
valueObjectThe value to set.

getName()

@deprecated. Please use the ’name’ property instead. Gets or sets the name of the range.

getName() : string;

Remarks

Named range is supported. For example,

range.Name = “Sheet1!MyRange”;

setName(string)

@deprecated. Please use the ’name’ property instead. Gets or sets the name of the range.

setName(value: string) : void;

Parameters:

ParameterTypeDescription
valuestringThe value to set.

Remarks

Named range is supported. For example,

range.Name = “Sheet1!MyRange”;

getRefersTo()

@deprecated. Please use the ‘refersTo’ property instead. Gets the range’s refers to.

getRefersTo() : string;

getHasRange()

@deprecated. Please use the ‘hasRange’ property instead. Indicates whether this has range.

getHasRange() : boolean;

@deprecated. Please use the ‘hyperlinks’ property instead. Gets all hyperlink in the range.

getHyperlinks() : Hyperlink[];

Returns

Hyperlink[]

getCellCount()

@deprecated. Please use the ‘cellCount’ property instead. Gets all cell count in the range.

getCellCount() : number;

getRangeCount()

@deprecated. Please use the ‘rangeCount’ property instead. Gets the count of the ranges.

getRangeCount() : number;

getRanges()

@deprecated. Please use the ‘ranges’ property instead. Gets all union ranges.

getRanges() : Range[];

Returns

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:

ParameterTypeDescription
stringValuestringInput value
isConvertedbooleanTrue: converted to other data type if appropriate.
setStylebooleanTrue: 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:

ParameterTypeDescription
styleStyleThe Style object.

applyStyle(Style, StyleFlag)

Applies formats for a whole range.

applyStyle(style: Style, flag: StyleFlag) : void;

Parameters:

ParameterTypeDescription
styleStyleThe style object which will be applied.
flagStyleFlagFlags 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:

ParameterTypeDescription
rangeUnionRangeThe source range.
optionsPasteOptionsThe 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:

ParameterTypeDescription
borderStylesCellBorderType[]Border styles.
borderColorsColor[]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:

ParameterTypeDescription
borderStyleCellBorderTypeBorder style.
borderColorColorBorder color.

intersect(string)

Intersects another range.

intersect(range: string) : UnionRange;

Parameters:

ParameterTypeDescription
rangestringThe range.

Returns

UnionRange

Remarks

If the two union ranges are not intersected, returns null.

intersect(UnionRange)

Intersects another range.

intersect(unionRange: UnionRange) : UnionRange;

Parameters:

ParameterTypeDescription
unionRangeUnionRangeThe range.

Returns

UnionRange

Remarks

If the two union ranges are not intersected, returns null.

intersect(Range[])

Intersects another range.

intersect(ranges: Range[]) : UnionRange;

Parameters:

ParameterTypeDescription
rangesRange[]The range.

Returns

UnionRange

Remarks

If the two union ranges are not intersected, returns null.

union(string)

Union another range.

union(range: string) : UnionRange;

Parameters:

ParameterTypeDescription
rangestringThe range.

Returns

UnionRange

union(UnionRange)

Union another range.

union(unionRange: UnionRange) : UnionRange;

Parameters:

ParameterTypeDescription
unionRangeUnionRangeThe range.

Returns

UnionRange

union(Range[])

Union the ranges.

union(ranges: Range[]) : UnionRange;

Parameters:

ParameterTypeDescription
rangesRange[]The ranges.

Returns

UnionRange

isNull()

Checks whether the implementation object is null.

isNull() : boolean;