Geeks With Blogs
Fórmulas e Cenas Object Reference Not Set to an Instance of an Object
Just a simple snippet to show how an aspx can be exported to Excel



Response.ClearContent();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition", "attachment; filename=" + "teste" + ".xls;charset=iso-8859-1");

StreamWriter sw = new StreamWriter(Response.OutputStream, System.Text.Encoding.GetEncoding("iso-8859-1"));
HtmlTextWriter htmlTextWriter = new HtmlTextWriter(sw);
this.RenderControl(htmlTextWriter);

Response.End(); Posted on Friday, April 17, 2009 5:49 PM Asp.Net , C# | Back to top


Comments on this post: Export Aspx to Excel

# re: Export Aspx to Excel
Requesting Gravatar...
Excelent friend, but i have a question,
how about if i want export images???
for example if i have a table that have an image, i actually make it but the image cant be renderized
how can i make it????
Left by Jules on Feb 15, 2010 10:29 AM

# re: Export Aspx to Excel
Requesting Gravatar...
eXCUSe me, i tried again, and all works fine.
Left by JULES on Feb 15, 2010 10:45 AM

# re: Export Aspx to Excel
Requesting Gravatar...
Sorry, how do I use that snippet? And in what program language is that? I newbie for this thing but I can learn fast :-) Thanks
Left by Moh on May 12, 2011 1:43 AM

Your comment:
 (will show your gravatar)


Copyright © Sglima | Powered by: GeeksWithBlogs.net