Solved

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

Posted on 2014-01-13
3
296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 53

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 53

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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.

734 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