Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 1st, 2007, 01:10 AM
Authorized User
 
Join Date: Aug 2007
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!





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





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