|
wxAutoExcel 2.8.1
|
The base object for all wxAutoExcel objects. More...
#include <wxAutoExcel_object.h>
Public Types | |
| enum | ErrorFlags { Err_DoNothing = 0 , Err_LogOnInvalidDispatch = 1 , Err_AssertOnInvalidDispatch = 1 << 1 , Err_ThrowOnInvalidDispatch = 1 << 2 , Err_LogOnInvalidArgument = 1 << 3 , Err_AssertOnInvalidArgument = 1 << 4 , Err_ThrowOnInvalidArgument = 1 << 5 , Err_LogOnFailedInvoke = 1 << 6 , Err_AssertOnFailedInvoke = 1 << 7 , Err_ThrowOnFailedInvoke = 1 << 8 , Err_LogOnInvalidReturnType = 1 << 9 , Err_AssertOnInvalidReturnType = 1 << 10 , Err_ThrowOnInvalidReturnType = 1 << 11 , Err_LogOnOtherError = 1 << 12 , Err_AssertOnOtherError = 1 << 13 , Err_ThrowOnOtherError = 1 << 14 } |
| Flags affecting the behaviour of wxExcelObject and its descendants when an error occurs during accessing an Excel object property or calling its method. More... | |
Public Member Functions | |
| bool | IsOk_ () const |
| Returns true if the object has a valid dispatch. | |
| virtual wxString | GetAutoExcelObjectName_ () const |
| Returns "Object". | |
| wxString | GetAutomationObjectName_ (bool stripUnderscores=false) const |
| Returns object name as provided by IDispatch->GetTypeInfo()->GetDocumentation(MEMBERID_NIL, &name, NULL, NULL, NULL). | |
| wxSharedPtr< wxAutomationObject > | GetAutomationObject_ () |
| Returns the underlying wxAutomationObject. | |
| template<typename T, typename = typename std::enable_if<std::is_same<T, bool>::value>::type> | |
| operator T () const | |
| Returns true if the object has a valid dispatch and its last automation call (if any), i.e. | |
| bool | IsLastResultNull_ () const |
| Returns true if MS Excel returned Null (or Empty) for the last property or method, e.g. | |
| WXLCID | GetAutomationLCID_ () const |
| Returns the locale identifier used in automation calls. | |
| bool | SetAutomationLCID_ (WXLCID lcid) |
| Sets the locale identifier to be used in automation calls. | |
| bool | GetPropertyAndMethodNames_ (wxArrayString &propertyNames, wxArrayString &methodNames, bool includeHidden=false) |
| Returns lists of property and method names the automation interface exposes. | |
| bool | HasProperty_ (const wxString &name) const |
| Returns true if the automation interface of the object has a property called name, ignoring the case, e.g. | |
| bool | HasMethod_ (const wxString &name) const |
| Returns true if the automation interface of the object has a method called name, ignoring the case, e.g. | |
| bool | GetUnimplementedObject_ (const wxString &name, wxAutomationObject &object) |
| Helper function for receiving an automation object not implemented in wxAutoExcel, see FAQ on how to use. | |
Static Public Member Functions | |
| static unsigned | GetErrorMode_ () |
| Sets the error mode to the combination of wxExcelObject::ErrorFlags. | |
| static void | SetErrorMode_ (unsigned mode) |
| Sets the error mode as the combination of wxExcelObject::ErrorFlags. | |
| static bool | GetUnimplementedCollectionItem_ (wxAutomationObject &collection, const long index, wxAutomationObject &item, bool asProperty) |
| Helper function for obtaining an item from MS Excel collection not implemented in wxAutoExcel, see FAQ on how to use. | |
The base object for all wxAutoExcel objects.
Flags affecting the behaviour of wxExcelObject and its descendants when an error occurs during accessing an Excel object property or calling its method.
| Enumerator | |
|---|---|
| Err_DoNothing | Do nothing when an error occurs, not to be combined with other |
| Err_LogOnInvalidDispatch | Call wxLogError() when attempted to access a property or call a method when the object doesn't have a valid dispatch. |
| Err_AssertOnInvalidDispatch | Call wxASSERT when attempted to access a property or call a method when the object doesn't have a valid dispatch. |
| Err_ThrowOnInvalidDispatch | Throw wxExcelException when attempted to access a property or call a method when the object doesn't have a valid dispatch. |
| Err_LogOnInvalidArgument | Call wxLogError() when an invalid argument has been passed to [Get|Set]Property or calling a method. |
| Err_AssertOnInvalidArgument | Call wxASSERT when an invalid argument has been passed to [Get|Set]Property or calling a method. |
| Err_ThrowOnInvalidArgument | Throw wxExcelException when an invalid argument has been passed to [Get|Set]Property or calling a method. |
| Err_LogOnFailedInvoke | Call wxLogError() when the underlying wxAutomationObject::Invoke() returned false. |
| Err_AssertOnFailedInvoke | Call wxASSERT when the underlying wxAutomationObject::Invoke() returned false. |
| Err_ThrowOnFailedInvoke | Throw wxExcelException when the underlying wxAutomationObject::Invoke() returned false. |
| Err_LogOnInvalidReturnType | Call wxLogError() when the underlying wxAutomationObject::Invoke() returned unexpected variant type. |
| Err_AssertOnInvalidReturnType | Call wxASSERT when the underlying wxAutomationObject::Invoke() returned unexpected variant type. |
| Err_ThrowOnInvalidReturnType | Throw wxExcelException when the underlying wxAutomationObject::Invoke() returned unexpected variant type. |
| Err_LogOnOtherError | Call wxLogError() when an unspecified error occured |
| Err_AssertOnOtherError | Call wxASSERT when an unspecified error occured |
| Err_ThrowOnOtherError | Throw wxExcelException when an unspecified error occured |
|
inline |
Returns true if the object has a valid dispatch.
|
static |
Sets the error mode to the combination of wxExcelObject::ErrorFlags.
Default error mode is set to Err_LogOnInvalidDispatch | Err_AssertOnInvalidDispatch | Err_LogOnInvalidArgument | Err_AssertOnInvalidArgument | Err_LogOnFailedInvoke | Err_AssertOnFailedInvoke | Err_LogOnInvalidReturnType | Err_AssertOnInvalidReturnType | Err_LogOnOtherError | Err_AssertOnOtherError;
|
static |
Sets the error mode as the combination of wxExcelObject::ErrorFlags.
|
inlinevirtual |
Returns "Object".
Reimplemented in wxAutoExcel::wxExcelAboveAverage, wxAutoExcel::wxExcelAddIn, wxAutoExcel::wxExcelAddIns2, wxAutoExcel::wxExcelAddIns, wxAutoExcel::wxExcelAddInsBase, wxAutoExcel::wxExcelAdjustments, wxAutoExcel::wxExcelAllowEditRange, wxAutoExcel::wxExcelAllowEditRanges, wxAutoExcel::wxExcelApplication, wxAutoExcel::wxExcelAreas, wxAutoExcel::wxExcelAuthor, wxAutoExcel::wxExcelAutoFilter, wxAutoExcel::wxExcelAxes, wxAutoExcel::wxExcelAxis, wxAutoExcel::wxExcelAxisTitle, wxAutoExcel::wxExcelBorder, wxAutoExcel::wxExcelBorders, wxAutoExcel::wxExcelBulletFormat2, wxAutoExcel::wxExcelCalloutFormat, wxAutoExcel::wxExcelCategoryCollection, wxAutoExcel::wxExcelCellControl, wxAutoExcel::wxExcelCharacters, wxAutoExcel::wxExcelChart, wxAutoExcel::wxExcelChartArea, wxAutoExcel::wxExcelChartCategory, wxAutoExcel::wxExcelChartColorFormat, wxAutoExcel::wxExcelChartFillFormat, wxAutoExcel::wxExcelChartFormat, wxAutoExcel::wxExcelChartGroup, wxAutoExcel::wxExcelChartGroups, wxAutoExcel::wxExcelChartObject, wxAutoExcel::wxExcelChartObjects, wxAutoExcel::wxExcelCharts, wxAutoExcel::wxExcelChartTitle, wxAutoExcel::wxExcelChartView, wxAutoExcel::wxExcelColorFormat, wxAutoExcel::wxExcelColorScale, wxAutoExcel::wxExcelColorScaleCriteria, wxAutoExcel::wxExcelColorScaleCriterion, wxAutoExcel::wxExcelColorStop, wxAutoExcel::wxExcelColorStops, wxAutoExcel::wxExcelComment, wxAutoExcel::wxExcelComments, wxAutoExcel::wxExcelCommentsThreaded, wxAutoExcel::wxExcelCommentThreaded, wxAutoExcel::wxExcelConditionValue, wxAutoExcel::wxExcelConnectorFormat, wxAutoExcel::wxExcelControlFormat, wxAutoExcel::wxExcelCustomProperties, wxAutoExcel::wxExcelCustomProperty, wxAutoExcel::wxExcelDatabar, wxAutoExcel::wxExcelDataBarBorder, wxAutoExcel::wxExcelDataLabel, wxAutoExcel::wxExcelDataLabels, wxAutoExcel::wxExcelDataTable, wxAutoExcel::wxExcelDisplayFormat, wxAutoExcel::wxExcelDisplayUnitLabel, wxAutoExcel::wxExcelDocumentProperties, wxAutoExcel::wxExcelDocumentProperty, wxAutoExcel::wxExcelDownBars, wxAutoExcel::wxExcelDropLines, wxAutoExcel::wxExcelError, wxAutoExcel::wxExcelErrorBars, wxAutoExcel::wxExcelErrorCheckingOptions, wxAutoExcel::wxExcelErrors, wxAutoExcel::wxExcelFileExportConverter, wxAutoExcel::wxExcelFileExportConverters, wxAutoExcel::wxExcelFillFormat, wxAutoExcel::wxExcelFilter, wxAutoExcel::wxExcelFilters, wxAutoExcel::wxExcelFloor, wxAutoExcel::wxExcelFont2, wxAutoExcel::wxExcelFont, wxAutoExcel::wxExcelFormatColor, wxAutoExcel::wxExcelFormatCondition, wxAutoExcel::wxExcelFormatConditions, wxAutoExcel::wxExcelFreeformBuilder, wxAutoExcel::wxExcelFullSeriesCollection, wxAutoExcel::wxExcelGlowFormat, wxAutoExcel::wxExcelGradientStop, wxAutoExcel::wxExcelGradientStops, wxAutoExcel::wxExcelGraphic, wxAutoExcel::wxExcelGridlines, wxAutoExcel::wxExcelGroupShapes, wxAutoExcel::wxExcelHeaderFooter, wxAutoExcel::wxExcelHiLoLines, wxAutoExcel::wxExcelHyperlink, wxAutoExcel::wxExcelHyperlinks, wxAutoExcel::wxExcelIcon, wxAutoExcel::wxExcelIconCriteria, wxAutoExcel::wxExcelIconCriterion, wxAutoExcel::wxExcelIconSet, wxAutoExcel::wxExcelIconSetCondition, wxAutoExcel::wxExcelIconSets, wxAutoExcel::wxExcelInterior, wxAutoExcel::wxExcelLanguageSettings, wxAutoExcel::wxExcelLeaderLines, wxAutoExcel::wxExcelLegend, wxAutoExcel::wxExcelLegendEntries, wxAutoExcel::wxExcelLegendEntry, wxAutoExcel::wxExcelLegendKey, wxAutoExcel::wxExcelLinearGradient, wxAutoExcel::wxExcelLineFormat, wxAutoExcel::wxExcelLinkFormat, wxAutoExcel::wxExcelListColumn, wxAutoExcel::wxExcelListColumns, wxAutoExcel::wxExcelListDataFormat, wxAutoExcel::wxExcelListObject, wxAutoExcel::wxExcelListObjects, wxAutoExcel::wxExcelListRow, wxAutoExcel::wxExcelListRows, wxAutoExcel::wxExcelModel3DFormat, wxAutoExcel::wxExcelMultiThreadedCalculation, wxAutoExcel::wxExcelName, wxAutoExcel::wxExcelNames, wxAutoExcel::wxExcelNegativeBarFormat, wxAutoExcel::wxExcelOLEFormat, wxAutoExcel::wxExcelOLEObject, wxAutoExcel::wxExcelOLEObjects, wxAutoExcel::wxExcelOutline, wxAutoExcel::wxExcelPage, wxAutoExcel::wxExcelPageBreak, wxAutoExcel::wxExcelPageBreaks, wxAutoExcel::wxExcelPages, wxAutoExcel::wxExcelPageSetup, wxAutoExcel::wxExcelPane, wxAutoExcel::wxExcelPanes, wxAutoExcel::wxExcelParagraphFormat2, wxAutoExcel::wxExcelPictureFormat, wxAutoExcel::wxExcelPlotArea, wxAutoExcel::wxExcelPoint, wxAutoExcel::wxExcelPoints, wxAutoExcel::wxExcelProtection, wxAutoExcel::wxExcelRange, wxAutoExcel::wxExcelRangeOwner, wxAutoExcel::wxExcelRecentFile, wxAutoExcel::wxExcelRecentFiles, wxAutoExcel::wxExcelRectangularGradient, wxAutoExcel::wxExcelReflectionFormat, wxAutoExcel::wxExcelSeries, wxAutoExcel::wxExcelSeriesCollection, wxAutoExcel::wxExcelSeriesLines, wxAutoExcel::wxExcelShadowFormat, wxAutoExcel::wxExcelShape, wxAutoExcel::wxExcelShapeNode, wxAutoExcel::wxExcelShapeNodes, wxAutoExcel::wxExcelShapeRange, wxAutoExcel::wxExcelShapes, wxAutoExcel::wxExcelSheet, wxAutoExcel::wxExcelSheets, wxAutoExcel::wxExcelSheetView, wxAutoExcel::wxExcelSheetViews, wxAutoExcel::wxExcelSoftEdgeFormat, wxAutoExcel::wxExcelSort, wxAutoExcel::wxExcelSortField, wxAutoExcel::wxExcelSortFields, wxAutoExcel::wxExcelSparkAxes, wxAutoExcel::wxExcelSparkColor, wxAutoExcel::wxExcelSparkHorizontalAxis, wxAutoExcel::wxExcelSparkline, wxAutoExcel::wxExcelSparklineGroup, wxAutoExcel::wxExcelSparklineGroups, wxAutoExcel::wxExcelSparkPoints, wxAutoExcel::wxExcelSparkVerticalAxis, wxAutoExcel::wxExcelStyle, wxAutoExcel::wxExcelStyles, wxAutoExcel::wxExcelTab, wxAutoExcel::wxExcelTableObject, wxAutoExcel::wxExcelTableStyle, wxAutoExcel::wxExcelTableStyleElement, wxAutoExcel::wxExcelTableStyleElements, wxAutoExcel::wxExcelTableStyles, wxAutoExcel::wxExcelTabStop2, wxAutoExcel::wxExcelTabStops2, wxAutoExcel::wxExcelTextColumn2, wxAutoExcel::wxExcelTextEffectFormat, wxAutoExcel::wxExcelTextFrame2, wxAutoExcel::wxExcelTextFrame, wxAutoExcel::wxExcelTextRange2, wxAutoExcel::wxExcelThreeDFormat, wxAutoExcel::wxExcelTickLabels, wxAutoExcel::wxExcelTop10, wxAutoExcel::wxExcelTrendline, wxAutoExcel::wxExcelTrendlines, wxAutoExcel::wxExcelUniqueValues, wxAutoExcel::wxExcelUpBars, wxAutoExcel::wxExcelUserAccess, wxAutoExcel::wxExcelUserAccessList, wxAutoExcel::wxExcelValidation, wxAutoExcel::wxExcelWalls, wxAutoExcel::wxExcelWindow, wxAutoExcel::wxExcelWindows, wxAutoExcel::wxExcelWorkbook, wxAutoExcel::wxExcelWorkbooks, wxAutoExcel::wxExcelWorksheet, wxAutoExcel::wxExcelWorksheets, and wxAutoExcel::wxExcelWorksheetView.
| wxString wxAutoExcel::wxExcelObject::GetAutomationObjectName_ | ( | bool | stripUnderscores = false | ) | const |
Returns object name as provided by IDispatch->GetTypeInfo()->GetDocumentation(MEMBERID_NIL, &name, NULL, NULL, NULL).
|
inline |
Returns the underlying wxAutomationObject.
|
inline |
Returns true if the object has a valid dispatch and its last automation call (if any), i.e.
accessing a property or calling a method, succeeded.
A property or method returning an object succeeds also when MS Excel returns Nothing, e.g. wxExcelWorksheet::GetAutoFilter() for a worksheet without an AutoFilter. The returned object is empty then, which can be checked with its conversion to bool or IsOk_().
A property also succeeds when MS Excel returns Null (or Empty), which it does when there is no single value, e.g. for wxExcelFont::GetBold() of a range with both bold and regular cells. The getter returns the default value of its type then (0, false, an empty string, an invalid colour, or an empty object), see IsLastResultNull_().
The object converts only to bool, e.g. in if ( !workbook ), bool ok = workbook;, or return workbook; in a function returning bool, but not to a number. A plain operator bool() would also convert it to a number, so e.g. styles["Normal"] would be ambiguous with the built-in subscript "Normal"[index].
|
inline |
Returns true if MS Excel returned Null (or Empty) for the last property or method, e.g.
for a property of a range whose cells have different values. The getter returned the default value of its type then, e.g. false from wxExcelFont::GetBold() for a range with both bold and regular cells.
| WXLCID wxAutoExcel::wxExcelObject::GetAutomationLCID_ | ( | ) | const |
Returns the locale identifier used in automation calls.
See wxAutomationObject::GetLCID().
| bool wxAutoExcel::wxExcelObject::SetAutomationLCID_ | ( | WXLCID | lcid | ) |
Sets the locale identifier to be used in automation calls.
See wxAutomationObject::SetLCID(). The identifier is passed to MS Excel with each call, how Excel uses it depends on the property or method.
Notably, it does not affect the list separator in the addresses of ranges with several areas, e.g. "A1:B2,D4:E5": MS Excel always uses the list separator of the Windows regional settings there, unlike in VBA, where it is always a comma. See wxExcelApplication::GetListSeparator_() and wxExcelApplication::Union().
| bool wxAutoExcel::wxExcelObject::GetPropertyAndMethodNames_ | ( | wxArrayString & | propertyNames, |
| wxArrayString & | methodNames, | ||
| bool | includeHidden = false ) |
Returns lists of property and method names the automation interface exposes.
If includeHidden is false, names of properties and methods with FUNCFLAG_FHIDDEN set will not be included. Note. The list will also include methods of IUnknown and IDispatch.
| bool wxAutoExcel::wxExcelObject::HasProperty_ | ( | const wxString & | name | ) | const |
Returns true if the automation interface of the object has a property called name, ignoring the case, e.g.
to check whether the version of MS Excel in use has a property before calling it:
The hidden properties are included. Returns false for an object without a valid dispatch.
This checks only that the property exists, the call may still fail, e.g. when it is used on a range for which Excel does not support it.
| bool wxAutoExcel::wxExcelObject::HasMethod_ | ( | const wxString & | name | ) | const |
Returns true if the automation interface of the object has a method called name, ignoring the case, e.g.
to check whether the version of MS Excel in use has a method before calling it.
The hidden methods are included. Returns false for an object without a valid dispatch.
| bool wxAutoExcel::wxExcelObject::GetUnimplementedObject_ | ( | const wxString & | name, |
| wxAutomationObject & | object ) |
Helper function for receiving an automation object not implemented in wxAutoExcel, see FAQ on how to use.
|
static |
Helper function for obtaining an item from MS Excel collection not implemented in wxAutoExcel, see FAQ on how to use.
Some collections provide their items as as Item property (e.g. Workbooks, Windows, Worksheets or Ranges) while others as a result of Item() method call (e.g. ColorStops, Shapes, FormatConditions or Names) If the collection provides items via Property, asProperty must be true, otherwise it must be set to false. You can learn which to use with online Excel VBA Object Model documentaion or using the Object Browser in the Excel VBA IDE. Index must be between 1 and collection.Count.