Microsoft Office Tutorials and References
In Depth Information
Web Service API Methods
Following are common uses for the GetRange method:
Set a single cell — The sheetName is the name of a sheet, and the rangeCoordinates are
initialized as Column=0 , Row=0 , Height=1 , and Width=1 . This sets the value of cell A1 with
rangeValues .
Set a range — The sheetName is the name of a sheet, and the rangeCoordinates are initialized
as Column=0, Row=0, Height=1, and Width=2. This sets the values in the range A1:B1 with
rangeValues.
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 SetRange
The following example makes a SetRange call using a range that is 2 rows by 6 columns. The range to
be set is E7:J8.
try
{
string xlSessionId;
Status[] xlStatus;
xlSessionId = xlEcsApi.OpenWorkbook(
@”http://theexcelserver/testsite/Shared Documents/workbook.xlsb”,
@”en-US”,
@”de-DE”,
out xlStatus);
//define and create the data for the rangeValues
int height = 2, width = 6;
object[] rangeValues = new object[height];
object[] firstRow = new object[width];
object[] secondRow = new object[width];
for (int x = 0; x < width; x++)
{
firstRow[x] = x + x;
secondRow[x] = x + x + 1;
}
rangeValues[0] = firstRow;
rangeValues[1] = secondRow;
//define range for E7:J8
RangeCoordinates xlRange = new RangeCoordinates();
xlRange.Column = 4;
xlRange.Row = 6;
xlRange.Height = height;
xlRange.Width = width;
//set values for E7:J8 on Sheet1
Search JabSto ::




Custom Search