Exporting Datagrid's data to an Excel Sheet.

  • Thread starter Thread starter http://www.visual-basic-data-mining.net/forum
  • Start date 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

Back
Top