Estrai dati del tema dai file Excel
Aspose.Cells per Python via .NET consente agli utenti di estrarre dati relativi ai temi dai file Excel. Ad esempio, puoi estrarre il nome del tema applicato al libro di lavoro e il colore del tema applicato alle celle o ai bordi delle celle, ecc.
Puoi applicare un tema al tuo foglio di lavoro usando Microsoft Excel tramite il comando Layout Pagina > Temi.
Codice C# per estrarre i dati del tema dal file Excel
Il seguente codice di esempio estrae il nome del Tema applicato al foglio di lavoro di origine e quindi estrae il colore del Tema applicato alla cella A1 e il colore del Tema applicato al bordo inferiore della cella.
from aspose.cells import BorderType, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Create workbook object | |
workbook = Workbook(dataDir + "source.xlsx") | |
# Extract theme name applied to this workbook | |
print(workbook.theme) | |
# Access first worksheet | |
worksheet = workbook.worksheets[0] | |
# Access cell A1 | |
cell = worksheet.cells.get("A1") | |
# Get the style object | |
style = cell.get_style() | |
if style.foreground_theme_color != None: | |
# Extract theme color applied to this cell if theme has foregroundtheme color defined | |
print(style.foreground_theme_color.color_type) | |
else: | |
print("Theme has not foreground color defined.") | |
# Extract theme color applied to the bottom border of the cell if theme has border color defined | |
bot = style.borders.get(BorderType.BOTTOM_BORDER) | |
if bot.theme_color != None: | |
print(bot.theme_color.color_type) | |
else: | |
print("Theme has not Border color defined.") |