Forum Moderators: open
I am looking for a tutorial on how to pass data from an HTML form to an Excel spreadsheet using ASP or VBScript. Does anybody have any ideas? Or know of any good books?
Is this hard to do? Would it be considered an advanced topic? Do you have to have special DLLs installed on the server?
THANKS!
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Application.Visible = True
Set ExcelBook = ExcelApp.Workbooks.Add
ExcelBook.Worksheets(1).Cells(Row, Col).Font.Size = 10
ExcelBook.Worksheets(1).Cells(Row, Col).Font.Bold = true
ExcelBook.Worksheets(1).Cells(Row, Col).Value="Your heading"
etc. for your title rows
dim query
query = "SELECT fields FROM tables WHERE criteria ORDER BY field"
'Response.Write(query)
Set RSEVENT = Server.CreateObject("ADODB.RecordSet")
RSEVENT.Open query, ConnSQL, 1, 3
dim i
i = 3 '(start at third line of the spreadsheet)
Do while NOT RSEVENT.EOF
ExcelBook.Worksheets(1).Cells(i, 1).Value=RSEVENT("field1")
ExcelBook.Worksheets(1).Cells(i, 2).Value=RSEVENT("field2")
ExcelBook.Worksheets(1).Cells(i, 3).Value=RSEVENT("field3")
etc... for as many fields as you want.
RSEVENT.movenext
i = i + 1
Loop
RSEVENT.close
set rsEvent = nothing
ExcelBook.SaveAs "path and name of file".xls"
ExcelApp.Application.Quit
Set ExcelApp = Nothing
Response.Redirect("your path and name of file".xls")
[webmasterworld.com...]
You may also want to look at the tutorials at Hotscripts, I always find them to be a good resource.
-Padraic