469,942 Members | 2,516 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,942 developers. It's quick & easy.

Exporting Datagrid's data to an Excel Sheet.

I have a web form in which I have a datagrid, I need to export this data to
a Microsoft Excel sheet.

I'm doing it thus:

Response.Clear();

Response.Buffer= true;

Response.ContentType = "application/vnd.ms-excel";

Response.Charset = "";

this.EnableViewState = false;

System.IO.StringWriter oStringWriter = new System.IO.StringWriter();

System.Web.UI.HtmlTextWriter oHtmlTextWriter = new
System.Web.UI.HtmlTextWriter(oStringWriter);

DataGrid1.RenderControl(oHtmlTextWriter);

Response.Write(oStringWriter.ToString());

Response.End();

But I'd like to avoid system ask user if desires open or save this file,
instead would open excel sheet as another window and when user saves the
file it be saved as an excel file.

Does somebody knows how achieve this?

I'll appreciate it very much.

A.L.

--
see07 - forum member
http://www.visual-basic-data-mining.net/forum
Nov 18 '05 #1
1 1269
This article provides a good example for you:
http://www.aspnetpro.com/NewsletterA...200309so_l.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"http://www.visual-basic-data-mining.net/forum" <si******@gmail.com> wrote
in message news:ub**************@TK2MSFTNGP11.phx.gbl...
I have a web form in which I have a datagrid, I need to export this data to
a Microsoft Excel sheet.

I'm doing it thus:

Response.Clear();

Response.Buffer= true;

Response.ContentType = "application/vnd.ms-excel";

Response.Charset = "";

this.EnableViewState = false;

System.IO.StringWriter oStringWriter = new System.IO.StringWriter();

System.Web.UI.HtmlTextWriter oHtmlTextWriter = new
System.Web.UI.HtmlTextWriter(oStringWriter);

DataGrid1.RenderControl(oHtmlTextWriter);

Response.Write(oStringWriter.ToString());

Response.End();

But I'd like to avoid system ask user if desires open or save this file,
instead would open excel sheet as another window and when user saves the
file it be saved as an excel file.

Does somebody knows how achieve this?

I'll appreciate it very much.

A.L.

--
see07 - forum member
http://www.visual-basic-data-mining.net/forum

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Anthony | last post: by
1 post views Thread by Matt | last post: by
3 posts views Thread by | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.