Excel テーブルをデータ範囲に変換する
Contents
[
Hide
]
Excel テーブルをデータ範囲に変換する
Aspose.Cells for Python via Java は、Excel テーブルをデータの範囲に変換するオプションを提供します。このために、API は[ListObject.convertToRange](https://reference.aspose.com/cells/python/asposecells.api/listobject#convertToRange() ) 方法。次のコード スニペットは、ListObject.convertToRange メソッドを使用して、Excel テーブルをデータ範囲に変換します。
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
source_directory = "Examples/SampleFiles/SourceDirectory/" | |
output_directory = "Examples/SampleFiles/OutputDirectory/" | |
workbook = Workbook(source_directory + "Book2.xlsx") | |
# Convert the first table/list object (from the first worksheet) to normal range | |
workbook.getWorksheets().get(0).getListObjects().get(0).convertToRange() | |
# Save the excel file. | |
workbook.save(output_directory + "ConvertTableToRange_out.xlsx") |
オプションを使用して Excel テーブルを範囲に変換する
を使用してテーブルを範囲に変換する際に、追加のオプションを指定できます。TableToRangeOptionsクラス。のインスタンスを渡すことができますTableToRangeOptionsへのクラス[ListObject.convertToRange](https://reference.aspose.com/cells/python/asposecells.api/listobject#convertToRange(com.aspose.cells.TableToRangeOptions)メソッドを使用して、追加のオプションを指定します。次のコード スニペットは、TableToRangeOptionsテーブルの最後の行インデックスを設定するクラス。テーブルの書式設定は、指定された行インデックスまで保持され、残りの書式設定は削除されます。
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
source_directory = "Examples/SampleFiles/SourceDirectory/" | |
output_directory = "Examples/SampleFiles/OutputDirectory/" | |
workbook = Workbook(source_directory + "Book2.xlsx") | |
# Convert the first table/list object (from the first worksheet) to normal range | |
tableToRangeOptions = TableToRangeOptions() | |
tableToRangeOptions.setLastRow(5) | |
# Convert the first table/list object (from the first worksheet) to normal range | |
workbook.getWorksheets().get(0).getListObjects().get(0).convertToRange(tableToRangeOptions) | |
# Save the excel file. | |
workbook.save(output_directory + "ConvertTableToRangeWithOptions_out.xlsx") |