使用内置样式

如何使用内置样式

方法Workbook.createBuiltinStyle和类BuiltinStyleType使得方便创建可重复使用的样式。这里是所有可能内置样式的列表:

以下代码演示了如何使用内置样式。

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