Click here to Skip to main content
12,893,027 members (57,421 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET MS-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
Updated 11-Dec-12 6:43am

1 solution

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

Solution 1

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)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170424.1 | Last Updated 11 Dec 2012
Copyright © CodeProject, 1999-2017
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