I wrote a procedure that will open xls from a local disk, update the data in it, and then save it again. It works great.
The problem occurs when I replace the file name to point to a SharePoint site. It opens the file in order. Updates the file, but when it tries to save the file, it throws an exception with the message "Unable to save as this name. The document was opened read-only." If I try to save the file with a different file name, then it works fine.
Does anyone know what I am missing? I think this should be due to the way I open the file. Is there any other way that I can force to open a file in read / write mode?
private static void RefreshExcelDocument(string filename) { var xls = new Microsoft.Office.Interop.Excel.Application(); xls.Visible = true; xls.DisplayAlerts = false; var workbook = xls.Workbooks.Open(Filename: filename, IgnoreReadOnlyRecommended: true, ReadOnly: false); try {
Thanks a lot in advance for the suggestions.
Jonathan
c # excel sharepoint wss
Jonathan stanton
source share