Solved

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

Posted on 2014-01-13
3
295 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 122
Programatically extract date from website 8 83
youtube blocking politics 4 75
Mutiple Folder view (5 Folder view) 3 46
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 …

679 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