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

可能な使用シナリオ

Aspose.CellsはDBNum カスタムパターンフォーマットをサポートしています。たとえば、セルの値が123で、それを[DBNum2][$-804]一般のカスタムフォーマットとして指定すると、それは壱百弐拾参と表示されます。セルのカスタムフォーマットを指定するには、Cell.GetStyle()メソッドとStyle.Customプロパティを使用できます。

サンプルコード

次のサンプルコードはDBNum カスタムパターンフォーマットの指定方法を示しています。詳細については、出力PDFをチェックしてください。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
//Create a workbook.
Workbook wb = new Workbook();
//Access first worksheet.
Worksheet ws = wb.Worksheets[0];
//Access cell A1 and put value 123.
Cell cell = ws.Cells["A1"];
cell.PutValue(123);
//Access cell style.
Style st = cell.GetStyle();
//Specifying DBNum custom pattern formatting.
st.Custom = "[DBNum2][$-804]General";
//Set the cell style.
cell.SetStyle(st);
//Set the first column width.
ws.Cells.SetColumnWidth(0, 30);
//Save the workbook in output pdf format.
wb.Save(dataDir + "outputDBNumCustomFormatting.pdf", SaveFormat.Pdf);