Forum Moderators: open

Message Too Old, No Replies

Passing data from HTML Form to Excel using ASP

Is this hard to do?

         

newnewbie1

1:21 am on Mar 12, 2003 (gmt 0)

10+ Year Member



Hi!

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!

txbakers

4:00 am on Mar 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't need anything special. Here is some code to do it:

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")

balinor

5:14 pm on Apr 9, 2003 (gmt 0)

10+ Year Member



That looks pretty simple, but I need PHP (Apache Server). Anyone got a quick fix for me?

Tvienti

6:22 pm on Apr 29, 2003 (gmt 0)

10+ Year Member



Hello - new to the forum. This topic is of great interest to me and I could use any help available. Does anybody know where I can find some more documentation on this? A tutorial, a cheat sheet, API docs..? I would appreciate it.

Thank you

balinor

6:47 pm on Apr 29, 2003 (gmt 0)

10+ Year Member



Here's another forum on how to do it in PHP if that interests you:

[webmasterworld.com...]

You may also want to look at the tutorials at Hotscripts, I always find them to be a good resource.

-Padraic