How to save format in HTML converted to Excel

I am working with an HTML table containing numbers (formated), and when I export it to an xls file (just change the extension ... hehe). I lost some of the data generated.

Example:

in html I have "1,000.00 | 500.00 | 20.00" and in excel it shows as: "1000.00 | 500 | 20"

I want him to know if the same format can be shown as in html.

THankyou: P

+4
source share
3 answers

you can achieve this using the class. eg:

add class first

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 the figure: Export to Excel in ASP.NET, decimal formatted edition for numbers greater than 1000

+1
source

I have done it. The best way to tell is to create a .xls file (not a .xlsx) and then save it as an html file.

Then look at the source of the html file. You will see some css classes at the top, and then if you look at the data below, you will see that they apply to the sheet.

So just a little reverse engineering ...

FYI - if you try to open it in 2007 or later, you will get an initial warning, but then everything will work fine.

+1
source

You can open Excel and import it as data, where it will ask you for a separator and data type for each column. You can also just manually select columns and add formatting.

0
source

Source: https://habr.com/ru/post/1312252/


All Articles