aspose.cells

Class Range

Encapsulates the object that represents a range of cells within a spreadsheet.
The Range class denotes a region of Excel spreadsheet. With this, you can format and set value of the range. And you can simply copy range of Excel too.

Property Getters/Setters Summary
functiongetAddress()
Gets address of the range.
functiongetColumnCount()
Gets the count of columns in the range.
functiongetColumnWidth()
function
           Sets or gets the column width of this range
functiongetCurrentRegion()
Returns a Range object that represents the current region. The current region is a range bounded by any combination of blank rows and blank columns.
functiongetEntireColumn()
Gets a Range object that represents the entire column (or columns) that contains the specified range.
functiongetEntireRow()
Gets a Range object that represents the entire row (or rows) that contains the specified range.
functiongetFirstColumn()
Gets the index of the first column of the range.
functiongetFirstRow()
Gets the index of the first row of the range.
functiongetHeight()
Gets the width of a range in points.
functiongetHyperlinks()
Gets all hyperlink in the range.
functiongetLeft()
Gets the distance, in points, from the left edge of column A to the left edge of the range.
functiongetName()
function
setName(value)
           Gets or sets the name of the range.
functiongetRefersTo()
Gets the range's refers to.
functiongetRowCount()
Gets the count of rows in the range.
functiongetRowHeight()
function
           Sets or gets the height of rows in this range
functiongetTop()
Gets the distance, in points, from the top edge of row 1 to the top edge of the range.
functiongetValue()
function
setValue(value)
           Gets and sets the value of the range.
functiongetWidth()
Gets the width of a range in points.
functiongetWorksheet()
Gets the Worksheetobject which contains this range.
functionget(rowOffset, columnOffset)
Gets Cell object in this range.
 
