Document Solutions for Excel, Java Edition | Document Solutions
In This Topic
    Get Range and Range Area
    In This Topic

    Range or a range area refers to an array of cells that have been defined in a spreadsheet. While working with worksheets in a workbook, users can define multiple ranges and then further access those range areas separately to perform certain tasks like formatting of cells, merging of cells, insertion or deletion of cells within a range and other useful operations.

    Refer to the following example code to see how you can define a range.

    Copy Code
    // UsedRange is "H6:M10"
    String usedrange = worksheet.getUsedRange().toString();
    // Customize the used range 

    Refer to the following example code to see how you can access the range area with a range.

    Copy Code
    IRange range = worksheet.getRange("A5:B7, C3, H5:N6");
    // Access the first area - area1 is A5:B7.
    IRange area1 = worksheet.getRange("A5:B7, C3, H5:N6").getAreas().getArea(0);
    // Set interior color for the first area
    // Access the second area - area2 is C3.
    IRange area2 = worksheet.getRange("A5:B7, C3, H5:N6").getAreas().getArea(1);
    // Set interior color for the second area
    // Access the third area - area3 is H5:N6.
    IRange area3 = worksheet.getRange("A5:B7, C3, H5:N6").getAreas().getArea(2);
    // Set interior color for the third area
    See Also