Microsoft Office Tutorials and References
In Depth Information
Web Service API Methods
A status object is returned by default with a value of null . See the “Status Class” section, earlier in this
chapter, for an explanation of this return type.
The following example makes four CalculateA1 calls. Comments are provided prior to each
CalculateA1 call to describe what is going to be calculated.
xlSessionId = xlEcsApi.OpenWorkbook(
//calculate the entire workbook
xlStatus = xlEcsApi.CalculateA1(xlSessionId, “”, “”);
//calculate only Sheet3
xlStatus = xlEcsApi.CalculateA1(xlSessionId, “Sheet3”, string.Empty);
//calculate the RangeOne named range on Sheet3
xlStatus = xlEcsApi.CalculateA1(xlSessionId, “Sheet3”, “RangeOne”);
//calculate range A1:B3 on Sheet1
xlStatus = xlEcsApi.CalculateA1(xlSessionId, “Sheet1”, “A1:B3”);
The Calculate method of the Excel Services web service calculates a single sheet or a range using range
coordinates. The declaration for the Calculate method looks like this:
public Status Calculate(string sessionId, string sheetName, RangeCoordinates
Following are the parameters for this method:
sessionId (in) — The sessionId string that was returned from a prior OpenWorkbook call.
The session must still be active at the time of the Calculate call. Making a Calculate call
using a sessionId that has timed out results in a SOAP exception.
sheetName (in) — Use this string to specify the name of the sheet containing the range
coordinates that are to be calculated.