Specify Custom Number Decimal and Group Separators for Workbook
In Microsoft Excel, you can specify the Custom Decimal and Thousands Separators instead of using System Separators from the Advanced Excel Options as shown in the screenshot below.
Aspose.Cells for Pytho via .NET provides the WorkbookSettings.number_decimal_separator and WorkbookSettings.number_group_separator properties to set the custom separators for formatting/parsing numbers.
Specifying Custom Separators using Microsoft Excel
The following screenshot shows the Advanced Excel Options and highlights the section to specify the Custom Separators.
Specifying Custom Separators using Aspose.Cells for Python via .NET
The following sample code illustrates how to specify the Custom Separators using Aspose.Cells for Python via .NET API. It specifies the Custom Number Decimal and Group Separators as dot and space respectively.
C# code to specify custom Number Decimal and Group Separators
from aspose.cells import 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(".") | |
workbook = Workbook() | |
# Specify custom separators | |
workbook.settings.number_decimal_separator = '.' | |
workbook.settings.number_group_separator = ' ' | |
worksheet = workbook.worksheets[0] | |
# Set cell value | |
cell = worksheet.cells.get("A1") | |
cell.put_value(123456.789) | |
# Set custom cell style | |
style = cell.get_style() | |
style.custom = "#,##0.000;[Red]#,##0.000" | |
cell.set_style(style) | |
worksheet.auto_fit_columns() | |
# Save workbook as pdf | |
workbook.save(dataDir + "CustomSeparator_out.pdf") |