Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Exporting Datagrid's data to an Excel Sheet.

Reply
Thread Tools

Exporting Datagrid's data to an Excel Sheet.

 
 
http://www.visual-basic-data-mining.net/forum
Guest
Posts: n/a
 
      10-25-2004
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


 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      10-25-2004
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" <(E-Mail Removed)> wrote
in message news:(E-Mail Removed)...
>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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting to Excel using new version of Excel Doogie ASP .Net 1 11-19-2008 09:10 PM
Exporting Repeater data to an Excel Spreadsheet Roberto Lopes ASP .Net 1 12-27-2007 03:21 PM
Exporting to Excel with Unicode data Bernard O'Flynn ASP .Net 1 08-22-2007 09:48 PM
exporting an excel file from database; making changes to excel file and updating the database by importing it back Luis Esteban Valencia ASP .Net 1 01-12-2005 12:28 AM
Exporting data to Microsoft Excel from a Web Form (using OWC) problem sarah5e@yahoo.com ASP .Net 1 05-10-2004 01:45 PM



Advertisments