获取地址 Cell Count Offset 整列和整行的范围
Contents
[
Hide
]
可能的使用场景
Aspose.Cells 提供了范围对象,它有各种实用方法,方便用户轻松使用 Excel 范围。本文说明了以下方法或属性的用法范围目的。
- 地址
获取范围地址。
- Cell 伯爵
获取范围内的所有单元格计数。
- 抵消
通过偏移获取范围。
- 整列
获取一个 Range 对象,该对象表示包含指定范围的整个一列(或多列)。
- 整行
获取一个 Range 对象,该对象表示包含指定范围的整行(或多行)。
获取地址,Cell 计数,偏移量,范围的整列整行
以下示例代码解释了上述方法和属性的用法。请参阅下面给出的代码的控制台输出以供参考。
示例代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// Create empty workbook. | |
Workbook wb = new Workbook(); | |
// Access first worksheet. | |
Worksheet ws = wb.getWorksheets().get(0); | |
// Create range A1:B3. | |
System.out.println("Creating Range A1:B3\n"); | |
Range rng = ws.getCells().createRange("A1:B3"); | |
// Print range address and cell count. | |
System.out.println("Range Address: " + rng.getAddress()); | |
System.out.println("Cell Count: " + rng.getCellCount()); | |
// Formatting console output. | |
System.out.println("----------------------"); | |
System.out.println(""); | |
// Create range A1. | |
System.out.println("Creating Range A1\n"); | |
rng = ws.getCells().createRange("A1"); | |
// Print range offset, entire column and entire row. | |
System.out.println("Offset: " + rng.getOffset(2, 2).getAddress()); | |
System.out.println("Entire Column: " + rng.getEntireColumn().getAddress()); | |
System.out.println("Entire Row: " + rng.getEntireRow().getAddress()); | |
// Formatting console output. | |
System.out.println("----------------------"); | |
System.out.println(""); |
控制台输出
Creating Range A1:B3
Range Address: A1:B3
Cell Count: 6
\----------------------
Creating Range A1
Offset: C3
Entire Column: A:A
Entire Row: 1:1
\----------------------