Solved

Exporting Query Results to Excel

Posted on 2013-02-04
11
290 Views
Last Modified: 2013-02-07
We recently moved a Classic ASP app to a new server that is running IE8, IIS6 but the code below that exports the html to excel has stopped working.  

Does anyone know of a workaround?

Response.ContentType = "application/vnd.xls"
0
Comment
Question by:jmpatton
[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
  • 6
  • 5
11 Comments
 
LVL 33

Expert Comment

by:Big Monty
ID: 38851799
try

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

Author Comment

by:jmpatton
ID: 38851815
No i tried that first and it didnt work.  Here is a stupid question, but does the MS Office suite have to be installed on the server for this to work?
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 38851837
Yes it does
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:jmpatton
ID: 38860221
Thanks, I added excel to the server and no longer get the error, however, a "Open/Save" dialog box now opens up, but it will not open.
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 38860230
are you getting any kind of error when you try to open it?
0
 

Author Comment

by:jmpatton
ID: 38860248
No, I hit the open button and it does nothing.  If I hit the Save button, it tries to save the page in ".asp" format
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 38860266
what version of excel are you using? its hard to diagnose the issue without seeing more of the code
0
 

Author Comment

by:jmpatton
ID: 38860349
Excel 2010.

Here is my code below.  I have an asp page that does a query and returns the results into an html table to the user.  If the user would like an excel format, they click a link at the top of the page and they are sent to a new page running the same query and returning the same results in html format just with the excel code below at the top of the page.

<%

Response.Buffer = true
Response.ContentType = "application/vnd.ms-excel"  
      
      If Request.QueryString("SQLType") <> "" Then
            sSQLType = Request.QueryString("SQLType")
      End If
      
      If Session("sSQL") <> "" Then
      
            oRs.Open Session("sSQL"), oConn
      
      Else
            
            Response.Redirect("oracle_query.asp")
            
      End If  
%>
0
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 38861850
try adding this to after the ContentType line:

Response.addHeader "content-disposition","attachment;filename=yourname.xls"
0
 

Author Comment

by:jmpatton
ID: 38864075
Great that worked.  Thanks so much for working with me
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 38864084
my pleasure, glad I could help :)
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JQuery to parse xml string and get element by id 4 64
rebind a grid after user clicks on node in treeview 1 48
Load data upon clicking a button 8 48
Debugging Html 8 32
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

733 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