Hi,
I am trying to download sql database through asp on my webpage and I keep getting weird outcomes in Excel. I have had to put in <char10> and <char13> into my sql data to have it display properly on the webpage and I know this is messing with the csv file download.
What it is doing in excel is breaking the "breaks" into multiple rows per recordset.
Here is my download code, is there anyway to fix this without removing them from my database?
[code=asp]response.expire s = 0
dim i,x,y,rst,F,Hea d,SQLstring,tem pstring, dbfield, hdr
public function replacebrComma( dbfield)
if len(dbfield)>0 then
replacebrComma= replace(replace (replace(replac e(dbfield,"<br> ",""),Chr(10)," "),Chr(13),""), ",","")
else
replacebrComma= ""
end if
end function
SQLstring = "Select * from FourBlocker"
set rst = my4Blocker.exec ute(SQLstring)
response.conten ttype = "applicatio n/vnd.ms-excel"
response.write( "<TABLE border='1'")
i=0
for each f in rst.fields
i=i+1
hdr = hdr & "<TD>" & f.name & "</TD>"
'g = g & ", " & f.name
next
response.write( "<TR><TD colspan='" & i & "'>Fourbloc ker Data Download</TD></TR>")
response.write( "<TR>" & hdr & "</TR>")
alldata = rst.getrows
for x=0 to ubound(alldata, 2)
response.write( "<TR>")
for y=0 to ubound(alldata, 1)
if alldata(y,x) <> "" then
response.write( "<TD>" & replace(alldata (y,x),"<BR>"," " & chr(10)) & "</TD>")
else
response.write( "<TD>" & alldata(y,x) & "</TD>")
end if
next
response.write( "</TR>")
next
response.write( "</TABLE>")[/code]
I am trying to download sql database through asp on my webpage and I keep getting weird outcomes in Excel. I have had to put in <char10> and <char13> into my sql data to have it display properly on the webpage and I know this is messing with the csv file download.
What it is doing in excel is breaking the "breaks" into multiple rows per recordset.
Here is my download code, is there anyway to fix this without removing them from my database?
[code=asp]response.expire s = 0
dim i,x,y,rst,F,Hea d,SQLstring,tem pstring, dbfield, hdr
public function replacebrComma( dbfield)
if len(dbfield)>0 then
replacebrComma= replace(replace (replace(replac e(dbfield,"<br> ",""),Chr(10)," "),Chr(13),""), ",","")
else
replacebrComma= ""
end if
end function
SQLstring = "Select * from FourBlocker"
set rst = my4Blocker.exec ute(SQLstring)
response.conten ttype = "applicatio n/vnd.ms-excel"
response.write( "<TABLE border='1'")
i=0
for each f in rst.fields
i=i+1
hdr = hdr & "<TD>" & f.name & "</TD>"
'g = g & ", " & f.name
next
response.write( "<TR><TD colspan='" & i & "'>Fourbloc ker Data Download</TD></TR>")
response.write( "<TR>" & hdr & "</TR>")
alldata = rst.getrows
for x=0 to ubound(alldata, 2)
response.write( "<TR>")
for y=0 to ubound(alldata, 1)
if alldata(y,x) <> "" then
response.write( "<TD>" & replace(alldata (y,x),"<BR>"," " & chr(10)) & "</TD>")
else
response.write( "<TD>" & alldata(y,x) & "</TD>")
end if
next
response.write( "</TR>")
next
response.write( "</TABLE>")[/code]
Comment