セル名と行/列インデックスの変換
行と列のインデックスからセル名を取得
行と列のインデックスを指定すると、セルの名前を見つけることが可能です。 この記事では、その方法について説明します。 Aspose.Cells for Python via .NETは、開発者が行と列のインデックスを指定した場合にセルの名前を取得できるCellsHelper.cell_index_to_nameメソッドを提供しています。
次のサンプルコードは、既知の行と列インデックスを使用してセルの名前にアクセスするためにCellsHelper.cell_index_to_nameを使用する方法を示しています。コードにより、次の出力が生成されます。
import io | |
import aspose.cells | |
from aspose.cells import Workbook, Worksheet, Cells, CellsHelper | |
# For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
row = 3 | |
column = 5 | |
name = CellsHelper.cell_index_to_name(row, column) | |
print("Cell name: " + name) |
セル名から行と列のインデックスを取得
セルの名前から行と列のインデックスを見つけることが可能です。 この記事では、その方法について説明します。 Aspose.Cells for Python via .NETは、開発者がセルの名前から行と列のインデックスを取得できるCellsHelper.cell_name_to_indexメソッドを提供しています。
次のサンプルコードは、CellsHelper.cell_name_to_indexを使用してセルの名前から行と列インデックスを取得する方法を示しています。コードにより、次の出力が生成されます。
import io | |
import aspose.cells | |
from aspose.cells import Workbook, Worksheet, Cells, CellsHelper | |
# For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
name = "C4"; | |
row = [] | |
column = [] | |
CellsHelper.cell_name_to_index(name, row, column) | |
print("Row: " + str(row[0]) + " , Column: " + str(column[0])) |
安全なシート名を作成します。
ランタイムでシート名を割り当てる必要がある場合があります。このシナリオでは、<>()+?“といった追加の文字を含むシート名が存在する場合があります。シート名として許可されていない文字はユーザーが提供した事前の文字で置き換える必要があります。同様に、長さが31文字を超える場合もあるため、縮小する必要があります。Apache POIは安全な名前の作成の特定の機能を提供していますが、同様の機能をAspose.Cells for Python via .NETによって提供されており、これによりこれらの問題を処理するための機能が提供されています。次のサンプルコードは、この機能を示しています。
from aspose.cells import CellsHelper | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Long name will be truncated to 31 characters | |
name1 = CellsHelper.create_safe_sheet_name("this is first name which is created using CellsHelper.CreateSafeSheetName and truncated to 31 characters") | |
# Any invalid character will be replaced with _ | |
name2 = CellsHelper.create_safe_sheet_name(" <> + (adj.Private ? \" Private\" : \")", '_') | |
# Display first name | |
print(name1) | |
# Display second name | |
print(name2) |
出力:
これは最初の名前です。
` <> + (形容詞Private _ " Private”