ASP.NET Excel Export formatting question

Posted by BWC on Stack Overflow See other posts from Stack Overflow or by BWC
Published on 2010-03-08T22:45:25Z Indexed on 2010/03/09 0:36 UTC
Read the original article Hit count: 309

Filed under:
|

Hey Guys,

I've been banging my head on the wall over this issue for a couple days now and I need some help.

I'm creating an excel file using ASP.net and everything is going just fine except one column has to be formatted as a decimal to 2 places but when it pulls into excel, excel automatically formats it as a whole number instead of keeping the decimal places.

sw.Write(String.Format("{0:f}", CDbl(dr(14)).ToString("0.00"))) this produces "20.00"

but when I open it in excel it's displayed as 20...if I select the whole column and format it as a number it gets displayed as 20.00 like it's supposed to but I don't want to have to do this (I can't do that) the file is supposed to be automatically picked up and imported into another system that needs the column to be a decimal.

Any suggestions would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about excel