从 Excel 文件中提取主题数据
Contents
[
Hide
]
Aspose.Cells允许用户从Excel文件中提取与主题相关的数据。例如,您可以提取应用于工作簿的主题名称和应用于单元格或单元格边框的主题颜色等。
您可以使用Microsoft Excel通过“页面布局” >“主题”命令为工作簿应用主题。
示例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ExtractThemeData.class); | |
// Create workbook object | |
Workbook workbook = new Workbook(dataDir + "TestBook.xlsx"); | |
// Extract theme name applied to this workbook | |
System.out.println(workbook.getTheme()); | |
// Access first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Access cell A1 | |
Cell cell = worksheet.getCells().get("A1"); | |
// Get the style object | |
Style style = cell.getStyle(); | |
// Extract theme color applied to this cell | |
System.out.println(style.getForegroundThemeColor().getColorType() == ThemeColorType.ACCENT_2); | |
// Extract theme color applied to the bottom border of the cell | |
Border bot = style.getBorders().getByBorderType(BorderType.BOTTOM_BORDER); | |
System.out.println(bot.getThemeColor().getColorType() == ThemeColorType.ACCENT_1); |
示例输出
以下是上述代码的示例控制台输出。
Civic
true
true