I'm sending an excel file as an attachment. the file is generated from an HTML table and when I open it, I receive a warning message stating: "the file format and extension don't match....."
here's my code:
string html = "<table><tr><td>Test</td></tr></table>";
System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType("application/vnd.ms-excel");
Attachment a = Attachment.CreateAttachmentFromString(html.ToString(), ct);
a.ContentDisposition.FileName = "Test.xls";
Am I missing something in this snippet?
Thanks in advance for the help,
thanks inadvance for the help .
The file does actually open and render correctly. So, what I really should have asked was can excel render html without giving this message. Which the answer appears to be - no. Or at least, I couldn't find a solution after a day of digging. I used openXML to generate the spreadsheet I want which works wonders (and only took me a couple of hours.)