Get Address Cell Count Offset Entire Column and Entire Row of the Range
Possible Usage Scenarios
Aspose.Cells provides the Range object which has various utility methods that facilitate the user to work with Excel Ranges easily. This article illustrates the usage of the following methods or properties of Range object.
- Address
Gets address of the range.
- Cell Count
Gets all cell count in the range.
- Offset
Gets range by offset.
- Entire Column
Gets a Range object that represents the entire column (or columns) that contains the specified range.
- Entire Row
Gets a Range object that represents the entire row (or rows) that contains the specified range.
Get Address, Cell Count, Offset, Entire Column and Entire Row of the Range
The following sample code explains the usage of the methods and properties as discussed above. Please see the console output of the code given below for a reference.
Sample Code
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Create empty workbook. | |
Workbook wb = new Workbook(); | |
// Access first worksheet. | |
Worksheet ws = wb.Worksheets[0]; | |
// Create range A1:B3. | |
Console.WriteLine("Creating Range A1:B3\n"); | |
Range rng = ws.Cells.CreateRange("A1:B3"); | |
// Print range address and cell count. | |
Console.WriteLine("Range Address: " + rng.Address); | |
Console.WriteLine("Range row Count: " + rng.RowCount); | |
Console.WriteLine("Range column Count: " + rng.ColumnCount); | |
// Formatting console output. | |
Console.WriteLine("----------------------"); | |
Console.WriteLine(""); | |
// Create range A1. | |
Console.WriteLine("Creating Range A1\n"); | |
rng = ws.Cells.CreateRange("A1"); | |
// Print range offset, entire column and entire row. | |
Console.WriteLine("Offset: " + rng.GetOffset(2, 2).Address); | |
Console.WriteLine("Entire Column: " + rng.EntireColumn.Address); | |
Console.WriteLine("Entire Row: " + rng.EntireRow.Address); | |
// Formatting console output. | |
Console.WriteLine("----------------------"); | |
Console.WriteLine(""); |
Console Output
Creating Range A1:B3
Range Address: A1:B3
Cell Count: 6
\----------------------
Creating Range A1
Offset: C3
Entire Column: A:A
Entire Row: 1:1
\----------------------