範囲のアドレス、セル数、オフセット、全列、および全行を取得する
Contents
[
Hide
]
可能な使用シナリオ
Aspose.Cells for Python via .NETは、Excel範囲で簡単に作業できるようにユーザーを支援するさまざまなユーティリティメソッドを持つRangeオブジェクトを提供しています。この記事では、Rangeオブジェクトの次のメソッドまたはプロパティの使用法について説明します。
- address
範囲のアドレスを取得します。
- cell_count
範囲内のすべてのセル数を取得します。
- get_offset
オフセットによって範囲を取得します。
- entire_column
指定された範囲を含む列全体を表すRangeオブジェクトを取得します。
- entire_row
指定された範囲を含む行全体を表すRangeオブジェクトを取得します。
範囲のアドレス、セル数、オフセット、全列および全行を取得する
以下のサンプルコードは、上記で説明したメソッドとプロパティの使用方法を説明します。参考のために、以下に示すコードのコンソール出力をご覧ください。
サンプルコード
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
from aspose.cells import Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Create empty workbook. | |
wb = Workbook() | |
# Access first worksheet. | |
ws = wb.worksheets[0] | |
# Create range A1:B3. | |
print("Creating Range A1:B3\n") | |
rng = ws.cells.create_range("A1:B3") | |
# Print range address and cell count. | |
print("Range Address: " + rng.address) | |
print("Range row Count: " + str(rng.row_count)) | |
print("Range column Count: " + str(rng.column_count)) | |
# Formatting console output. | |
print("----------------------") | |
print("") | |
# Create range A1. | |
print("Creating Range A1\n") | |
rng = ws.cells.create_range("A1") | |
# Print range offset, entire column and entire row. | |
print("Offset: " + rng.get_offset(2, 2).address) | |
print("Entire Column: " + rng.entire_column.address) | |
print("Entire Row: " + rng.entire_row.address) | |
# Formatting console output. | |
print("----------------------") | |
print("") |
コンソール出力
Creating Range A1:B3
Range Address: A1:B3
Cell Count: 6
\----------------------
Creating Range A1
Offset: C3
Entire Column: A:A
Entire Row: 1:1
\----------------------