如果您確定指定的查詢確實有效,則根據至少下列.NET組件可用的首選項:
下面提供了基於的消費SharePoint Excel REST服務的示例3210。
public class ExcelClient : IDisposable
{
public ExcelClient(Uri webUri, ICredentials credentials)
{
WebUri = webUri;
_client = new WebClient {Credentials = credentials};
}
public string ReadRange(string libraryName, string fileName,string rangeName, string formatType)
{
var endpointUrl = WebUri + string.Format("/_vti_bin/ExcelRest.aspx/{0}/{1}/Model/Ranges('{2}')?$format={3}", libraryName,fileName, rangeName, formatType);
return _client.DownloadString(endpointUrl);
}
public void Dispose()
{
_client.Dispose();
GC.SuppressFinalize(this);
}
public Uri WebUri { get; private set; }
private readonly WebClient _client;
}
使用
var credentials = new NetworkCredential(userName,password,domain);
var client = new ExcelClient(webUri, credentials);
var data = client.ReadRange("docs", workbookName, rangeName, "html");
你能告訴我,這可能是我的webUri? 我在此位置獲得價值:** http://sharepoint1.net/excel/_vti_bin/ExcelRest.aspx/docs/「+ workbookName +」/ model/Ranges('「+ rangeName +」')?$ format = HTML ** – hello 2015-04-01 14:12:50
當然,這是網站url:http://sharepoint1.net/excel在你的情況下(我假設'excel'是'docs'庫駐留在哪個excel文件'abc的子站點的名稱.xslx'被存儲) – 2015-04-01 14:16:02
我得到錯誤:**遠程服務器返回錯誤:(400)錯誤的請求。**。我在'return _client.DownloadString(endpointUrl)';' – hello 2015-04-01 14:33:54