ASP to EXCEL

ASP to EXCEL

am 31.08.2005 17:13:27 von DNKMCA

Hi,

Im creating an Excel file using ASP
Versions : Office 97

The formattting is not working properly in Excel 97, but the same works fine
in Office XP & 2000
Is there any additional code has to be added in my code to get a formatted
output in Excel 97 version?

Please help.

Thanks.


MyCode
---------

set Cn=server.createobject("ADODB.connection")
Cn.open sqlconstring
tfName = "salesexcel.xls"

set Rs=server.createobject("ADODB.recordset")
sql = "select * from sales WHERE month(saledate)=8 and day(saledate)=28
year(saledate)=2005"
Rs.open sql,Cn,1,3

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=" & tfName

if not rs.eof then
Response.write "

"
Response.write " colspan='2'>Executive"
while not rs.eof
Response.write ""
Response.write ""
Response.write ""
Response.write ""
rs.movenext
wend
enf if

Response.write "
IDSales Done
" & rs(0) & " & rs(1) & " & rs(2) &
"
set Cn = Nothing
------------------------------------------------------------ -

Re: ASP to EXCEL

am 08.09.2005 04:17:31 von Bullschmidt

Don't know if it's a typo but I did notice that you may want to change
this:

sql = "select * from sales WHERE month(saledate)=8 and day(saledate)=28
year(saledate)=2005"

To be more like this instead:

sql = "select * from sales WHERE month(saledate)=8 and day(saledate)=28
and year(saledate)=2005"

And maybe you want to create .csv files which can be opened in Excel.

Puzzle 5 Not much different from other solutions by Manohar Kamath
posted 1/12/99
http://www.asp101.com/puzzles/puzzle5_s7.asp

Puzzle 5 "Write delimited data to browser window" by Kirk Lockhart
posted on 12/21/98
Write the data in plain text to the browser window, and the user can
save the results as a plain text file and then import the data into
Excel or whatever application they want.
http://www.asp101.com/puzzles/puzzle5_s1.asp

Creating the Excel File Server Side
http://www.greggriffiths.org/webdev/both/excel/serverside.ht ml
Uses FSO to create a .csv file.

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


*** Sent via Developersdex http://www.developersdex.com ***