Specifying DBNum Custom Pattern Formatting
Possible Usage Scenarios
Aspose.Cells for Node.js via C++ supports the DBNum custom pattern formatting. For example, if your cell value is 123 and you specify its custom formatting as [DBNum2][$-804]General then it will be displayed like 壹佰贰拾叁. You can specify your custom formatting of the cell using Cell.getStyle() method and Style.setCustom(string) method.
Sample Code
The following sample code illustrates how to specify DBNum custom pattern formatting. Please check its output PDF for more help.
const path = require("path"); | |
const AsposeCells = require("aspose.cells.node"); | |
// Create a workbook. | |
const wb = new AsposeCells.Workbook(); | |
// Access first worksheet. | |
const ws = wb.getWorksheets().get(0); | |
// Access cell A1 and put value 123. | |
const cell = ws.getCells().get("A1"); | |
cell.putValue(123); | |
// Access cell style. | |
const 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(path.join(dataDir, "outputDBNumCustomFormatting.pdf"), AsposeCells.SaveFormat.Pdf); |