• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 297
  • Last Modified:

Exporting Query Results to Excel

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
jmpatton
Asked:
jmpatton
  • 6
  • 5
1 Solution
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
try

Response.ContentType = "application/vnd.ms-excel"
0
 
jmpattonAuthor Commented:
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
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
Yes it does
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jmpattonAuthor Commented:
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
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
are you getting any kind of error when you try to open it?
0
 
jmpattonAuthor Commented:
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
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
what version of excel are you using? its hard to diagnose the issue without seeing more of the code
0
 
jmpattonAuthor Commented:
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
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
try adding this to after the ContentType line:

Response.addHeader "content-disposition","attachment;filename=yourname.xls"
0
 
jmpattonAuthor Commented:
Great that worked.  Thanks so much for working with me
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
my pleasure, glad I could help :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now