| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||||||
|
||||||||
|
Well here is a Sample of View_Enquiry.asp that shows the result from a database which is linked to export_to_excel.asp that handles the export of data to excel.
You can change it to meet your needs. View_Enquiry.asp asp Code:
export_to_excel.asp asp Code:
Last edited by Systemdownnn : April 1st, 2007 at 09:31 AM. |
|
#2
|
|||
|
|||
|
Great timing on this post! I just finished my first on-line database and I'm looking to add more functionality. I created the two files above as instructed. The first file worked except that the formatting is all honked up. (Not a problem, I'll make it pretty later). But the second file - export_to_excel.asp - is giving me an error message:
Response object error 'ASP 0156 : 80004005' Header Error /fa22qa/soar/export_to_excel.asp, line 18 The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content. Line 18 in my file is: Response.ContentType = "application/vnd.ms-excel" The header content in my file looks like this: <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "(URL address blocked: See forum rules)"> <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <html xmlns="(URL address blocked: See forum rules)"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> Can you see what might be causing this error? Thanks! pbp |
|
#3
|
|||
|
|||
|
Post your whole code on the export_to_excel.asp page and i'll see whats happening!
|
|
#4
|
||||
|
||||
|
try adding Response.Buffer=True to your code.
|
|
#5
|
|||
|
|||
|
Quote:
I hope you can see this... Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "(URL address blocked: See forum rules)">
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html xmlns="(URL address blocked: See forum rules)">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<%
dim Cn,Rs
set Cn=server.createobject("ADODB.connection")
set Rs=server.createobject("ADODB.recordset")
Cn.open "PROVIDER=sqloledb;SERVER=myserver;UID=myid;PWD=myp w;DATABASE=mydb"
Rs.open "select * from Tbl_SOAR_Surveillance",Cn,1,3
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=Enquiry_List.xls"
if Rs.eof <> true then
response.write "<table border=0>"
while not Rs.eof
response.write "<tr><td>" & Rs.fields("SurvID") & "</td><td>" & Rs.fields("InspName") & "</td><td>" & Rs.fields("SupvName") & "</td><td>" & Rs.fields("SurvDate") & "</td><td>" & Rs.fields("swbs") & "</td><td>" & Rs.fields("Q1") & "</td><td>" & Rs.fields("Q2") & "</td><td>" & Rs.fields("Q3") & "</td><td>" & Rs.fields("Q4") & "</td><td>" & Rs.fields("Q5") & "</td><td>" & Rs.fields("Q6") & "</td><td>" & Rs.fields("Q7") & "</td><td>" & Rs.fields("Q8") & "</td><td>" & Rs.fields("Q9") & "</td><td>" & Rs.fields("Q10") & "</td><td>" & Rs.fields("Q11") & "</td><td>" & Rs.fields("Q12") & "</td><td>" & Rs.fields("Q13") & "</td><td>" & Rs.fields("Q14") & "</td><td>" & Rs.fields("Q15") & "</td><td>" & Rs.fields("empnum") & "</td><td>" & Rs.fields("comments") & "</td></tr>"
Rs.movenext
wend
response.write "</table>"
end if
set rs=nothing
Cn.close
%>
</body>
</html>
Thanks for your help ![]() |
|
#6
|
|||||
|
|||||
|
dont add the html headers...
just have this code asp Code:
hope it helped |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Exporting From Access Db to Excell in asp |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|