DBNumのカスタムパターン書式を指定する

可能な使用シナリオ

Aspose.Cellsは、DBNumのカスタムパターン書式をサポートしています。たとえば、セルの値が123で、そのカスタム書式を [DBNum2][$-804]一般 と指定した場合、それは壹佰贰拾叁のように表示されます。Cell.getStyle()およびStyle.setCustom()メソッドを使用してセルのカスタム書式を指定できます。

サンプルコード

次のサンプルコードは、DBNum のカスタムパターン書式を指定する方法を示しています。詳細については、出力PDF をご確認ください。

// 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(SpecifyingDBNumCustomPatternFormatting.class) + "data/";
//Create a workbook.
Workbook wb = new Workbook();
//Access first worksheet.
Worksheet ws = wb.getWorksheets().get(0);
//Access cell A1 and put value 123.
Cell cell = ws.getCells().get("A1");
cell.putValue(123);
//Access cell style.
Style st = cell.getStyle();
//Specifying DBNum custom pattern formatting.
st.setCustom("[DBNum2][$-804]General");
//Set the cell style.
cell.setStyle(st);
//Set the first column width.
ws.getCells().setColumnWidth(0, 30);
//Save the workbook in output pdf format.
wb.save(dataDir + "outputDBNumCustomFormatting.pdf", SaveFormat.PDF);