Using Built-in Styles

How to use Built-in Styles

The method Workbook.createBuiltinStyle and class BuiltinStyleType make it convenient to create re-usable styles. Here is a list of all possible built-in styles:

The following code demonstrates how to use built-in styles.

todo:image_alt_text

// 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);