I'm working with an HTML table, that contains numbers (formated) and when I export this to xls file (just change extension... hehe) I loss some of the formated data.
Example:
in html I have " 1,000.00 | 500.00 | 20.00 " and in excel it shows like: "1,000.00 | 500 | 20"
I want it to know if it is possible to show the very same format as in html.
THankyou :P
you can achive that by using class. for example:
first add class
writer.WriteLine("<style> .number{mso-number-format:\"\\#\\#0\\.00\";} </style>");
and then, in your iteration :
writer.Write("<td class=\"number\" >");
writer.Write(data);
writer.WriteLine("</td>");
as shown in : Export to Excel in ASP.NET, issue with decimal formatting for numbers greater than 1000
I've done this. The best way to tell is to create an .xls file (not .xlsx) and then save it as an html file.
Then look at the source of the html file. You'll see some css classes at the top and then if you look at the data below you'll see them being applied to the sheet.
So just a bit of reverse engineering...
FYI - if you try to open this up in 2007 or later, you'll get an initial warning but then all works OK.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With