Extraer datos de tema de archivo de Excel
Aspose.Cells permite a los usuarios extraer datos relacionados con el tema de un archivo de Excel. Por ejemplo, puede extraer el nombre del tema aplicado al libro de trabajo y el color del tema aplicado a la celda o bordes de la celda, etc.
Puede aplicar un tema a su libro de trabajo usando Microsoft Excel a través del comando Diseño de página > Temas.
Ejemplo
// 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); |
Salida de ejemplo
Aquí hay una muestra de la salida de consola del código anterior.
Civic
true
true