Solved

sending data from .ASP to excel is not working.

Posted on 2010-11-30
4
403 Views
Last Modified: 2012-05-10
I have an ASP page that displays data from an access table. On the page i have a form button that calls another page that basically takes the data being diplayed and sends it to excel. This has been working for almost a year now suddenly, its not working. No cade has changed. The code to send the data to excel is attached below. Can anyone offer suggestions as to why this does not work anymore.
<%@ Language=VBScript %>
<%

Dim arrMonths(11)
arrMonths(0) = "Jan"
arrMonths(1) = "Feb"
arrMonths(2) = "March"
arrMonths(3) = "April"
arrMonths(4) = "May"
arrMonths(5) = "June"
arrMonths(6) = "July"
arrMonths(7) = "Aug"
arrMonths(8) = "Sep"
arrMonths(9) = "Oct"
arrMonths(10) = "Nov"
arrMonths(11) = "Dec"

dim Rs
Dim strSQL
session("strSQL") = request("strSQL")

vMdbFile = Server.MapPath("\virtual\data\EnergySysVC\TiH.mdb")
	vConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security info=False;Data Source=" & vMdbFile	

		'Open Database Connection
		Set Conn = Server.CreateObject("ADODB.Connection")
		Conn.Open vConnStr

set Rs=server.createobject("ADODB.recordset")
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=Enquiry_List.xls" 
strSQL = "SELECT * FROM tblTIHMetrics "
If Request.QueryString("Month") <> "" OR Request.QueryString("Year") <> "" OR Request.QueryString("Site") <> "" Then
     strSQL = strSQL & "WHERE"
End If
If Request.QueryString("Month") <> "" Then
      strSQL = strSQL & " month = '" & Request.QueryString("Month") & "'"
      If Request.QueryString("Year") <> "" OR Request.QueryString("Site") <> "" Then
            strSQL = strSQL & " and"
      End If
End If
If Request.QueryString("Year") <> "" Then
      strSQL = strSQL & " year = '" & Request.QueryString("Year") & "'"
      If Request.QueryString("Site") <> "" Then
            strSQL = strSQL & " and"
      End If
End If
If Request.QueryString("Site") <> "" Then
      strSQL = strSQL & " site = '" & Request.QueryString("Site") & "'"
End If
strSQL = strSQL & " ORDER BY 'site'"
'response.write strSQL
Rs.open strSQL,Conn,1,3
%>
<%

if Rs.eof <> true then
response.write "<table border=1>" & _
"<tr><td><strong>Name</strong></td><td>" & _
"<strong>Month</strong></td><td><strong>Year</strong>" & _
"</td><td><strong>Site</strong></td><td><strong>Planned Hours Per Job</strong></td>" & _
"<td><strong>Actual Hours Per Job</strong></td><td><strong>Percent of One Mans Job</strong>" & _
"</td><td><strong>Percent of Jobs started in Afternoon</strong></td>" &_
"<td><strong>TIH Hours Per Job</strong></td><td><strong>Total Jobs</strong></td></tr>"

while not Rs.eof

response.write "<tr><td>" & Rs.fields("Name") & "</td><td>" & Rs.fields("Month") & _
"</td><td>" & Rs.fields("Year") & "</td><td>" & Rs.fields("Site") & _
"</td><td>" & Rs.fields("PlannedHoursperJob") & "</td><td>" & _
Rs.fields("ActualHoursperJob") & "</td><td>" & Rs.fields("PercentOneManJobs") & _
"</td><td>" & Rs.fields("PercentJobsStartedintheAfternoon") & _
"</td><td>" & Rs.fields("TIHHoursperJob") & "</td><td>" & Rs.fields("TotalJobs") & _
"</td></tr>"

Rs.movenext
wend
response.write "</table>"
end if


set rs=nothing
Conn.close
%>

Open in new window

0
Comment
Question by:jlcannon
[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
  • 2
4 Comments
 
LVL 18

Expert Comment

by:ChetOS82
ID: 34242391
What exactly isn't working about it?
0
 

Author Comment

by:jlcannon
ID: 34242613
in the past, up until recently when anyone clicked the "Export to excel" button on the page it sent the exact data on the page to an excel sheet called Enquiry_List.xls but now you click export to excel, it does nothing at all.

the button is on an ASP page and the button code looks like this.
<form method="post" action="export_to_excel.asp?Year=<%=Yr%>&Month=<%=Mth%>&Site=<%=Ste%>"><input type="Submit" value="Export to Excel"></form>
and the code from the "export_to_excel.asp code is what i posted attached to the question.
0
 
LVL 18

Accepted Solution

by:
ChetOS82 earned 500 total points
ID: 34242634
I would start by commenting out the:

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=Enquiry_List.xls"

and then see if the server is throwing an error that you just couldn't see.
0
 

Author Closing Comment

by:jlcannon
ID: 34242710
by doing this I saw that the jet service was hanging. Thanks.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Executing a script on a timer online 5 32
Designing forms 3 41
Upgrade code from VS 2010 to VS 2015 7 32
Calculating percentage 2 28
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
This video teaches users how to migrate an existing Wordpress website to a new domain.

763 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