Using Aspose.Excel from COM applications

Please check https://forum.aspose.com/t/130424 and https://forum.aspose.com/t/130424. It also works for Aspose.Excel.

Classical ASP example<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

This example demonstrates how to use Aspose.Excel from a classical ASP page to dynamically generate a document.

<%@ LANGUAGE = VBScript %>

<% Option Explicit %>

Aspose.Excel classical ASP sample

Aspose.Excel classical ASP sample

Please enter your name below (both first and last):

First name:

Last name:

<%

If Request.form("fname") <> "" AND Request.form("lname") <> "" Then

'Create an Excel object

Dim xls

Set xls = CreateObject("Aspose.Excel.Excel")

'Open a designer file(template)

xls.Open_2 "c:\book1.xls"

'Put data into this file
Dim sheet
Set sheet = xls.worksheets.item(0)
Dim cells
Set cells = sheet.cells
Dim cell
Set cell = cells.item_3("A1")
cell.PutValue_4 "Hello, " & Request.form("fname") & " " & Request.Form("lname") & "!"

'Save the document to the stream.

Dim stream
set stream = xls.SaveToStream(2)

Response.Clear


'Specify the document type.

Response.ContentType = "application/vnd.ms-excel"

'Other options:

'Response.ContentType = "text/plain"

'Response.ContentType = "text/html"

'Specify how the document is sent to the browser.

Response.AddHeader "content-disposition","attachment; filename=MyBook.xls"

'Another option could be:

'Response.AddHeader "content-disposition","inline; filename=MyBook.xls";

'Get data bytes from the stream and send it to the response.

Dim bytes

bytes = stream.ToArray()

Response.BinaryWrite(bytes)

Response.End

End If

%>