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
Solved

Exporting Query Results to Excel

Posted on 2013-02-04
11
289 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 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

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/…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

839 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