Solved

Is There A Way To Have An ASP Web Page With A Table Exported To Excel?

Posted on 2014-01-13
3
291 Views
Last Modified: 2014-01-27
I have an ASP Web Page that displays a dynamic table with data. I am using Internet Explorer 11. If I right click and try "Export To Excel" I get an error.
"Unable to open http://.........asp. Cannot download the information.

Is there a way to get this to work?

I can right click and select and copy the table on the ASP web page and paste it into excel manually. I would prefer not to do this.

Thank you for any help.
Rick
0
Comment
Question by:ES-Components
  • 2
3 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
At the very top just below where you declare <%@LANGUAGE="VBSCRIPT"%> add

<%
Response.ContentType = "application/vnd.ms-excel"
Response.AppendHeader "content-disposition", " filename=TheFileName.xls"
%>

Open in new window

0
 

Author Comment

by:ES-Components
Comment Utility
This is the first few lines of code to this web page. You can see where I put your suggestion.
I get an HTTP500 error. The website can not display the page. Possible programming error.

Any ideas?

Thank you...
Rick


<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/CustomerHistory2.asp" -->
<!--#include file="Connections/OpenOrdersCustomer.asp" -->
<%
Response.ContentType = "application/vnd.ms-excel"
Response.AppendHeader "content-disposition", " filename=TheFileName.xls"
%>
<%
Dim Recordset1__ShipTo
Recordset1__ShipTo = "1"
If (Request.Form("ShipTo")   <> "") Then
  Recordset1__ShipTo = Request.Form("ShipTo")  
End If
%>
<%
Dim Recordset1__varStartRange
Recordset1__varStartRange = "1/1/07"
If (Request.Form("Date1")   <> "") Then
  Recordset1__varStartRange = Request.Form("Date1")  
End If
%>
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
Comment Utility
The problem could be you have 2 include files first.  When the page loads, the include files are rendered as if the html/asp code was there.  So try

<%@LANGUAGE="VBSCRIPT"%>

<%
Response.ContentType = "application/vnd.ms-excel"
Response.AppendHeader "content-disposition", " filename=TheFileName.xls"
%> 
<!--#include file="Connections/CustomerHistory2.asp" -->
<!--#include file="Connections/OpenOrdersCustomer.asp" -->

Open in new window


Also 500 errors are generic, you need to turn on your errors in iis or view the site on the server to see the exact error.  For now, try the suggestion above.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Report events not being triggered 8 98
strDist challenge 35 84
word0 challenge 4 52
PHP question(s) about order of output 9 39
A short article about a problem I had getting the GPS LocationListener working.
A short article about problems I had with the new location API and permissions in Marshmallow
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

772 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

10 Experts available now in Live!

Get 1:1 Help Now