Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Excel Services - Edit .xlsx with external data

$
0
0

I created a new .xlsx file in Excel 2013 with external data connection to MS SQL database. Uploaded it to SharePoint Server 2010 document library.

I edit this file in workflow action. It uses ExcelService class generated via web reference. Here is my code:

// string SheetName = "Sheet1" // string CellName = "C1" // string Variable = "10"

using (var xl = new ExcelWebService.ExcelService()) { xl.Url = "http://localhost/_vti_bin/excelservice.asmx"; ExcelWebService.Status[] status; string sessionId = xl.OpenWorkbookForEditing(url, CurrentCulture, CurrentCulture, out status); try { xl.SetCellA1(sessionId, SheetName, CellName, Variable); xl.SaveWorkbook(sessionId); } catch (System.Web.Services.Protocols.SoapException) { throw; } finally { xl.CloseWorkbook(sessionId); } }

I get this exception every time when I run my code to edit any cell in the document:

System.Web.Services.Protocols.SoapException: This workbook cannot be edited because it contains the following features:

• External data ranges (also called query tables)

To edit this workbook, open the workbook for viewing, select Save a Copy from the File tab, and edit the new copy. 
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) 
   at System.Web.Services.Protocols.SoapHttpClientProtocol ExcelSetCellValue.Invoke(String methodName, Object[] parameters) 
   at ...ExcelService.OpenWorkbookForEditing(String workbookPath, String uiCultureName, String dataCultureName, Status[]& status) 

Method GetCellA1 works fine.

Can I edit Excel document with external data in SQL database using Excel Web Services?



The cake is a lie.


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>