Excel export Function
<%
Sub exporttoexcel
Response. contenttype = "application/vnd. MS-excel"
Response. addheader "content-disposition", "attachment?filename=results.xls"
Response. Write "<body>"
Response. Write "<Table border = 1>"
Call writetabledata
Response. Write "</table>"
Response. Write "</body>"
Response. Write "
End sub
%>
Import database in Excel
<%
Dim filename
Filename = "excel.xls" ': get the file name. It is specified by the project manager and the path is fixed in a virtual path.
Dim Conn, RS
Set conn = Createobject ("ADODB. Connection ")
Conn. Open "driver = {Microsoft Excel Driver (*. xls )};"&_
"Driverid = 790 ;"&_
"DBQ =" & server. mappath ("" & filename &"")&";"&_
"Defaultdir = G :/"
Set rs = Createobject ("ADODB. recordset ")
Rs. Open "select * from [sheet1 $]", Conn, 2, 2
If Rs. EOF then
Response. Write "no records in the Excel table"
Else
Set conndb = server. Createobject ("ADODB. Connection ")
Dbpath = server. mappath ("Excel. mdb ")
'Response. Write dbpath
Conndb. Open "driver = {Microsoft Access Driver (*. mdb)}; DBQ =" & dbpath
Set rsdb = server. Createobject ("ADODB. recordset ")
Sqldb = "select * from Excel"
Rsdb. Open sqldb, conndb, 1, 3
Do while not Rs. EOF 'reads data cyclically
Rsdb. addnew
Rsdb ("FILENAME") = RS (0)
Rsdb ("id1") = RS (1)
Rsdb ("ID2") = RS (2)
Rsdb ("ID3") = RS (3)
Rsdb ("ID4") = RS (4)
Rs. Update
Rsdb. movenext
Rs. movenext
Loop
'Response. Redirect filename
End if
Rsdb. movefirst
If rsdb. EOF then
Response. Write "no records in the Database"
Else
Do while not rsdb. EOF
Response. Write rsdb ("FILENAME ")&""
Response. Write rsdb ("id1 ")&""
Response. Write rsdb ("ID2 ")&""
Response. Write rsdb ("ID3 ")&""
Response. Write rsdb ("ID4 ")&""
Response. Write "<br>"
Rsdb. movenext
Loop
End if
Rs. Close
Set rs = nothing
Set conn = nothing
%>