Hi!
I'm doing some Excel Exports on the ASP.NET Site. Everything works except of the Encoding. When I open it in Excel, it looks like this:
Eingabe Kosten je Gerät Gerät: Gerätebezeichnung: Betriebsmittel Heizöl in €: 4 Dieselverbrauch in €: 4
This is my code:
Response.Clear();
Response.ContentType = "application/ms-excel";
Response.AddHeader("Content-Disposition", "inline;filename=NachkalkGeraete.xls;");
var writer = new HtmlTextWriter(Response.Output);
SomeControl.RenderControl(writer); /* FormView, Table, DataGrid... */
Response.End();
I've already tried explicitly set the Encoding.. but no change occured:
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment; filename=NachkalkGeraete.xls");
Response.BufferOutput = true;
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Charset = "UTF-8";
EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
SomeControl.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
What is wrong, please?