Method Summary
functionaddHyperlink(address, textToDisplay, screenTip)
Adds a hyperlink to a specified cell or a range of cells.
functionapplyStyle(style, flag)
Applies formats for a whole range.
functionautoFill(target)
Automaticall fill the target range.
functionautoFill(target, autoFillType)
Automaticall fill the target range.
functioncopy(range)
Copies data (including formulas), formatting, drawing objects etc. from a source range.
functioncopy(range, options)
Copying the range with paste special options.
functioncopyData(range)
Copies cell data (including formulas) from a source range.
functioncopyStyle(range)
Copies style settings from a source range.
functioncopyValue(range)
Copies cell value from a source range.
functiongetCellOrNull(rowOffset, columnOffset)
Gets Cell object or null in this range.
functiongetOffset(rowOffset, columnOffset)
Gets Range range by offset.
functionintersect(range)
Returns a Range object that represents the rectangular intersection of two ranges.
functionisBlank()
Indicates whether the range contains values.
functionisIntersect(range)
Indicates whether the range is intersect.
functioniterator()
Gets the enumerator for cells in this Range.
functionmerge()
Combines a range of cells into a single cell.
functionmoveTo(destRow, destColumn)
Move the current range to the dest range.
functionputValue(stringValue, isConverted, setStyle)
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.
functionsetInsideBorders(borderEdge, lineStyle, borderColor)
Set inside borders of the range.
functionsetOutlineBorder(borderEdge, borderStyle, borderColor)
Sets outline border around a range of cells.
functionsetOutlineBorder(borderEdge, borderStyle, borderColor)
Sets outline border around a range of cells.
functionsetOutlineBorders(borderStyle, borderColor)
Sets the outline borders around a range of cells with same border style and color.
functionsetOutlineBorders(borderStyle, borderColor)
Sets the outline borders around a range of cells with same border style and color.
functionsetOutlineBorders(borderStyles, borderColors)
Sets out line borders around a range of cells.
functionsetStyle(style)
Sets the style of the range.
functionsetStyle(style, explicitFlag)
Apply the cell style.
functiontoString()
Returns a string represents the current Range object.
functionunion(range)
Returns the union of two ranges.
functionunionRang(range)
Returns the union result of two ranges.
functionunMerge()
Unmerges merged cells of this range.
 

    • Property Getters/Setters Detail

      • getCurrentRegion : Range 

        function getCurrentRegion()
        
        Returns a Range object that represents the current region. The current region is a range bounded by any combination of blank rows and blank columns.
      • getHyperlinks : Hyperlink[] 

        function getHyperlinks()
        
        Gets all hyperlink in the range.
      • getRowCount : Number 

        function getRowCount()
        
        Gets the count of rows in the range.
      • getColumnCount : Number 

        function getColumnCount()
        
        Gets the count of columns in the range.
      • getName/setName : String 

        function getName() / function setName(value)
        
        Gets or sets the name of the range. Named range is supported. For example,

        range.Name = "Sheet1!MyRange";

      • getRefersTo : String 

        function getRefersTo()
        
        Gets the range's refers to.
      • getAddress : String 

        function getAddress()
        
        Gets address of the range.
      • getLeft : Number 

        function getLeft()
        
        Gets the distance, in points, from the left edge of column A to the left edge of the range.
      • getTop : Number 

        function getTop()
        
        Gets the distance, in points, from the top edge of row 1 to the top edge of the range.
      • getWidth : Number 

        function getWidth()
        
        Gets the width of a range in points.
      • getHeight : Number 

        function getHeight()
        
        Gets the width of a range in points.
      • getFirstRow : Number 

        function getFirstRow()
        
        Gets the index of the first row of the range.
      • getFirstColumn : Number 

        function getFirstColumn()
        
        Gets the index of the first column of the range.
      • getValue/setValue : Object 

        function getValue() / function setValue(value)
        
        Gets and sets the value of the range. If the range contains multiple cells, the returned/applied object should be Object[][].
      • getColumnWidth/setColumnWidth : Number 

        function getColumnWidth() / function setColumnWidth(value)
        
        Sets or gets the column width of this range
      • getRowHeight/setRowHeight : Number 

        function getRowHeight() / function setRowHeight(value)
        
        Sets or gets the height of rows in this range
      • getEntireColumn : Range 

        function getEntireColumn()
        
        Gets a Range object that represents the entire column (or columns) that contains the specified range.
      • getEntireRow : Range 

        function getEntireRow()
        
        Gets a Range object that represents the entire row (or rows) that contains the specified range.
      • getWorksheet : Worksheet 

        function getWorksheet()
        
        Gets the Worksheetobject which contains this range.
      • get : Cell 

        function get(rowOffset, columnOffset)
        
        Gets Cell object in this range.
        Parameters:
        rowOffset - Row offset in this range, zero based.
        columnOffset - Column offset in this range, zero based.
        Returns:
        Cell object.
    • Method Detail

      • autoFill

        function autoFill(target)
        Automaticall fill the target range.
        Parameters:
        target: Range - the target range.
      • autoFill

        function autoFill(target, autoFillType)
        Automaticall fill the target range.
        Parameters:
        target: Range - The targed range.
        autoFillType: Number - A AutoFillType value. The auto fill type.
      • addHyperlink

        function addHyperlink(address, textToDisplay, screenTip)
        Adds a hyperlink to a specified cell or a range of cells.
        Parameters:
        address: String - Address of the hyperlink.
        textToDisplay: String - The text to be displayed for the specified hyperlink.
        screenTip: String - The screenTip text for the specified hyperlink.
        Returns:
        Hyperlink object.
      • iterator

        function iterator()
        Gets the enumerator for cells in this Range. 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).
        Returns:
        The cells enumerator
      • isIntersect

        function isIntersect(range)
        Indicates whether the range is intersect. If the two ranges area not in the same worksheet ,return false.
        Parameters:
        range: Range - The range.
        Returns:
        Whether the range is intersect.
      • intersect

        function intersect(range)
        Returns a Range object that represents the rectangular intersection of two ranges. If the two ranges are not intersected, returns null.
        Parameters:
        range: Range - The intersecting range.
        Returns:
        Returns a Range object
      • unionRang

        function unionRang(range)
        Returns the union result of two ranges.
        Parameters:
        range: Range - The range
        Returns:
        The union of two ranges.
      • union

        function union(range)
        Returns the union of two ranges. NOTE: This method is now obsolete. Instead, please use Range.UnionRang() method. This method will be removed 12 months later since November 2023. Aspose apologizes for any inconvenience you may have experienced.
        Parameters:
        range: Range - The range
        Returns:
        The union of two ranges.
      • isBlank

        function isBlank()
        Indicates whether the range contains values.
        Returns:
      • merge

        function merge()
        Combines a range of cells into a single cell. Reference the merged cell via the address of the upper-left cell in the range.
      • unMerge

        function unMerge()
        Unmerges merged cells of this range.
      • putValue

        function putValue(stringValue, isConverted, setStyle)
        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.
        Parameters:
        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

        function setStyle(style, explicitFlag)
        Apply the cell style.
        Parameters:
        style: Style - The cell style.
        explicitFlag: boolean - True, only overwriting formatting which is explicitly set.
      • applyStyle

        function applyStyle(style, flag)
        Applies formats for a whole range. Each cell in this range will contains a Style object. So this is a memory-consuming method. Please use it carefully.
        Parameters:
        style: Style - The style object which will be applied.
        flag: StyleFlag - Flags which indicates applied formatting properties.
      • setStyle

        function setStyle(style)
        Sets the style of the range.
        Parameters:
        style: Style - The Style object.
      • setOutlineBorders

        function setOutlineBorders(borderStyle, borderColor)
        Sets the outline borders around a range of cells with same border style and color.
        Parameters:
        borderStyle: Number - A CellBorderType value. Border style.
        borderColor: CellsColor - Border color.
      • setOutlineBorders

        function setOutlineBorders(borderStyle, borderColor)
        Sets the outline borders around a range of cells with same border style and color.
        Parameters:
        borderStyle: Number - A CellBorderType value. Border style.
        borderColor: Color - Border color.
      • setOutlineBorders

        function setOutlineBorders(borderStyles, borderColors)
        Sets out line borders around a range of cells. Both the length of borderStyles and borderStyles must be 4. The order of borderStyles and borderStyles must be top,bottom,left,right
        Parameters:
        borderStyles: Number Array - Border styles.
        borderColors: Color[] - Border colors.
      • setOutlineBorder

        function setOutlineBorder(borderEdge, borderStyle, borderColor)
        Sets outline border around a range of cells.
        Parameters:
        borderEdge: Number - A BorderType value. Border edge.
        borderStyle: Number - A CellBorderType value. Border style.
        borderColor: CellsColor - Border color.
      • setOutlineBorder

        function setOutlineBorder(borderEdge, borderStyle, borderColor)
        Sets outline border around a range of cells.
        Parameters:
        borderEdge: Number - A BorderType value. Border edge.
        borderStyle: Number - A CellBorderType value. Border style.
        borderColor: Color - Border color.
      • setInsideBorders

        function setInsideBorders(borderEdge, lineStyle, borderColor)
        Set inside borders of the range.
        Parameters:
        borderEdge: Number - A BorderType value. Inside borde type, only can be BorderType.VERTICAL and BorderType.HORIZONTAL.
        lineStyle: Number - A CellBorderType value. The border style.
        borderColor: CellsColor - The color of the border.
      • moveTo

        function moveTo(destRow, destColumn)
        Move the current range to the dest range.
        Parameters:
        destRow: Number - The start row of the dest range.
        destColumn: Number - The start column of the dest range.
      • copyData

        function copyData(range)
        Copies cell data (including formulas) from a source range.
        Parameters:
        range: Range - Source Range object.
      • copyValue

        function copyValue(range)
        Copies cell value from a source range.
        Parameters:
        range: Range - Source Range object.
      • copyStyle

        function copyStyle(range)
        Copies style settings from a source range.
        Parameters:
        range: Range - Source Range object.
      • copy

        function copy(range, options)
        Copying the range with paste special options.
        Parameters:
        range: Range - The source range.
        options: PasteOptions - The paste special options.
      • copy

        function copy(range)
        Copies data (including formulas), formatting, drawing objects etc. from a source range.
        Parameters:
        range: Range - Source Range object.
      • getCellOrNull

        function getCellOrNull(rowOffset, columnOffset)
        Gets Cell object or null in this range.
        Parameters:
        rowOffset: Number - Row offset in this range, zero based.
        columnOffset: Number - Column offset in this range, zero based.
        Returns:
        Cell object.
      • getOffset

        function getOffset(rowOffset, columnOffset)
        Gets Range range by offset.
        Parameters:
        rowOffset: Number - Row offset in this range, zero based.
        columnOffset: Number - Column offset in this range, zero based.
        Returns:
      • toString

        function toString()
        Returns a string represents the current Range object.
        Returns: