Accessing Cells of a Worksheet
Aspose.Cells provides a class, Workbook that represents a Microsoft Excel file. The Workbook class contains a WorksheetCollection collection that allows access to each worksheet in the Excel file. A worksheet is represented by the Worksheet class. The Worksheet class provides a Cells collection that represents all the cells in the worksheet.
We can use the Cells collection to access cells in a worksheet. Aspose.Cells provides different basic approaches for accessing cells:
Using Cell Name
If you create a blank worksheet at the start, the count of Cells collection is zero. When you use this approach to access a cell, it will check whether this cell exists in the collection or not. If yes, it returns the cell object in the collection otherwise, it creates a new Cell object, adds the object to the Cells collection and then returns the object. This approach is the easiest way to access the cell if you are familiar with Microsoft Excel but it’s slower than other approaches.
Using Row & Column Index of the Cell
This approach works in the same way as that of the first approach.
Accessing Maximum Display Range of Worksheet
Aspose.Cells allows developers to access a worksheet’s maximum display range. The maximum display range - the range of cells between the first and last cell with content - is useful when you need to copy, select, or display the entire contents of a worksheet in an image.
You can access a worksheet’s maximum display range using Worksheet.getCells().getMaxDisplayRange().
In the following figure, the selected worksheet' maximum display range is A1:G15.
Showing the maximum display range of this worksheet
The following sample code illustrates how to access the MaxDisplayRange property. The code generates the following output.
Maximum Display Range: =Sheet1!$A$1:$G$15