Extraire les données de thème du fichier Excel
Aspose.Cells permet aux utilisateurs d’extraire des données liées au thème à partir d’un fichier Excel. Par exemple, vous pouvez extraire le nom du thème appliqué au classeur et la couleur du thème appliqué à la cellule ou aux bordures de cellules, etc.
Vous pouvez appliquer un thème à votre classeur à l’aide de Microsoft Excel via la commande Mise en page > Thèmes.
Exemple
// 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); |
Résultat d’échantillon
Voici un exemple de sortie console du code ci-dessus.
Civic
true
true