Extract Theme Data from Excel File
Aspose.Cells for Python via .NET allows the users to extract Theme related data from Excel file. For example, you can extract Theme Name applied to workbook and Theme Color applied to cell or borders of the cell, etc.
You can apply Theme to your workbook using Microsoft Excel via Page Layout > Themes command.
C# code to extract theme data from Excel file
The following sample code extracts the Theme name applied to source workbook and then it extracts the Theme color applied to cell A1 and Theme color applied to the bottom border of the cell.
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.") |