Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Gridview - Convert to Excel and Save on Server Automatically

Reply
Thread Tools

Gridview - Convert to Excel and Save on Server Automatically

 
 
John Walker
Guest
Posts: n/a
 
      03-06-2009
Hi,

I am using the following code to convert an asp.net 2.0 gridview to Excel.
When this happens the user will be prompted to either open the file, save it
to disk, cancel, etc., and it works fine but now there's a new requirement
whereby I'll need to have the gridview automatically saved as an Excel file
on the server's hard drive instead of being downloaded to the client browser.
Is there a way to accomplish that?

Dim resp As HttpResponse
resp = Page.Response
resp.ContentType = "application/download"
Page.EnableViewState = False
resp.Charset = String.Empty
resp.AppendHeader("Content-Disposition",
"attachment;filename=PerformanceRpt.xls")
Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
gv.AllowPaging = False
gv.RenderControl(hw)


Thanks,
John
 
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
Problem with Excel reports ::::Excel 2003 Migration To Excel 2007 =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?= ASP .Net 15 10-24-2007 01:34 PM
how to automatically "Save " a page after certain intervals without clicking "Save Page As..." subhadip Java 0 03-28-2007 04:15 PM
Saving Excel Files on Server Automatically puneet.bansal@wipro.com Java 1 04-22-2005 09:52 PM
how to save the out html to a html file on server disk automatically ? sincethe2003 ASP .Net 2 07-14-2004 05:18 PM
Excel open automatically without giving a dialog box option to Open/Save/Cancel using filesys.create eddie wang ASP General 0 10-03-2003 04:05 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57