I would like to know how to Convert HTML to Excel using Open XML. I have an html file and I want to export it, as it is in Excel 2007 format.
Please suggest me with sample code.
Below is a Html file that is getting generated
Are you talking about converting a table from HTML to Excel? Other than that, it's not clear to me how you would convert HTML to Excel. You can look at my blogs about creating Excel spreadsheets: Quick Generation of Spreadsheet Data and Cell Styles. You would need to code the part that reads the HTML and creates the data structures used to generate the spreadsheet.
I have updated html above. Yes. Its table within table.
Manually how I do is, excel 2007 >> data >> from web >> give url >> click import, while importing go to options and select "full HTML formatting" radio button, this imports the html perfectly with all formatting preserved, in to excel 2007.
Same thing I want to achieve through c# code using OpenXml. I do not want to use Excel Automation (Microsoft.Office.Interop.Excel) as it requires excel 2007 or share point installed on target machine.
I don't know of any sample code that directly addresses this. If you know how to process through the HTML, then you should be able to feed that data into the structures from the example I mentioned above. There is an example of converting HTML into a Word document. You can find that in the PowerTools for OpenXML
The Open XML SDK provides a way to create and modify documents. It does not replicate the capabilities of the Microsoft Office products. As you point out, Office Automation serves that purpose.