Helps to search and iterate over CXlOper instances that contain arrays.
class CXlArrayContainer<T> |
The CXlArrayContainer<T> class is a utility class to help you inspect CXlOper instances that contain large arrays. Three types of read-only forward-only iterators are provided to work with the container class. They can be accessed most easily through typedef's, as shown in the example code in Usage below.
| typedef | Class | Description |
| cell_iterator | CXlArrayCellIterator<T> | Forward-only iterator which traverses across all cells in the array. |
| row_iterator | CXlArrayRowIterator<T> | Forward-only iterator which traverses across each row in the array. |
| col_iterator | CXlArrayColumnIterator<T> | Forward-only iterator which traverses across all columns in the array. |
These iterators can be used to iterate through a CXlOper containing an array with minimum performance overhead. Compared with standard CXlOper programming, using these classes is harder work.
Use the class with the following pattern:
double total = 0.0;
if (input->HasOper12())
{
CXlArrayContainer<XLOPER12> cont(*input);
for (CXlArrayContainer<XLOPER12>::cell_iterator i = cont.begin(); i != cont.end(); i++)
{
// Look at the value in each cell
if (i->xltype == xltypeNum)
total += i->val.num;
}
for (CXlArrayContainer<XLOPER12>::row_iterator r = cont.begin_rows(); r != cont.end_rows(); r++)
{
// Look at a cell in the first column of the current row
if (r->xltype == xltypeNum)
total += r->val.num;
// Look at a cell in the third column of the current row
if (r[2].xltype == xltypeNum)
total += r[2].val.num;
}
for (CXlArrayContainer<XLOPER12>::col_iterator c = cont.begin_cols(); c != cont.end_cols(); c++)
{
// Look at a cell in the first row of the current column
if (c->xltype == xltypeNum)
total += c->val.num;
// Look at a cell in the the second row of the current column
if (c[1].xltype == xltypeNum)
total += c[1].val.num;
}
}
else if (input->HasOper4())
{
// Provide this section only if you wish to provide support for Excel 2003 and below
CXlArrayContainer<XLOPER4> cont(*input);
// ...
}
Header: xlpfastit.h
CXlArrayContainer<T> Methods | xlpfastit.h | CXlArrayCellIterator<T> class | CXlArrayRowIterator<T> class | CXlArrayColumnIterator<T> class