Changing an Excel File
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:
Any help would be greatly appreciated.
<%@ 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
OLE DB Provider for Excel
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
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.
For more information, see: Q278973 [ http://support.microsoft.com/default...b;en-us;278973 ]
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.
You can download and try out the functionality here
Hope this helps!
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)