Accesso e modifica dell etichetta di visualizzazione dell oggetto Ole collegato
Possibili Scenari di Utilizzo
Microsoft Excel permette di cambiare l’etichetta di visualizzazione dell’Ole Object come mostrato nello screenshot seguente. Puoi anche accedere o modificare l’etichetta di visualizzazione dell’Ole object usando le API di Aspose.Cells per Python via .NET con la proprietà OleObject.Label.
Accesso e modifica dell’etichetta di visualizzazione dell’oggetto Ole collegato
Si prega di vedere il seguente codice di esempio, carica il file Excel di esempio che contiene l’oggetto Ole. Il codice accede all’oggetto Ole e ne cambia l’etichetta da Sample APIs a Aspose APIs. Si prega di vedere l’output della console qui sotto che mostra l’effetto del codice di esempio sul file Excel di esempio per un riferimento.
Codice di Esempio
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) |
Output della console
Ole Object Label - Before: Sample APIs
Ole Object Label - After: Aspose APIs