'Create EXCEL from html table using C#
I am trying to create an excel sheet for shipping products using C# and HTML table. The image shown below is my HTML as it looks in the browser. What I am trying to do it to take this table and shove it into an excel page keeping proportions and merges intact. (I put a border color on each td to symbolise the cells in excel, that color wont be necessary once it's in Excel sheet).
I tried working from this post (How to export html table to excel using asp.net/c#) but when using this code my table hasnt become cells when its in the file, its just one cell with text in it.
To be added, when using the code on that link i took a copy of the code in the aspx page and put it as a html string which was then added to the form, as shown in the example on the link. This then produced the same form that I had previously made by hand.
var html = "<tabe><tr><td width=\"86\">x</td><td width=\"72\">x</td><td width=\"91\">x</td><td width=\"72\">x</td><td width=\"72\">x</td><td width=\"139\">x</td><td width=\"93\">x</td><td width=\"72\">x</td><td width=\"72\">x</td><td width=\"72\">x</td><td width=\"72\">x</td><td width=\"72\">x</td></tr><tr><td rowspan=\"5\" colspan=\"2\" style=\"border: solid 2px black;\">INVOICE</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td rowspan=\"2\" colspan=\"2\" style=\"background-color: green;\">Ref</td><td></td><td style=\"background-color: green;\">Swiss Post</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td style=\"background-color: yellow;\">SoBling</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>";
What am I doing wrong?
Solution 1:[1]
I made you a few links that will help you with merging, width, height and creating Excell. I have made links only refering SO that should work togeather.
creating simple excel sheet in c# with strings as input
Merging Cells in Excel using C#
width and heigth are 'same'. I havent dish out you a solution in terms on code, rather the links so you make your own solution and learn from it. Ask if you have questions.
Solution 2:[2]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Community |
Solution 2 | user287107 |