Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 1st, 2007, 01:10 AM
Authorized User
 
Join Date: Aug 2007
Location: , , Singapore.
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yukijocelyn
Default File stream Gridview to Excel

Hi

I need help in this part. I need to send and attachment(.xls file) which contains the data in the gridview of my page where users chooses the data. My Gridview will then filter out and give me the details of those whose data matching the filtering conditions.

I then will have to export these data into an excel file, which I will email these details out immediately. I want the saving of the file to be in the background unlike the codes that I have now, which prompts me on whether I want to save, open, or cancel. I do not want the user to do anything to that exported file. The codes that I have now keeps prompting me on the above 3 options, which I now know is wrong to yse Response.write because I have been told that it is of the wrong direction. I've read on topic here that says using file stream will help. My ASP.NET still isn't good enought to understand what was needed and how could I come along it?
Below are the old codes for Respnose.Write:

Dim stringWrite As IO.StringWriter
        Dim htmlWrite As HtmlTextWriter
        Dim frm As HtmlForm = New HtmlForm()

        Response.Clear()

        Response.AddHeader("content-disposition", "attachment;filename=tryexcel.xls")

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

        stringWrite = New IO.StringWriter

        htmlWrite = New HtmlTextWriter(stringWrite)

        Controls.Add(frm)
        frm.Controls.Add(GridView1)
        frm.RenderControl(htmlWrite)

        Response.Write(stringWrite.ToString())

        Response.End()

Please help, thank you!
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export GridView data to Excel file rao965 ASP.NET 2.0 Professional 0 June 14th, 2007 10:18 AM
reading a stream from all the lines of a file vaidyapragati ASP.NET 2.0 Basics 3 May 10th, 2007 02:33 AM
xml binary file to ADO stream clk1022 XML 1 March 17th, 2006 03:33 PM
problem retreivig image from file stream sanjeet General .NET 0 September 23rd, 2005 04:31 PM
Adodb.stream File could not be opened. irabba Javascript 6 July 6th, 2004 06:25 AM



All times are GMT -4. The time now is 04:53 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.