Aspose.Cellsを使用したOpenXmlのSheet.SheetIdプロパティを利用する
Contents
[
Hide
]
可能な使用シナリオ
Sheet.SheetId プロパティは、DocumentFormat.OpenXml.Spreadsheet名前空間内にあり、OpenXmlの一部です。このプロパティとその値は、以下のスクリーンショットに示すように workbook.xml 内に見られます。Aspose.Cells for Python via .NETは、同等のプロパティをWorksheet.tab_idとして提供します。
Aspose.Cells for Python Excelライブラリを使用してOpenXmlのSheet.SheetIdプロパティを活用する
次のサンプルコードは、サンプルExcelファイルをロードし、そのシートまたはタブIDを読み取り、それに新しいタブIDを割り当てて出力Excelファイルとして保存します。以下に示すコードのコンソール出力も参照してください。
サンプルコード
This file contains hidden or 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 | |
# Load source Excel file | |
wb = Workbook("sampleSheetId.xlsx") | |
# Access first worksheet | |
ws = wb.worksheets[0] | |
# Print its Sheet or Tab Id on console | |
print("Sheet or Tab Id: " + str(ws.tab_id)) | |
# Change Sheet or Tab Id | |
ws.tab_id = 358 | |
# Save the workbook | |
wb.save("outputSheetId.xlsx") |
コンソール出力
Sheet or Tab Id: 1297