Click here to Skip to main content
15,879,490 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to export some values to Excel. I am able to export values like 1.23, 5.45,9.25 successfully with decimal values by specifying dataFormatString = {0:N2}. But the same is not working when I export 0.00, the decimal values 00 after the period are removed . So I am just seeing '0' instead of '0.00'. Below is the code I am using Any help would be appreciated.

C#
if (column.ColumnType == ViewColumnType.Numeric)
                {
                    var dataFormatString = "{0:N2}";
                    string rowText = string.Format(dataFormatString, "0.00");
                }

string newText = rowText.Replace("\"", "\"\"");
                    _writer.Write(string.Format("\"{0}\"", newText));

[Edit]Code block added[/Edit]
Posted
Updated 11-Dec-12 6:43am
v2

1 solution

You need to format the column in excel. have a look at this: http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/fdc6cfb5-e7cc-466f-95f0-d8cd29f49d2d/[^]
 
Share this answer
 
Comments
DinoRondelly 11-Dec-12 13:15pm    
Thats just crazy enough to work +5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900