Solved

Exporting Query Results to Excel

Posted on 2013-02-04
11
288 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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

770 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