0

Am getting an error when I export dynamically created html table to excel. the error says

Missing File: ~\Temporary Internet Files\Content.IE5\style.css. 

when I say ok then the excel opens with the data displayed on browser. Don't know where am going wrong. Below is the code to excel export.

Response.ContentType = "application/x-msexcel";
Response.Clear();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.AddHeader("Content-Disposition", "attachment; filename=ExcelFilenew.xls"); 
StringWriter tw = new StringWriter(); 
HtmlTextWriter hw = new HtmlTextWriter(tw);
HtmlTbl.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
शेखर
  • 17,412
  • 13
  • 61
  • 117
Aswini
  • 51
  • 4
  • 16

1 Answers1

0

You must do your export to XLS file and the whole XLS(x?) file creation on the server side. This way as you do it you are probably trying to open HTML as XLS file at the client.

Create your XLSX file completely on the server side using some library like EPPlus and then send the resulting file to the client as a Response of ContentType = application/x-msexcel or better see this answer for what type of response you should use.

Community
  • 1
  • 1
Vojtěch Dohnal
  • 7,867
  • 3
  • 43
  • 105