CellsFactoryクラスを使用してスタイルオブジェクトを作成する

CellsFactoryクラスを使用してスタイルオブジェクトを作成する

次のサンプルコードは、CellsFactoryクラスを使用してStyleオブジェクトを作成し、その後、ブックのデフォルトスタイルを設定します。参照のために出力エクセルファイル をダウンロードして結果を確認してください。

サンプルコード

// 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.getSharedDataDir(CreateStyleobjectusingCellsFactoryclass.class) + "articles/";
// Create a Style object using CellsFactory class
CellsFactory cf = new CellsFactory();
Style st = cf.createStyle();
// Set the Style fill color to Yellow
st.setPattern(BackgroundType.SOLID);
st.setForegroundColor(Color.getYellow());
// Create a workbook and set its default style using the created Style
// object
Workbook wb = new Workbook();
wb.setDefaultStyle(st);
// Save the workbook
wb.save(dataDir + "CreateStyleobject_out.xlsx");