TSchuman
asked on
ASP to XLS Code Explanation
Ive been trying to find information on how to export ASP to XLS and there doesnt seem to be much out there. I was wondering if anyone knew the rules about how to do this. I would like to be able to create multiple worksheet in one file as well as adjusting the fonts, alignment, etc.
This is some of the code i have been playing around with:
Set ExcelApp = CreateObject("Excel.Applic ation")
ExcelApp.Application.Visib le = True
Set ExcelBook = ExcelApp.Workbooks.Add
ExcelBook.Worksheets(1).Ce lls(2, 2).Font.Name = "Verdana"
ExcelBook.Worksheets(1).Ce lls(2, 2).Font.Size = 10
ExcelBook.Worksheets(1).Ce lls(2, 2).Font.Italic = true
ExcelBook.Worksheets(1).Ce lls(2, 2).Value="Hello world"
ExcelBook.Worksheets(1).Ce lls(2, 2).HorizontalAlignment = 1
ExcelBook.Worksheets(1).Ce lls(2, 2).Font.Color = RGB(0,0,0)
ExcelBook.SaveAs "c:\yourfile.xls"
ExcelApp.Application.Quit
Set ExcelApp = Nothing
I thought changing the worksheet # would allow me to input data to a new worksheet but it doesnt appear to work that way. Any help would be appreciated.
This is some of the code i have been playing around with:
Set ExcelApp = CreateObject("Excel.Applic
ExcelApp.Application.Visib
Set ExcelBook = ExcelApp.Workbooks.Add
ExcelBook.Worksheets(1).Ce
ExcelBook.Worksheets(1).Ce
ExcelBook.Worksheets(1).Ce
ExcelBook.Worksheets(1).Ce
ExcelBook.Worksheets(1).Ce
ExcelBook.Worksheets(1).Ce
ExcelBook.SaveAs "c:\yourfile.xls"
ExcelApp.Application.Quit
Set ExcelApp = Nothing
I thought changing the worksheet # would allow me to input data to a new worksheet but it doesnt appear to work that way. Any help would be appreciated.
ASKER
Weareu,
I tried your solution above but when i attempt to run it, It just sits there and nothing happens. Any ideas?
I tried your solution above but when i attempt to run it, It just sits there and nothing happens. Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Weareu, that did it!
Im not sure what was wrong before but when i would run the ASP it would just sit there like it was caught in an endless loop. Having the page response.write the file after its done must have been what was missing.
Thanks again for your help.
Im not sure what was wrong before but when i would run the ASP it would just sit there like it was caught in an endless loop. Having the page response.write the file after its done must have been what was missing.
Thanks again for your help.
ExcelApp.Application.Visib
Set ExcelBook = ExcelApp.Workbooks.Add
Set ExcelSheet1 = ExcelBook.Worksheets(1)
ExcelSheet1.Cells(2, 2).Font.Name = "Verdana"
ExcelSheet1.Cells(2, 2).Font.Size = 10
ExcelSheet1.Cells(2, 2).Font.Italic = true
ExcelSheet1.Cells(2, 2).Value="Hello sheet 1"
ExcelSheet1.Cells(2, 2).HorizontalAlignment = 1
ExcelSheet1.Cells(2, 2).Font.Color = RGB(0,0,0)
Set ExcelSheet2 = ExcelBook.Worksheets.Add
ExcelSheet2.Cells(2, 2).Font.Name = "Verdana"
ExcelSheet2.Cells(2, 2).Font.Size = 10
ExcelSheet2.Cells(2, 2).Font.Italic = true
ExcelSheet2.Cells(2, 2).Value="Hello sheet 2"
ExcelSheet2.Cells(2, 2).HorizontalAlignment = 1
ExcelSheet2.Cells(2, 2).Font.Color = RGB(0,0,0)
ExcelBook.SaveAs "c:\yourfile.xls"
ExcelApp.Application.Quit
Set ExcelApp = Nothing