获取地址 Cell Count Offset 整列和整行的范围

可能的使用场景

Aspose.Cells 提供了 Range 对象,它有多种实用方法,方便用户轻松使用 Excel 范围。本文说明了 Range 对象的以下方法或属性的用法。

  • 地址

获取范围地址。

  • Cell 伯爵

获取范围内的所有单元格计数。

  • 抵消

通过偏移获取范围。

  • 整列

获取一个 Range 对象,该对象表示包含指定范围的整个一列(或多列)。

  • 整行

获取一个 Range 对象,该对象表示包含指定范围的整行(或多行)。

获取地址,Cell 计数,偏移量,范围的整列整行

以下示例代码解释了上述方法和属性的用法。请参阅下面给出的代码的控制台输出以供参考。

 示例代码

// 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("");

控制台输出

 Creating Range A1:B3

Range Address: A1:B3

Cell Count: 6

\----------------------

Creating Range A1

Offset: C3

Entire Column: A:A

Entire Row: 1:1

\----------------------