Solved

Exporting Query Results to Excel

Posted on 2013-02-04
11
284 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
  • 6
  • 5
11 Comments
 
LVL 32

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 32

Expert Comment

by:Big Monty
ID: 38851837
Yes it does
0
 

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 32

Expert Comment

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

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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 32

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 32

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 32

Expert Comment

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

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now