Exporting Datagrid's data to an Excel Sheet.

  • Thread starter http://www.visual-basic-data-mining.net/forum
  • Start date
H

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

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top