G
Guillermo Rosich Capablanca
I have a problem with utf-8 enconding and I don't know
what to do in order to make it work.
I want to open a new window with excel data so the user
can choose to save it local. Everything works fine, the
new window, the excel data appears, but, extended
characters are wrong.
I call the window from an aspx page using this:
<script language='javascript'> window.open
('excelviewer.aspx?nif=...&id=.....
then, excelviewer.aspx.cs has this:
private void showExcel (DataSet ds) {
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-
Disposition", "inline;filename=consulta.csv");
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Charset = "utf-8";
//Response.AppendHeader("Content-Transfer-Encoding",
Response.ContentEncoding.EncodingName);
System.Globalization.CultureInfo culture = new
System.Globalization.CultureInfo("es");
System.IO.StringWriter sw = new System.IO.StringWriter
(culture);
HtmlTextWriter htmlw = new HtmlTextWriter(sw);
htmlw.AddAttribute
(HtmlTextWriterAttribute.Title, "Consulta");
DataGrid dg = new DataGrid();
dg.DataSource = ds.Tables[0];
dg.DataBind();
dg.RenderControl(htmlw);
Response.Write(htmlw.InnerWriter);
Response.Flush();
Response.Close();
}
That is the C# code, it works fine, the new window
appears with the excel content and the correct columns
and rows, but several extended characters appears badly.
I saw on IE view and there is no AutoSelect and UTF-8 is
selected instead.
Also on the aspx I put this <%@ Page language="c#"
ResponseEncoding="UTF-8" Codebehind="excelviewer.aspx.cs"
AutoEventWireup="false"
Inherits="ROCAMP.Formularis.excelviewer" %> but nothing.
Here you can find some explample of the output, it is
just a part of the columns, and only the first line:
NIF NOM ESTAT CARNET NÃsMERO MOVIMENT BORSA DATA
INICI
38112294Y David Bernal Manero Finalitzat BÃ?SIC
BA100000/03 Expedició No 21/01/2004
it should look like this:
NIF NOM ESTAT CARNET NÚMERO MOVIMENT BORSA DATA
INICI
38112294Y David Bernal Manero Finalitzat BÀSIC
BA100000/03 Expedició No 21/01/2004
If anyone could give me some advice, I'll appreciate it
very much.
thanx in advance,
Guillermo.
what to do in order to make it work.
I want to open a new window with excel data so the user
can choose to save it local. Everything works fine, the
new window, the excel data appears, but, extended
characters are wrong.
I call the window from an aspx page using this:
<script language='javascript'> window.open
('excelviewer.aspx?nif=...&id=.....
then, excelviewer.aspx.cs has this:
private void showExcel (DataSet ds) {
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-
Disposition", "inline;filename=consulta.csv");
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Charset = "utf-8";
//Response.AppendHeader("Content-Transfer-Encoding",
Response.ContentEncoding.EncodingName);
System.Globalization.CultureInfo culture = new
System.Globalization.CultureInfo("es");
System.IO.StringWriter sw = new System.IO.StringWriter
(culture);
HtmlTextWriter htmlw = new HtmlTextWriter(sw);
htmlw.AddAttribute
(HtmlTextWriterAttribute.Title, "Consulta");
DataGrid dg = new DataGrid();
dg.DataSource = ds.Tables[0];
dg.DataBind();
dg.RenderControl(htmlw);
Response.Write(htmlw.InnerWriter);
Response.Flush();
Response.Close();
}
That is the C# code, it works fine, the new window
appears with the excel content and the correct columns
and rows, but several extended characters appears badly.
I saw on IE view and there is no AutoSelect and UTF-8 is
selected instead.
Also on the aspx I put this <%@ Page language="c#"
ResponseEncoding="UTF-8" Codebehind="excelviewer.aspx.cs"
AutoEventWireup="false"
Inherits="ROCAMP.Formularis.excelviewer" %> but nothing.
Here you can find some explample of the output, it is
just a part of the columns, and only the first line:
NIF NOM ESTAT CARNET NÃsMERO MOVIMENT BORSA DATA
INICI
38112294Y David Bernal Manero Finalitzat BÃ?SIC
BA100000/03 Expedició No 21/01/2004
it should look like this:
NIF NOM ESTAT CARNET NÚMERO MOVIMENT BORSA DATA
INICI
38112294Y David Bernal Manero Finalitzat BÀSIC
BA100000/03 Expedició No 21/01/2004
If anyone could give me some advice, I'll appreciate it
very much.
thanx in advance,
Guillermo.