FileOpenAccessDenied Exception
Hopefully, someone can help me. I have a web part calling out to the Excel Services web service (code appears below). I am simply trying to return the value from a cell, but I can't even get the file open.
I am getting the FileOpenAccessDenied exception, even though the user is a site owner for everything, from the site collection on down. I have even tried overriding permissions in the doc library to ensure that the user is the owner.
I have set up the entire site collection as a trusted location for Excel Services.
I have published a major version of the spreadsheet in the document library.
Can someone please help me? I have been fighting this for two days.
Here is my web part code:
using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using ExcelAggregate.ExcelSvcs; //Web Reference to Excel Web Services
using System.Web.Services.Protocols;
namespace ExcelAggregate
{
[Guid("27626ed1-ec63-4b9b-b327-365f321ec002")]
public class ExcelAggregate : System.Web.UI.WebControls.WebParts.WebPart
{
protected override void Render(HtmlTextWriter writer)
{
// TODO: add custom rendering code here.
// writer.Write("Output HTML");
try
{
ExcelService es = new ExcelService();
es.SoapVersion = SoapProtocolVersion.Soap12;
string wkshtName = "Historical";
string tgtBook = "http://intranet.demo.com/Reports/Excel%20Sheets/2007%20CHI%20-%20MS%20Business%20Plan%202007.xlsx";
//System.Net.NetworkCredential newCred = new System.Net.NetworkCredential("Administrator", "P@ssw0rd", "DEMO");
es.Credentials = System.Net.CredentialCache.DefaultCredentials;
Status[] outStatus;
string sessionID = es.OpenWorkbook(tgtBook, "en-US", "en-US", out outStatus);
writer.Write("Session ID: " + sessionID + "<BR>");
object cellVal = es.GetCell(sessionID, wkshtName, 31, 1, true, out outStatus);
writer.Write(cellVal.ToString());
es.CloseWorkbook(sessionID);
}
catch (SoapException ex)
{
writer.Write("SOAP Exception Message: {0}<BR><BR>", ex.Message);
writer.Write("SOAP Exception Error Code: {0}", ex.SubCode.Code.Name);
}
}
}
}

