リンクされたオブジェクトの表示ラベルへのアクセスと変更
Contents
[
Hide
]
可能な使用シナリオ
Microsoft Excelでは、Oleオブジェクトの表示ラベルを変更できます。次のスクリーンショットのように、Aspose.Cells for Python via .NETのAPIを使用してOleオブジェクトの表示ラベルにアクセスまたは変更することも可能です。
リンクされたオブジェクトの表示ラベルへのアクセスと変更
次のサンプルコードを参照してください。Ole Objectを含むsample Excel fileを読み込みます。コードはOle Objectにアクセスし、そのラベルをサンプルAPIからAspose APIに変更します。下記のコンソール出力を参照してください。これはサンプルコードのサンプル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 SaveFormat, Workbook | |
from io import BytesIO | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Load the sample Excel file | |
wb = Workbook("sampleAccessAndModifyLabelOfOleObject.xlsx") | |
# Access first worksheet | |
ws = wb.worksheets[0] | |
# Access first Ole Object | |
oleObject = ws.ole_objects[0] | |
# Display the Label of the Ole Object | |
print("Ole Object Label - Before: " + oleObject.label) | |
# Modify the Label of the Ole Object | |
oleObject.label = "Aspose APIs" | |
# Save workbook to memory stream | |
ms = BytesIO() | |
wb.save(ms, SaveFormat.XLSX) | |
# Set the workbook reference to null | |
wb = None | |
# Load workbook from memory stream | |
wb = Workbook(ms) | |
# Access first worksheet | |
ws = wb.worksheets[0] | |
# Access first Ole Object | |
oleObject = ws.ole_objects[0] | |
# Display the Label of the Ole Object that has been modified earlier | |
print("Ole Object Label - After: " + oleObject.label) |
コンソール出力
Ole Object Label - Before: Sample APIs
Ole Object Label - After: Aspose APIs