asp.netexcelcsvexponentiation

ASP.NET CSV Response, Excel Exponential Format Issue


In my ASP.NET application, I need to write DataTable as CSV response to the customer. Everything is working fine except a column which has a numbers.

Ex: 7002136138603600000

But when I open the CSV in Excel, it is showing in exponential format.

Something like this: 7E+18

Could you please let me know what needs to be done in order to show these values as test instead in exponential format?

Thanks, Mahesh


Solution

  • Regarding the CSV numbers format, check here: http://support.microsoft.com/kb/214233


    I did export to Excel many times. Just write the output of the Gridview to a String Builder using an HtmlTextWriter send the response.

    You can find two examples of doing this:

    More search results: http://www.google.com/search?q=export+gridview+to+excel

    So, I think the easiest way is to bind to GridView and write it as HTML as in the other examples, unless you need CSV for another reason also.