ASP to Excel
Posted on 2002-03-04
I have an HTML table that I want the user to be able to save to Excel. I have tried diffence method but still not work.
My first method is:
<%@ language=vbscript %>
response.buffer = true
response.ContentType = "application/vnd.ms-excel"
response.AddHeader "content-disposition", "inline; filename=dynamic.xls"
response.write "<table width=200>"
for i = 1 to 4
response.write "<td width=40>"
response.write i + i
response.write "<td width=40><b>=sum(A1:D1)</b></td>"
But the result showed in browser is in html format not in excel:
2 4 6 8 =sum(A1:D1)
So, I try the other method and run in a computer:
Set ExcelSheet = CreateObject("Excel.Sheet")
' Make Excel visible through the Application object.
ExcelSheet.Application.Visible = true
' Place some text in the first cell of the sheet.
ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1"
' Save the sheet.
' Close Excel with the Quit method on the Application object.
' Release the object variable.
Set ExcelSheet = Nothing
No Excel file is generated in the application path and an error is occured
Call was rejected by callee
/excel.asp, line 4
What's wrong with my coding and my web server? What do I need to do in order to fix the problem?