|
wxAutoExcel 2.5.1
|
A rectangular block of the values or formulas of range cells. More...
#include <wxAutoExcelRangeData.h>
Public Member Functions | |
| wxExcelRangeData (size_t rows=0, size_t columns=0) | |
| Creates data of the given size, with all cells empty. | |
| size_t | GetRowCount () const |
| Returns the number of rows. | |
| size_t | GetColumnCount () const |
| Returns the number of columns. | |
| bool | IsEmpty () const |
| Returns true if the data have no cells. | |
| void | Resize (size_t rows, size_t columns) |
| Changes the size. | |
| void | Clear () |
| Removes all the cells. | |
| wxVariant & | operator() (size_t row, size_t column) |
| Returns the cell in the given row and column, numbered from 0. | |
| bool | GetCell (size_t row, size_t column, double &value) const |
| Gets the value of the cell in the given row and column, numbered from 0, when the cell contains a value of the type of value. | |
| bool | IsCellEmpty (size_t row, size_t column) const |
Returns true if the cell in the given row and column, numbered from 0, is empty. | |
| bool | IsCellError (size_t row, size_t column, XlCVError *error=NULL) const |
Returns true if the cell in the given row and column, numbered from 0, contains an error value, such as #N/A or #DIV/0! | |
| wxVector< wxVariant > | GetRow (size_t row) const |
| Returns the cells of the given row, numbered from 0. | |
| wxVector< wxVariant > | GetColumn (size_t column) const |
| Returns the cells of the given column, numbered from 0. | |
| wxVariant | ToVariant () const |
| Converts the data to a wxVariant containing a two-dimensional SAFEARRAY of VARIANTs, which can be passed e.g. | |
Static Public Member Functions | |
| static bool | FromVariant (const wxVariant &value, wxExcelRangeData &data) |
| Sets data from the value of a range returned by Excel, which is a two-dimensional SAFEARRAY of VARIANTs for a range with more than one cell, or a single value for a single cell. | |
A rectangular block of the values or formulas of range cells.
The rows and columns are numbered from 0, so that the cell in the top left corner of the range is (0, 0). Each cell is a wxVariant, which is null for an empty cell, a double for a number, a string, a bool, a wxDateTime for a date (when not obtained with Value2), or a wxVariantDataErrorCode for an error value.
Use wxExcelRange::GetValues_() and wxExcelRange::SetValues_(), or wxExcelRange::GetFormulas_() and wxExcelRange::SetFormulas_() to transfer the data at once, which is much faster than cell by cell:
| wxAutoExcel::wxExcelRangeData::wxExcelRangeData | ( | size_t | rows = 0, |
| size_t | columns = 0 ) |
Creates data of the given size, with all cells empty.
|
inline |
Returns the number of rows.
|
inline |
Returns the number of columns.
|
inline |
Returns true if the data have no cells.
| void wxAutoExcel::wxExcelRangeData::Resize | ( | size_t | rows, |
| size_t | columns ) |
Changes the size.
The cells which remain keep their values, the new cells are empty.
| void wxAutoExcel::wxExcelRangeData::Clear | ( | ) |
Removes all the cells.
| wxVariant & wxAutoExcel::wxExcelRangeData::operator() | ( | size_t | row, |
| size_t | column ) |
Returns the cell in the given row and column, numbered from 0.
| bool wxAutoExcel::wxExcelRangeData::GetCell | ( | size_t | row, |
| size_t | column, | ||
| double & | value ) const |
Gets the value of the cell in the given row and column, numbered from 0, when the cell contains a value of the type of value.
Otherwise, returns false, leaving value unchanged.
The values are not converted between the types, except for numbers:
Excel provides dates as wxDateTime only when obtained with Value, see wxExcelRange::GetValues_(), with Value2 they are numbers.
| bool wxAutoExcel::wxExcelRangeData::IsCellEmpty | ( | size_t | row, |
| size_t | column ) const |
Returns true if the cell in the given row and column, numbered from 0, is empty.
| bool wxAutoExcel::wxExcelRangeData::IsCellError | ( | size_t | row, |
| size_t | column, | ||
| XlCVError * | error = NULL ) const |
Returns true if the cell in the given row and column, numbered from 0, contains an error value, such as #N/A or #DIV/0!
. If error is not NULL, it is set to the error value.
| wxVector< wxVariant > wxAutoExcel::wxExcelRangeData::GetRow | ( | size_t | row | ) | const |
Returns the cells of the given row, numbered from 0.
| wxVector< wxVariant > wxAutoExcel::wxExcelRangeData::GetColumn | ( | size_t | column | ) | const |
Returns the cells of the given column, numbered from 0.
| wxVariant wxAutoExcel::wxExcelRangeData::ToVariant | ( | ) | const |
Converts the data to a wxVariant containing a two-dimensional SAFEARRAY of VARIANTs, which can be passed e.g.
to wxExcelRange::SetValue(). Returns a null wxVariant when the data are empty.
The SAFEARRAY is destroyed when the wxVariant is passed to an automation call, otherwise the caller must destroy it with SafeArrayDestroy().
|
static |
Sets data from the value of a range returned by Excel, which is a two-dimensional SAFEARRAY of VARIANTs for a range with more than one cell, or a single value for a single cell.
A SAFEARRAY is not destroyed. Returns false, leaving data empty, when value is a SAFEARRAY of another type or with another number of dimensions, or a list, which has no dimensions.