Извлечение данных темы из файла Excel
Aspose.Cells для Python via .NET позволяет пользователям извлекать тематические данные из файла Excel. Например, можно извлечь название темы, применённое к книге, цвет темы, применённый к ячейке или границам ячейки и т. д.
Вы можете применить тему к своей книге с помощью Microsoft Excel через команду Разметка страницы > Темы.
Код на C#, извлекающий данные темы из файла Excel
В следующем образце кода извлекается название темы, примененной к исходной книге, а затем извлекается цвет темы, примененный к ячейке A1, и цвет темы, примененный к нижнему краю ячейки.
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.") |