Re: Export to Excell
- From: "Patrick.O.Ige" <naijacoder@xxxxxxxxxxx>
- Date: Sun, 11 Jun 2006 23:26:13 +1000
There is a good sample by Steve here at:-
http://steveorr.net/articles/ExcelExport.aspx
Patrick
"Webmills" <james@xxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1150022143.441123.33970@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi
I am exporting a datagrid to Excel using the code as below. The problem
that I am experiencing is that if my datagrid includes
characters, spurious A with an accent characters appear within the
export. I am certain that this should be remedied by changin the
charset and/or encoding, but I cannot seem to get it right.
// Set up the page for export.
this.EnableViewState = false;
Response.Clear();
Response.Buffer = true;
Response.Charset = "utf-8";
Response.ContentEncoding = Encoding.GetEncoding("utf-8");
// Set the content type.
Response.ContentType = "application/vnd.ms-excel";
// Set the title.
Response.AddHeader("content-disposition", "attachment; filename=" +
TITLE + ".xls");
// Create the string builder.
StringBuilder stringBuilder = new StringBuilder();
// Append the page start.
stringBuilder.AppendFormat("<html><head><link href=\"{0}/Styles.css\"
rel=\"style***\" type=\"text/css\" /></head><body>",
Session["RootPath"]);
// Create the html text writer.
HtmlTextWriter htmlTextWriter = new HtmlTextWriter(new
StringWriter(stringBuilder, CultureInfo.InvariantCulture));
// Render the controls.
phrTitle.RenderControl(htmlTextWriter);
phrFinished.RenderControl(htmlTextWriter);
dgdData.RenderControl(htmlTextWriter);
// Append the page end.
stringBuilder.Append("</body></html>");
// Write the output.
Response.Write(stringBuilder.ToString());
Response.End();
Any ideas?
Regards
James
.
- References:
- Export to Excell
- From: Webmills
- Export to Excell
- Prev by Date: Re: How to delete cookie
- Next by Date: Crystal Report based on embedded MDF
- Previous by thread: Export to Excell
- Next by thread: Global application Masterpages and Intellisense
- Index(es):