Microsoft Office Tutorials and References

In Depth Information

**Web Service API Methods**

❑

rangeCoordinates (in)
— Use this
RangeCoordinates
type to specify the range that is to

be calculated. The range can be a single cell or a contiguous range. The
rangeCoordinates

type has the following four properties:

❑

Column — The zero-based integer index, where column A is 0.

❑

Row
— The zero-based integer row index, where row 1 is 0.

❑

Height — An integer greater than 0, which represents the row height of the range.

❑

Width
— An integer greater than 0, which represents the column width of the range.

The behavior of
Calculate
is dependant on the values provided for the
rangeCoordinates
. Following

are common uses for the
Calculate
method:

❑

Calculate sheet
— The
sheetName
is the name of a sheet, and the
rangeCoordinates
are

initialized to 0.

❑

Calculate cell A1
— The sheetName is the name of a sheet, and the rangeCoordinates are

initialized as Column=0, Row=0, Height=1, and Width=1. This calculates cell A1.

❑

Calculate cell B1
— The
sheetName
is the name of a sheet, and the
rangeCoordinates
are

initialized as
Column=1
,
Row=0
,
Height=1
, and
Width=1
. This calculates cell B1.

❑

Calculate cells A1:A2
— The sheetName is the name of a sheet, and the rangeCoordinates

are initialized as Column=0, Row=0, Height=2, and Width=1. This calculates cells A1:A2.

❑

Calculate cell A1:B1
— The
sheetName
is the name of a sheet, and the
rangeCoordinates
are

initialized as
Column=0
,
Row=0
,
Height=1
, and
Width=2
. The result is that cells A1:B1 are calculated.

Return Value

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.

Calling Calculate

The following example makes a
Calculate
call. The range is defined using the
RangeCoordinates

object, and then the
Calculate
method is called to calculate range
A1:A2
on
Sheet3
.

try

{

string xlSessionId;

Status[] xlStatus;

xlSessionId = xlEcsApi.OpenWorkbook(

@”http://theexcelserver/testsite/Shared Documents/workbook.xlsb”,

@”en-US”,

@”de-DE”,

out xlStatus);

RangeCoordinates xlRange = new RangeCoordinates();

xlRange.Column = 0;

xlRange.Row = 0;