<< Return to Main Index

< Return to Class Index

CGXStyle::SetValueType

CGXStyle& SetValueType(unsigned nType);

nType

Possible types are: GX_VT_STRING for string values, GX_VT_NUMERIC for numberic values, GX_VT_EXPRESSION for expressions (formulas) and GX_VT_ERROR for error values.

Return Value

Returns the this pointer.

Remarks

Sets the value type. Possible types are: GX_VT_STRING, GX_VT_NUMERIC, GX_VT_EXPRESSION and GX_VT_ERROR.

SetValueType does not affect the way values are stored in CGXStyle. All values are stored as a string. SetValueType only offers additional information of the value that is stored in the cell. For example, when you apply numeric formatting to a cell that will only affect the cell if the value type is GX_VT_NUMERIC.

The value type information is very important when you pass style objects to the formula engine because depending on the value type the formula engine will decide whether it stores the value as a number in (double format) or as string into the engine. For the formula engine it is very important to distinct between numbers and strings.

Example:

SetValueRange(CGXRange(nRow, nCol), 122.22); // this will set value type to GX_VT_NUMERIC
SetValueRange(CGXRange(nRow, nCol), "122.22"); // this will set value type to GX_VT_STRING
SetStyleRange(CGXRange(nRow, nCol), CGXStyle().SetValue ("122.22")); // this will set value type to GX_VT_STRING
SetStyleRange(CGXRange(nRow, nCol), CGXStyle().SetValue (929.2)); // this will set value type to GX_VT_NUMERIC
SetExpressionRowCol (nRow, nCol, "1222.22"); // SetExpressionRowCol parses the string and will set value type to GX_VT_NUMERIC
SetExpressionRowCol (nRow, nCol, "ABDGDDG1222.22"); // SetExpressionRowCol parses the string and will set value type to GX_VT_STRING

See Also

CGXStyle::SetValue CGXStyle::SetFormat

CGXStyle

Class Overview | Class Members