Utilizando Estilos Incorporados
Contents
[
Hide
]
Aspose.Cells ofrece una vasta colección de estilos reutilizables para formatear una celda en un documento de hoja de cálculo. Podemos utilizar estilos incorporados en nuestro libro de trabajo y también crear estilos personalizados.
Cómo utilizar Estilos Incorporados
El método Workbook.createBuiltinStyle y la clase BuiltinStyleType facilitan la creación de estilos reutilizables. Aquí hay una lista de todos los posibles estilos incorporados:
- TWENTY_PERCENT_ACCENT_1
- TWENTY_PERCENT_ACCENT_2
- TWENTY_PERCENT_ACCENT_3
- TWENTY_PERCENT_ACCENT_4
- TWENTY_PERCENT_ACCENT_5
- TWENTY_PERCENT_ACCENT_6
- FORTY_PERCENT_ACCENT_1
- FORTY_PERCENT_ACCENT_2
- CUARENTA_PORCIENTO_RESALTADO_3
- CUARENTA_PORCIENTO_RESALTADO_4
- CUARENTA_PORCIENTO_RESALTADO_5
- CUARENTA_PORCIENTO_RESALTADO_6
- SESENTA_PORCIENTO_RESALTADO_1
- SESENTA_PORCIENTO_RESALTADO_2
- SESENTA_POR_CIENTO_ACENTO_3
- SESENTA_POR_CIENTO_ACENTO_4
- SESENTA_POR_CIENTO_ACENTO_5
- SESENTA_POR_CIENTO_ACENTO_6
- ACCENT_1
- ACCENT_2
- ACCENT_3
- ACCENT_4
- ACCENT_5
- ACCENT_6
- MAL
- CÁLCULO
- VERIFICAR_CELDA
- COMA
- COMA_1
- MONEDA
- MONEDA_1
- TEXTO_EXPLICATIVO
- BUENO
- ENCABEZADO_1
- ENCABEZADO_2
- ENCABEZADO_3
- ENCABEZADO_4
- VINCULO
- VINCULO_SEGUIDO
- ENTRADA
- CELDA_VINCULADA
- NEUTRAL
- NORMAL
- NOTA
- SALIDA
- PORCENTAJE
- TITULO
- TOTAL
- TEXTO_ADVERTENCIA
- NIVEL_FILA
- NIVEL_COLUMNA
El siguiente código demuestra cómo utilizar estilos integrados.
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 | |
String dataDir = Utils.getDataDir(UsingBuiltinStyles.class); | |
String output1Path = dataDir + "Output.xlsx"; | |
String output2Path = dataDir + "Output.ods"; | |
Workbook workbook = new Workbook(); | |
Style style = workbook.createBuiltinStyle(BuiltinStyleType.TITLE); | |
Cell cell = workbook.getWorksheets().get(0).getCells().get("A1"); | |
cell.putValue("Aspose"); | |
cell.setStyle(style); | |
workbook.getWorksheets().get(0).autoFitColumn(0); | |
workbook.getWorksheets().get(0).autoFitRow(0); | |
workbook.save(output1Path); | |
System.out.println("File saved " + output1Path); | |
workbook.save(output2Path); | |
System.out.println("File saved " + output2Path); |