Click here to Skip to main content
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
ProgramFOX119.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 Sergey Alexandrovich Kryukov 459
1 Nirav Prabtani 338
2 Abhinav S 170
3 PIEBALDconsult 160
4 Pikoh 140
0 OriginalGriff 7,640
1 Sergey Alexandrovich Kryukov 6,836
2 Maciej Los 3,919
3 Peter Leow 3,698
4 CHill60 2,742


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 11 Dec 2012
Copyright © CodeProject, 1999-2014
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