We were programmatically trying to read an Excel file, uploaded to a SharePoint 2007 Document library, by making a Web Service call to Excel Services.
And the code was giving System.Web.Services.Protocols.SoapException error with message “You do not have permissions to open this file on Excel Services”.
We initially thought that it’s a permissions issue, the context under which code is running does not have access to the Excel file. To verify, we opened the file in browser using Excel Services View in Browser option, and the excel file was rendered correctly. Permissions issue was ruled out.
On closer look at code and debugging, the bug was found in the code. We were referring to the wrong Excel Services URL. The URL gets hardcoded when you add the Web Service Reference in Visual Studio. The error can occur when you move from one Development machine to another and URL changes, or refer the Excel Service of SSP.
To resolve the error, simply update the Url of the ExcelService object.
ExcelService exlObj = new ExcelService();
exlObj.Url = oweb.Site.Url + "/_vti_bin/excelservice.asmx";
exlObj.Credentials = System.Net.CredentialCache.DefaultCredentials;
string sessionId = exlObj.OpenWorkbook(filePathUrl,"en-US", "en-US", out status);