
Accessing an Excel spreadsheet using ASP
THE FOLLOWING OPENS UP THE EXCEL FILE, EDITS SOME CELLS ON THE WORKSHEET,
GETS INFORMATION FROM CELLS, AND RUNS A MACRO THAT EXPORTS A CHART AS A GIF
IMAGE. WHAT I'M DOING IS UPDATING A WORKSHEET FROM USER FORM INPUT, THEN
UPDATING THE WEB PAGE WITH THE NEW DATA AND CHART IMAGE!
Set xlApp = CreateObject("excel.application")
xlApp.Visible = True
xlApp.Application.DisplayAlerts = False
xlApp.Workbooks.Open"C:\yourfile.xls"
xlApp.Worksheets("Sheet1").Cells(500, 10) = RandNum
xlApp.Worksheets("Sheet1").Cells(8, 6) = Session("UniqueNum")
xlApp.Worksheets("Sheet1").Cells(9, 6) = Session("PagesNum")
Cell7 = xlApp.Worksheets("Sheet1").Cells(17, 2).value
Cell8 = xlApp.Worksheets("Sheet1").Cells(17, 4).value
Cell19 = FormatCurrency(Cell19,0,-1,-1,-1)
Cell20 = xlApp.Worksheets("Sheet1").Cells(30, 4).value
Cell20 = FormatCurrency(Cell20,0,-1,-1,-1)
Cell21 = xlApp.Worksheets("Sheet1").Cells(30, 6).value
Cell21 = FormatCurrency(Cell21,0,-1,-1,-1)
Cell46 = xlApp.Worksheets("Sheet1").Cells(42, 8).value
Cell46 = FormatCurrency(Cell46,0,-1,-1,-1)
Cell47 = xlApp.Worksheets("Sheet1").Cells(42, 10).value
Cell47 = FormatCurrency(Cell47,0,-1,-1,-1)
Cell48 = xlApp.Worksheets("Sheet1").Cells(42, 12).value
Cell48 = FormatCurrency(Cell48,0,-1,-1,-1)
xlApp.Application.Run("Create_GIF")
xlApp.Quit
Set xlApp = Nothing
-Curtis
Quote:
> Hi,
> I'm trying to write some script to access an Excel spreadsheet through an
> ASP page. Just wanted to know:
> 1) Can I do it?
> 2) If so, then could someone give me some direction on how to proceed?
> I am creating the pages locally on PWS for Win98 to set up the pages and
> test the script and this how far I am now:
> <%
> Option Explicit
> Response.Expires = 0
> Dim objConn, ObjRS, strQuery, strConnection
> Set objConn = Server.CreateObject("ADODB.Connection")
> strConnection = "DSN=workbook1;"
> strConnection = strConnection & "UID=;PWD;"
> objConn.Open strConnection
> Now I am stuck. I know I should be using a database, but I have my
reasons
> =). Any help on how to proceed would be appreciated.
> -Rob