com.aspose.cells

  • java.lang.Object
    • com.aspose.cells.Range
public class Range 
extends java.lang.Object

Encapsulates the object that represents a range of cells within a spreadsheet.

Property Getters/Setters Summary
java.lang.StringgetAddress()
Gets address of the range.
intgetCellCount()
Gets all cell count in the range.
intgetColumnCount()
Gets the count of columns in the range.
doublegetColumnWidth()
void
setColumnWidth(doublevalue)
           Sets or gets the column width of this range
RangegetEntireColumn()
Gets a Range object that represents the entire column (or columns) that contains the specified range.
RangegetEntireRow()
Gets a Range object that represents the entire row (or rows) that contains the specified range.
intgetFirstColumn()
Gets the index of the first column of the range.
intgetFirstRow()
Gets the index of the first row of the range.
com.aspose.cells.Hyperlink[]getHyperlinks()
Gets all hyperlink in the range.
java.lang.StringgetName()
void
setName(java.lang.Stringvalue)
           Gets or sets the name of the range.
java.lang.StringgetRefersTo()
Gets the range's refers to.
intgetRowCount()
Gets the count of rows in the range.
doublegetRowHeight()
void
setRowHeight(doublevalue)
           Sets or gets the height of rows in this range
java.lang.ObjectgetValue()
void
setValue(java.lang.Objectvalue)
           Gets and sets the value of the range.
WorksheetgetWorksheet()
Gets the Worksheetobject which contains this range.
Cellget(int rowOffset, int columnOffset)
Gets Cell object in this range.
 
Method Summary
voidapplyStyle(Style style, StyleFlag flag)
Applies formats for a whole range.
voidcopy(Range range)
Copies data (including formulas), formatting, drawing objects etc. from a source range.
voidcopy(Range range, PasteOptions options)
Copying the range with paste special options.
voidcopyData(Range range)
Copies cell data (including formulas) from a source range.
voidcopyStyle(Range range)
Copies style settings from a source range.
voidcopyValue(Range range)
Copies cell value from a source range.
CellgetCellOrNull(int rowOffset, int columnOffset)
Gets Cell object or null in this range.
RangegetOffset(int rowOffset, int columnOffset)
Gets Range range by offset.
Rangeintersect(Range range)
Returns a Range object that represents the rectangular intersection of two ranges.
booleanisIntersect(Range range)
Indicates whether the range is intersect.
java.util.Iteratoriterator()
Gets the enumerator for cells in this Range.
voidmerge()
Combines a range of cells into a single cell.
voidmoveTo(int destRow, int destColumn)
Move the current range to the dest range.
voidputValue(java.lang.String stringValue, boolean isConverted, boolean 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.
voidsetOutlineBorder(int borderEdge, int borderStyle, Color borderColor)
Sets outline border around a range of cells.
voidsetOutlineBorders(int borderStyle, com.aspose.cells.Color borderColor)
Sets the outline borders around a range of cells with same border style and color.
voidsetOutlineBorders(int[] borderStyles, com.aspose.cells.Color[] borderColors)
Sets out line borders around a range of cells.
voidsetStyle(Style style)
Sets the style of the range.
java.lang.StringtoString()
Returns a string represents the current Range object.
java.util.ArrayListunion(Range range)
Returns the union of two ranges.
voidunMerge()
Unmerges merged cells of this range.
 

    • Property Getters/Setters Detail

      • getHyperlinks

        public com.aspose.cells.Hyperlink[] getHyperlinks()
        
        Gets all hyperlink in the range.
      • getRowCount

        public int getRowCount()
        
        Gets the count of rows in the range.
      • getColumnCount

        public int getColumnCount()
        
        Gets the count of columns in the range.
      • getCellCount

        public int getCellCount()
        
        Gets all cell count in the range.
      • getName/setName

        public java.lang.String getName() / public void setName(java.lang.String value)
        
        Gets or sets the name of the range. Named range is supported. For example,

        range.Name = "Sheet1!MyRange";

      • getRefersTo

        public java.lang.String getRefersTo()
        
        Gets the range's refers to.
      • getAddress

        public java.lang.String getAddress()
        
        Gets address of the range.
      • getFirstRow

        public int getFirstRow()
        
        Gets the index of the first row of the range.
      • getFirstColumn

        public int getFirstColumn()
        
        Gets the index of the first column of the range.
      • getValue/setValue

        public java.lang.Object getValue() / public void setValue(java.lang.Object value)
        
        Gets and sets the value of the range. If the range contains multiple cells, return a two-dimension System.Array object. If applies object array to the range, it should be a two-dimension System.Array object.
      • getColumnWidth/setColumnWidth

        public double getColumnWidth() / public void setColumnWidth(double value)
        
        Sets or gets the column width of this range
      • getRowHeight/setRowHeight

        public double getRowHeight() / public void setRowHeight(double value)
        
        Sets or gets the height of rows in this range
      • getEntireColumn

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

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

        public Worksheet getWorksheet()
        
        Gets the Worksheetobject which contains this range.
      • get

        public Cell get(int rowOffset, int 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.

    setName

    public voidsetName(java.lang.Stringvalue)
    
    Gets or sets the name of the range. Named range is supported. For example,

    range.Name = "Sheet1!MyRange";

    setValue

    public voidsetValue(java.lang.Objectvalue)
    
    Gets and sets the value of the range. If the range contains multiple cells, return a two-dimension System.Array object. If applies object array to the range, it should be a two-dimension System.Array object.

    setColumnWidth

    public voidsetColumnWidth(doublevalue)
    
    Sets or gets the column width of this range

    setRowHeight

    public voidsetRowHeight(doublevalue)
    
    Sets or gets the height of rows in this range
    • Method Detail

      • iterator

        public java.util.Iterator 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

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

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

        public java.util.ArrayList union(Range range)
        Returns the union of two ranges.
        Parameters:
        range - The range
        Returns:
        The union of two ranges.
      • merge

        public void 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

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

        public void putValue(java.lang.String stringValue, boolean isConverted, boolean 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 - Input value
        isConverted - True: converted to other data type if appropriate.
        setStyle - True: set the number format to cell's style when converting to other data type
      • applyStyle

        public void applyStyle(Style style, StyleFlag 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 - The style object which will be applied.
        flag - Flags which indicates applied formatting properties.
      • setStyle

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

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

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

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

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

        public void copyData(Range range)
                     throws java.lang.Exception
        Copies cell data (including formulas) from a source range.
        Parameters:
        range - Source Range object.
      • copyValue

        public void copyValue(Range range)
                      throws java.lang.Exception
        Copies cell value from a source range.
        Parameters:
        range - Source Range object.
      • copyStyle

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

        public void copy(Range range, PasteOptions options)
                 throws java.lang.Exception
        Copying the range with paste special options.
        Parameters:
        range - The soure range.
        options - The paste special options.
      • copy

        public void copy(Range range)
                 throws java.lang.Exception
        Copies data (including formulas), formatting, drawing objects etc. from a source range.
        Parameters:
        range - Source Range object.
      • getCellOrNull

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

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

        public java.lang.String toString()
        Returns a string represents the current Range object.
        Returns: