Convert HTML table to Excel using C #

I have an html table in a Microsoft.Office.Interop.Outlook.MailItem object, and I just need to populate the excel sheet with this table using C # for a desktop application. Can anyone help me in this regard. Thanks

+5
source share
2 answers

Quick and dirty way:

File.WriteAllText(@"C:\Temp\Table.xls", mailItem.Body);

Excel will open it even if the file does not contain a valid xls document

+3
source

You can also use HtmlAgilityPack for parsing email and EPPlus for writing to Excel (xlsx 2007/2010 only).

0
source

All Articles