Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Fri Jan 14, 2022 8:42 pm

Hi,

I would like to know how to convert a number so that it looks like this: "1.175.575,40"

I tried "#,##0.00" and also "#.##0.00"

Both ways come out:

"1,175,575.40"

I need the comma in the decimal places on the right


Grateful,
Guiherme

guiherme
 
Posts: 2
Joined: Fri Jan 14, 2022 8:18 pm

Mon Jan 17, 2022 3:00 am

Hello,

Thanks for your inquiry!

Kindly note that the character used to separate thousands or decimals in Excel is controlled by the Excel options or your region settings, but not the number format. Even in the Microsoft Excel, if your region setting did not use "," to separate decimals, there is no way to change it by number format. Our Spire.Xls following the MS Excel standard, sorry that we cannot support too.

Here, I provided two methods for you to change the value to your needs.

First, change the Excel options or region settings according to the Microsoft official documents.

Or you can also refer to the following code to use SUBSTITUTE formula to replace the "," and ".".
Code: Select all
            Workbook workbook = new Workbook();

            CellRange range = workbook.Worksheets[0]["A1"];
            range.Value = "1175575.40";
            range.NumberFormat = "#,###.00";
            range.Formula = "SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(\"" +range.NumberText + "\",\".\",\"*\"),\",\",\".\"),\"*\",\",\")";
            range.NumberFormat = "general";
           
            //Save the result file
            workbook.SaveToFile("NumberFormat.xlsx", FileFormat.Version2013);


If you have any other questions, just feel free to contact us.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Jan 24, 2022 8:43 am

Hello,

Hope you are doing well!

Has the issue been solved now? Could you please give us some feedback at your convenience?

Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Jan 24, 2022 3:35 pm

Thanks, it's working.

guiherme
 
Posts: 2
Joined: Fri Jan 14, 2022 8:18 pm

Tue Jan 25, 2022 1:09 am

Hello,

Thanks for your feedback!

Glad to hear that your issue has been solved.

If you encounter any issues related to our product in the future, just feel free to contact us.

Have a nice day!

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Return to Spire.XLS