Returns a reference to an item in an array
[C++]
CXlOper& Cell(
USHORT usRow,
USHORT usCol,
BOOL bArrayOnly = FALSE
);
const CXlOper& 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 CXlOper does not contain an array; if bArrayOnly is false, then the function returns the CXlOper itself for a non-array CXlOper, 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 = xlo.GetWidth();
for ( USHORT i = 0; i < usCols; i++ )
{
const CXlOper& xloCell = xlo.Cell(0, i);
if ( xloCell.IsBool() && !xloCell.ToBool() )
dSum = 0.0;
else
dSum += (double)xloCell;
}
double dSum = 0.0;
USHORT usCols = xlo.GetWidth();
CXlOper* pxloCell;
for ( USHORT i = 0; i < usCols; i++ )
{
pxloCell = &xlo.Cell(0, i);
if ( pxloCell->IsBool() && !pxloCell->ToBool() )
dSum = 0.0;
else
dSum += (double)*pxloCell;
}
Header: xllplus.h