Returns a reference to an item in an array
[C++]
COper& Cell(
USHORT usRow,
USHORT usCol,
BOOL bArrayOnly = FALSE
);
const COper& Cell(
USHORT usRow,
USHORT usCol,
BOOL bArrayOnly = FALSE
) const;
The row containing the item of interest (the top row is 0).
The column containing the item of interest (the leftmost column is 0).
If the bArrayOnly parameter is true, then the function asserts if the COper does not contain an array; if bArrayOnly is false, then the function returns the COper itself for a non-array COper, so long as both usRow and usCol = 0.
The reference returned by this function can be used to read the item and to update it. While this is an efficient function (particularly in the release build), for better
performance you may wish to hold a pointer or a reference to a cell inside an iteration
whenever the cell is repeatedly used, e.g. using a const reference:
or, using a pointer:
double dSum = 0.0;
USHORT usCols = op.GetWidth();
for ( USHORT i = 0; i < usCols; i++ )
{
const COper& opCell = op.Cell(0, i);
if ( opCell.IsBool() && !opCell.ToBool() )
dSum = 0.0;
else
dSum += (double)opCell;
}
double dSum = 0.0;
USHORT usCols = op.GetWidth();
COper* popCell;
for ( USHORT i = 0; i < usCols; i++ )
{
popCell = &op.Cell(0, i);
if ( popCell->IsBool() && !popCell->ToBool() )
dSum = 0.0;
else
dSum += (double)*popCell;
}
Header: xllplus.h