We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

NumberSeparator not working

Hi all,
I using aspose cell 19.2 and I want to set NumberSeperator for workbook.
I’m trying to set prop Settings.NumberGroupSeparator and Settings.NumberDecimalSeparator
and changing CultureInfo, but it does not work.
This is my sample code:

var _wb = new Workbook();
_wb.Settings.NumberGroupSeparator = '.';
_wb.Settings.NumberDecimalSeparator = ',';
//_wb.Settings.CultureInfo = exportCulture;

var _ws = _wb.Worksheets[0];
var _cell = _ws.Cells[0, 0];
_cell.PutValue(1234567);

var _style = _cell.GetStyle();
_style.Custom = "#,##0.00";
_cell.SetStyle(_style);

_wb.Save("d:\\_test.xlsx", SaveFormat.Xlsx);

@DungLT,

Thanks for code segment and details.

As you just save the workbook to an Excel file. I am afraid it has nothing to do with this issue. the settings of NumberSeparator is just for formatting by Aspose.Cells APIs, such as, getting the cell’s formatted string value. Please note, the settings cannot change the behavior of MS Excel.

Well, you do not need to set those separators separately, the better way is to customize the used CultureInfo for the workbook. You may select or create one CultureInfo whose decimal separator is ‘,’ and group separator is ‘.’ and set it to the workbook. See the sample code for your reference:
e.g
Sample code:

 var _wb = new Workbook();
            _wb.Settings.Region = CountryCode.Germany;//I choose Germany which has your desired group separator and decimal separator.

            var _ws = _wb.Worksheets[0];
            var _cell = _ws.Cells[0, 0];
            _cell.PutValue(1234567);
            var _style = _cell.GetStyle();
            _style.Custom = "#,##0.00";
            _cell.SetStyle(_style);
            _ws.AutoFitColumn(0);

            _wb.Save("e:\\test2\\_test1.xlsx", SaveFormat.Xlsx);
            _wb.Save("e:\\test2\\out1.pdf");//confirmed the output is ok.

Hope, this helps a bit.

1 Like

Thank @Amjad_Sahi ,
I saving to pdf and it work fine :wink:

@DungLT,
Good to know that your issue is sorted out by the suggested line of code. Feel free to contact us at any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

1 Like