Solved

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

Posted on 2014-01-13
3
292 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
ID: 39777047
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
ID: 39779136
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
ID: 39779182
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
array11 challenge 16 62
Magic Software info 18 126
Microsoft C++ code failing in executable that worked 9 86
I need an assist with a programming logic math question. 5 55
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

864 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

21 Experts available now in Live!

Get 1:1 Help Now