Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Grid User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

14.2 CGXFormulaSheet Class

The CGXFormulaSheet class acts like an interface to the Objective Grid formula engine. CGXFormulaSheet can be attached to a CGXGridCore object and replace the CGXData object that holds all the cell data. CGXFormulaSheet has special overrides for GetStyleRowCol() and StoreStyleRowCol() that ensure that cell changes are stored directly in the formula engine. In addition, other operations such as moving, removing, and inserting cells are forwarded to the engine by overrides in CGXFormulaSheet.

14.2.1 Cell Values

The tables in this section (Table 10 through Table 18) list and describe the methods provided by the CGXFormulaSheet class.

Table 10: Cell Value Methods

Method Purpose
SetFormulaRowCol Assigns a formula expression to a cell. The formula must start with an equal sign (=).
SetTextRowCol Assigns a text label to a cell.
GetTextRowCol Returns the text value for a cell. Numeric values are converted to strings. Formulas are reevaluated if necessary. Cells with error state will return "Error!" as text.
SetNumberRowCol Assigns a number to a cell.
GetNumberRowCol Returns the numeric value for a cell. Text label returns 0. Formula is reevaluated when necessary.
SetFormatRowCol Changes the numeric formatting of a cell.
GetFormatRowCol Returns the numeric formatting to a cell.
SetExpressionRowCol Parses the given text and (based on the text content) assigns a formula, a text label, or a number to the specified cell. To force numeric or date values to be stored as string, insert an apostrophe (') at the beginning of the text. Formulas must start with an equal sign (=).
GetExpressionRowCol Returns either the text value or formula for the cell. Numeric values will be converted to a string. Text label cells will have a leading apostrophe (') to identify them as string.
GetUpdateFlag Checks if the given cell needs to be redrawn (e.g. if formula result has been changed). CGXGridCore::RefreshViews checks GetUpdateFlag() for all visible and refreshes them if GetUpdateFlag() returns TRUE.
SetUpdateFlag Forces the given cell to be redrawn with the next RefreshViews() call.


CGXGridCore::SetValueRange and CGXGridCore::SetExpressionRowCol() call CGXFormulaSheet::SetExpressionRow() after they ensure that the cell is not read-only and notify the cell object of the change.

Call the above cell value methods (SetNumberRowCol() and SetTextRowCol()) directly if you want to initialize the grid with a large data-set. It is much faster than calling SetValueRange() or SetExpressionRowCol() for each cell. Be aware that if cells are read-only, they are not checked, cell objects are not notified, and Undo information is not created.

Example:

14.2.2 Row and Column Coordinates

The following table lists methods that can be used to convert row and column coordinates.

Table 11: Row and Column Coordinate Methods

Method Purpose
GetEngineRow Converts a grid row coordinate (of type ROWCOL, zero-based) into an engine row coordinate (of type int, zero-based).
GetEngineCol Converts a grid column coordinate (of type ROWCOL, zero-based) into an engine column coordinate (of type int, one-based).
GetGridRow Converts an engine row coordinate (of type int, zero-based) into a grid row coordinate (of type ROWCOL, zero-based).
GetGridCol Converts an engine column coordinate (of type int, one-based) into a grid column coordinate (of type ROWCOL, zero-based).

14.2.3 Sheet Settings

The following table contains methods used to modify sheet settings.

Table 12: Sheet Setting Methods

Method Purpose
SetIterationLimit When the Iteration Limit is set to a non-zero value, iterative calculation is enabled. In this mode, Objective Grid makes multiple recalculation passes and preserves the natural order and minimal recalculation rules until either the iteration limit has been reached or, if constraint checking is enabled, until all constraints are satisfied, whichever comes first.
GetIterationLimit Returns the Iteration Limit value.
SetBlanksAreZeros Specified if blank cells should be treated as a numeric 0 in formula expressions.
GetBlanksAreZeros Returns TRUE if blank cells should be treated as a numeric 0 in formula expressions.
SetRecalcMode Objective Gridlets you decide whether to recalculate the spreadsheet after you make changes that affect other cells or whenever the sheet is initially loaded.Objective Grid automatically recalculates the spreadsheets in both cases if Recalculation Mode is set to Automatic. If recalculation is too time-consuming, you can switch off automatic recalculation so Objective Grid will only recalculate upon explicit request.
GetRecalcMode Returns the recalc mode setting.
SetRecalcMethod Recalculation Method defines how Objective Gridproceeds with recalculation.There are two options: As Needed and Foreground. As Needed indicates that recalculation is highly optimized to recompute the minimum number of cells when updating the sheet. This can result in a significant performance improvement for certain types of sheets, particularly on very large sheets.
GetRecalcMethod Returns the recalculation method setting.
SetConstraintCheck Toggles on/off constraint checking. Constraints are limitations or conditions placed on the variables in your spreadsheet. They are expressed as algebraic statements appended to formulas. You can attach a constraint expression to any formula by typing a semicolon (;) and the constraint conditions after the formula.
GetConstraintCheck Returns TRUE if constraint checking is enabled.

14.2.4 Recalculation

The following table lists methods used for recalculation.

Table 13: Recalculation Methods

Method Purpose
AddRecalcRange Marks a given range of cells so that formula cells that depend on the marked cells can later be reevaluated. The formula engine maintains a recalc range list where all these ranges are added.
Recalc Recalculates all cells in the worksheet that depend on cells in the recalc range list.
ResetError Resets the error state of the formula engine.
GetError Returns the error state of the formula engine. Objective Grid calls this method and when necessary displays a message box with error information based on the return value of this GetError method.

14.2.5 Named Ranges

The following table contains methods used with named ranges.

Table 14: Named Range Methods

Method Purpose
SetRangeName Adds a named range or replaces an existing named range with the new range settings.
GetRangeName Returns the associated range for a given range name.
DeleteRangeName Deletes a named range from the range name list.
GetRangeNameArray Returns a string array with all named ranges. Each entry in the array is in the form 'name=A1..B5'.
SetRangeNameArray Adds a batch of named ranges from a string array. Each entry in the array is in the form 'name=A1..B5'.

14.2.6 Range Specification

The following methods convert range specifications.

Table 15: Range Specification Methods

Method Purpose
TextToRange Converts a range specification, e.g. 'A1..C5', into a CGXRange object, e.g. CGXRange(1,1,5,3).
RangeToText Converts a CGXRange object, e.g. CGXRange(1,1,5,3), into a range specification, e.g. 'A1..C5'.

Keep in mind the following points about these range specification methods:

See Section 14.5.5, "Cell Referencing in Objective Grid," for more information about absolute and relative cell references. See Section 14.3.6, "Ranges," for more information about ranges.

14.2.7 Expression Evaluation

The following methods are used for parsing expressions.

Table 16: Expression Evaluation Methods

Method Purpose
EvaluateExpression Parses and evaluates the given expression and returns the result as a string.
ParseExpression Parses the given expression and returns the parsed formula expression in binary format.

14.2.8 Clipboard Cut/Copy and Paste

Methods associated with the clipboard include:

Table 17: Clipboard Methods

Method Purpose
StoreCopyCells Copies cells from source range to a destination range. Cell references in formula expressions (unless marked as absolute range) will be adjusted.
StoreMoveCells Moves cells from source range to a destination range. Cell references in formula expressions that depend on cells in the moved range will be adjusted.

14.2.9 Cell Operations

The following table lists cell operation methods.

Table 18: Cell Operation Methods

Method Purpose
GetColCount Returns the number of columns.
GetRowCount Returns the number of rows.
StoreColCount Specifies the number of columns.
StoreRowCount Specifies the number of rows.
GetStyleRowCol Looks up a style in the formula engine. If called with nType = GX_VALUE_EXPRESSION the formula expression (if available) is assigned to the style value. Otherwise, the evaluated cell value (the result) is assigned to the cell value.
StoreStyleRowCol Stores a style into the formula engine. If called with nType = GX_VALUE_EXPRESSION, the style value is parsed by calling SetExpressionRowCol. Otherwise, the style value is assigned to the cell as a text label (by calling SetTextRowCol).
StoreInsertCols Inserts columns in the formula engine and updates cell references to moved cells.
StoreInsertRows Inserts rows in the formula engine and updates cell references to moved cells.
StoreMoveCols Moves columns in the formula engine and updates cell references to moved cells.
StoreMoveRows Moves rows in the formula engine and updates cell references to moved cells.
StoreRemoveCols Removes columns in the formula engine and updates cell references to moved cells.
StoreRemoveRows Removes rows in the formula engine and updates cell references to moved cells.
StoreMoveDataCols Rearranges the columns in the grid. The new order of columns is specified through the awColIndex array. Cell references to moved cells are updated.
StoreMoveDataRows Rearranges the rows in the grid. The new order of rows is specified through the awRowIndex array. Cell references to moved cells are updated.


Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.