Specifying DBNum Custom Pattern Formatting

Possible Usage Scenarios

Aspose.Cells for Python via .NET 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.custom property.

Sample Code

The following sample code illustrates how to specify DBNum custom pattern formatting. Please check its output PDF for more help.

from aspose.cells import SaveFormat, Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Create a workbook.
wb = Workbook()
# Access first worksheet.
ws = wb.worksheets[0]
# Access cell A1 and put value 123.
cell = ws.cells.get("A1")
cell.put_value(123)
# Access cell style.
st = cell.get_style()
# Specifying DBNum custom pattern formatting.
st.custom = "[DBNum2][$-804]General"
# Set the cell style.
cell.set_style(st)
# Set the first column width.
ws.cells.set_column_width(0, 30)
# Save the workbook in output pdf format.
wb.save(dataDir + "outputDBNumCustomFormatting.pdf", SaveFormat.PDF)