Click here to Skip to main content
11,647,676 members (71,845 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Excel string export , +
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.
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 11-Dec-12 6:40am
Edited 11-Dec-12 6:43am
ProgramFOX163.3K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
DinoRondelly at 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)

  Print Answers RSS
0 jyo.net 500
1 F-ES Sitecore 370
2 OriginalGriff 322
3 DamithSL 315
4 CPallini 240
0 OriginalGriff 1,342
1 jyo.net 994
2 DamithSL 971
3 Sergey Alexandrovich Kryukov 873
4 CPallini 795


Advertise | Privacy | Mobile
Web04 | 2.8.150804.3 | Last Updated 11 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100