Access and Modify the Display Label of the Linked Ole Object
Possible Usage Scenarios
Microsoft Excel allows you to change the display label of the Ole Object as shown in the following screenshot. You can also access or modify the display label of the Ole object using Aspose.Cells for Python via .NET APIs with the OleObject.Label property.
Access and Modify the Display Label of the Linked Ole Object
Please see the following sample code, it loads the sample Excel file that contains the Ole Object. The code accesses the Ole Object and changes its Label from Sample APIs to Aspose APIs. Please see the console output given below that shows the effect of the sample code on the sample Excel file for a reference.
Sample Code
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) |
Console Output
Ole Object Label - Before: Sample APIs
Ole Object Label - After: Aspose APIs