[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Problem Exporting Gridview To Excel: No prompt to download Please Help!!! (VB)

Posted on 2006-07-12
3
Medium Priority
?
272 Views
Last Modified: 2008-02-26
I'm trying to export a gridview to excel. However, Internet Explorer constantly opens the file rather than giving me the choice to download it resulting in my computer slowing down signifigantly as it tries to load all the data.  I've tried resetting both the security and advanced settings within IE and nothing seems to work, which leads me to think it might be my code.

Here is my export code:

In Export.aspx:

Protected Sub On_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim TempAccessDataSource As New AccessDataSource

        TempAccessDataSource.DataFile = strDatabasePath

        TempAccessDataSource.SelectCommand = Session("SelectCommand")
        Session("SelectCommand") = Nothing
        Session.Remove("SelectCommand")


        'create table to export to excel
        Dim NewGridView As New GridView()
        NewGridView.DataSource = TempAccessDataSource
        NewGridView.DataBind()
        Dim oStringWriter As New System.IO.StringWriter()
        Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)

        'export to excel
        Response.Clear()
        Response.Charset = ""
        Response.ContentEncoding = System.Text.Encoding.ASCII
        Response.Buffer = True
        Response.ContentType = "application/vnd.ms-excel"
        Response.AddHeader("Content-Disposition", "inline;filename=ExcelDownload.xls")
        NewGridView.RenderControl(oHtmlTextWriter)
        Response.Write(oStringWriter.ToString())
        Response.End()

        'clean up
        NewGridView.Dispose()
        TempAccessDataSource.Dispose()

    End Sub

The


I appreciate any help on this matter as this problem is draining away my productivity.


I'm sorry if I put this question in the wrong topic area, I was unsure weather or not the problem lay in my code or with IE so I errored on the side of caution and placed it here.
0
Comment
Question by:rderveloy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 18

Accepted Solution

by:
Elvio Lujan earned 900 total points
ID: 17091598
run gpedit.msc...

and go to:

User configutration - Administrative templates - Windows components - Internet Explorer - Internet control panel - Security page - Internet zone

and set "automaticly ask before to download a file" to enabled

may be the names are not the same... because i have the spanish windows... but try to find them! :)
0
 
LVL 14

Assisted Solution

by:Ramuncikas
Ramuncikas earned 600 total points
ID: 17091730
Change to
   Response.ContentType = "application/download"
   -or-
   Response.ContentType = "application/unknown"
0
 

Author Comment

by:rderveloy
ID: 17133911
Thanks for the help!

I tried the modified code and it didn't seem to do anything.

The final solution was to use the gpedit.msc trick as well as the following:

Within windows explorer, go to Tools -> Folder Options.  Click the file types tab.  Select "XLS Microsoft Excel Worksheet" and click advanced.  Place a check in the box labled "Confirm open after download," click ok, then click close.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question