Forums
This topic is locked
Exporting ASP results table to Excel
Posted 07 Jul 2005 03:06:29
1
has voted
07 Jul 2005 03:06:29 Simon Howell posted:
Does anyone know how to export the displayed results of an ASP search to excel or .csv? What I'd like to do is have a link on the search results page that says "Export to Excel" or whatever. Ideally a link would be generated that I could right click.STUDIO MX 2004
Replies
Replied 08 Jul 2005 21:59:13
08 Jul 2005 21:59:13 Simon Martin replied:
Does this help?
www.developerfusion.com/forums/topic-26813
Live the life you love
Love the life you live
~ ~ ~ ~ ~ ~ ~
<b>Simon Martin</b> - <i>DMXzone Manager</i>
<font size=1>[ Dreamweaver MX/MX2004 | ASP | SQL | XHTML/CSS | Web Accessibility ] </font id=size1>
www.developerfusion.com/forums/topic-26813
Live the life you love
Love the life you live
~ ~ ~ ~ ~ ~ ~
<b>Simon Martin</b> - <i>DMXzone Manager</i>
<font size=1>[ Dreamweaver MX/MX2004 | ASP | SQL | XHTML/CSS | Web Accessibility ] </font id=size1>
Replied 09 Jul 2005 01:04:11
09 Jul 2005 01:04:11 paul durbar replied:
Say you have generated a recordset called SearchRS then you can export it to comma seperated values like:
Dim strReturn
for each field in SearchRS.fields
if strReturn = "" then
strReturn = field.name
else
strReturn = strReturn & "," & field.name
end if
next
strReturn = strReturn & vbCrLf
strReturn = strReturn & """" & SearchRS.GetString(2,,""",""","""" & vbCrLf & """",""
strReturn = Left(strReturn,Len(strReturn)-1) ' since GetString will add an extra quote at the end
Response.AddHeader "Content-Disposition", "attachment; filename=Search_Export.txt"
Response.Charset = "UTF-8"
Response.ContentType = "text/plain"
Response.BinaryWrite strReturn
Response.Flush
Response.Clear
This can be imported into Excel easily. Hope that helps
D2 Sitelock v3.0
Sell and securely deliver downloads, paid subscription systems and website membership areas:
www.d2computing.co.uk/sitelock.htm
Dim strReturn
for each field in SearchRS.fields
if strReturn = "" then
strReturn = field.name
else
strReturn = strReturn & "," & field.name
end if
next
strReturn = strReturn & vbCrLf
strReturn = strReturn & """" & SearchRS.GetString(2,,""",""","""" & vbCrLf & """",""

strReturn = Left(strReturn,Len(strReturn)-1) ' since GetString will add an extra quote at the end
Response.AddHeader "Content-Disposition", "attachment; filename=Search_Export.txt"
Response.Charset = "UTF-8"
Response.ContentType = "text/plain"
Response.BinaryWrite strReturn
Response.Flush
Response.Clear
This can be imported into Excel easily. Hope that helps
D2 Sitelock v3.0
Sell and securely deliver downloads, paid subscription systems and website membership areas:
www.d2computing.co.uk/sitelock.htm