UnionRange

UnionRange class

Represents union range.

class UnionRange;

Methods

MethodDescription
getFirstRow()Gets the index of the first row of the range.
getFirstColumn()Gets the index of the first column of the range.
getRowCount()Gets the count of rows in the range.
getColumnCount()Gets the count of rows in the range.
getName()Gets or sets the name of the range.
setName(string)Gets or sets the name of the range.
getRefersTo()Gets the range’s refers to.
getHasRange()Indicates whether this has range.
getHyperlinks()Gets all hyperlink in the range.
getCellCount()Gets all cell count in the range.
getRangeCount()Gets the count of the ranges.
getRanges()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.

getFirstRow()

Gets the index of the first row of the range.

getFirstRow() : number;

Remarks

Only effects when it only contains one range.

getFirstColumn()

Gets the index of the first column of the range.

getFirstColumn() : number;

Remarks

Only effects when it only contains one range.

getRowCount()

Gets the count of rows in the range.

getRowCount() : number;

Remarks

Only effects when it only contains one range.

getColumnCount()

Gets the count of rows in the range.

getColumnCount() : number;

Remarks

Only effects when it only contains one range.

getName()

Gets or sets the name of the range.

getName() : string;

Remarks

Named range is supported. For example,

range.Name = “Sheet1!MyRange”;

setName(string)

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()

Gets the range’s refers to.

getRefersTo() : string;

getHasRange()

Indicates whether this has range.

getHasRange() : boolean;

Gets all hyperlink in the range.

getHyperlinks() : Hyperlink[];

Returns

Hyperlink[]

getCellCount()

Gets all cell count in the range.

getCellCount() : number;

getRangeCount()

Gets the count of the ranges.

getRangeCount() : number;

getRanges()

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