I’m hoping if someone can help me… I’m trying to open a .xls file, edit it, then close it, all on the server-side, but unsuccessfully.
For this, I’m trying to use the Excel.Application object, but my page just hangs, no errors, and when I try to open test.xls manually I get message that the file is in use by IUSR_Computer, do I want to open in read-only? This means, my code opens the file, but nothing happens (no changes are applied either). I have given full permission to the IUSR of my Excel Application and Excel 2007 Worksheet components trough DCOMCNFG.
Also, the reason why I’m going with this method is because I want to have a formatted xls file on the server, which is formatted for printing, with logo, header, footer, and using ASP I just want to copy this file, fill in a few values using cell references, then pass the new file to the user as a download link.
Here is my code so far:
Code:
<%@ Language=VBScript %>
<%
'// objects
Dim objApp
Dim objBook
Dim objSheet
'// Create excel application object
Set objApp = Server.CreateObject("Excel.Application")
'// Open the workbook (.xls) file
Set objBook = objApp.Workbooks.Open("c:\inetpub\wwwroot\abx\test.xls")
'// Select the sheet
Set objSheet = objBook.Sheets.Item("Sheet1")
'// Set a celltext
objSheet.Range("B1").Value = "This text is set from ASP"
'// Close the workbook and save changes
objBook.Close True
'// Exit excel (important! especially when running on server!!!)
objApp.Quit
'// Garbage collection (just to make sure)
Set objSheet = Nothing
Set objBook = Nothing
Set objApp = Nothing
Response.Write("OK")
%>
OLE DB Provider for Excel http://www.carlprothman.net/Default....oviderForExcel
<<
Currently Excel does not have an OLE DB Provider.
However, you can use the ODBC Driver for Excel.
Or use the OLE DB Provider for JET to read and write data in an Excel workbook.
>>
You can also open an Excel Spreadsheet using the JET OLE DB Provider http://www.carlprothman.net/Default....rosoftJetExcel
<<
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\mySpreadsheet.xls;" & _
"Extended Properties=""Excel 8.0;HDR=Yes"""
Where "HDR=Yes" means that there is a header row in the cell range (or named range), so the provider will not include the first row of theselection into the recordset. If "HDR=No", then the provider will include the first row of the cell range (or named ranged) into the recordset.
Your answer lies in MOSS... Microsoft Office Sharepoint Server will allow you to open office files from your site as read only or will allow you to check them out to edit them and then publish your changes to the server.
Bookmarks