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:
<%@ Language=VBScript %>
'// 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
'// Exit excel (important! especially when running on server!!!)
'// Garbage collection (just to make sure)
Set objSheet = Nothing
Set objBook = Nothing
Set objApp = Nothing
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.