Hi, I need some assistance with exporting to excel from asp. I have seen your responses on the formating of columns when exporting, but I need an example.
The code I'm using:
Now, the problem is the telephone area code starts with a 0, and I need it in text. Like I said, I have read and tested your comments, but apparently I'm to much of a novice to master it without assistance.
Please assist, Thanx. H
The code I'm using:
Code:
Function GenHtmlTable()
set conn=Server.CreateObject("ADODB.Connection")
conn.provider="Microsoft.Jet.OLEDB.4.0;"
conn.open server.mappath(MyDB.mdb")
set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Users", conn
On Error resume next
Dim sRet, VarFirstName, VarSurname, VarHomeTelephoneNumberCode, VarHomeTelephoneNumber
sRet = ""
sRet = <table border=1 class=mysmalltext><tr>"
sRet = sRet & "<td>Name</td>" & _
"<td>Surname</td>"& _
"<td>HomeTelephoneNumberCode</td>" & _
"<td>HomeTelephoneNumber</td>" & _
sRet = sRet & "</tr>"
while (not rs.EOF)
VarFirstName = rs("FirstName")
VarSurname = rs("Surname")
VarHomeTelephoneNumberCode = rs("HomeTelephoneNumberCode")
VarHomeTelephoneNumber = rs("HomeTelephoneNumber")
sRet = sRet & "<tr>"
sRet = sRet & "<td>"& VarFirstName & "</td><td>"
& VarSurname & "</td>" & VarHomeTelephoneNumberCode
& "</td><td>" & VarHomeTelephoneNumber & "</td>"
sRet = sRet & "</tr>"
rs.MoveNext()
wend
sRet = sRet & "</table>"
rs.close()
conn.close()
GenHtmlTable = sRet
End Function
Response.Clear()
Response.Buffer = True
Response.AddHeader "Content-Disposition", "attachment;filename=export.xls"
Response.ContentType = "application/vnd.ms-excel"
Response.Write GenHtmlTable()
Response.End()
Please assist, Thanx. H
Comment