Aspose::Cells::FormatCondition class

FormatCondition class

Represents conditional formatting condition.

class FormatCondition

Methods

MethodDescription
FormatCondition(FormatCondition_Impl* impl)Constructs from an implementation object.
FormatCondition(const FormatCondition& src)Copy constructor.
GetAboveAverage()Get the conditional formatting’s “AboveAverage” instance. The default instance’s rule highlights cells that are above the average for all values in the range. Valid only for type = AboveAverage.
GetColorScale()Get the conditional formatting’s “ColorScale” instance. The default instance is a “green-yellow-red” 3ColorScale . Valid only for type = ColorScale.
GetDataBar()Get the conditional formatting’s “DataBar” instance. The default instance’s color is blue. Valid only for type is DataBar.
GetFormula1(bool isR1C1, bool isLocal)Gets the value or expression associated with this format condition.
GetFormula1(bool isR1C1, bool isLocal, int32_t row, int32_t column)Gets the value or expression of the conditional formatting of the cell.
GetFormula1()Gets and sets the value or expression associated with conditional formatting.
GetFormula1(int32_t row, int32_t column)Gets the formula of the conditional formatting of the cell.
GetFormula2(bool isR1C1, bool isLocal)Gets the value or expression associated with this format condition.
GetFormula2(bool isR1C1, bool isLocal, int32_t row, int32_t column)Gets the value or expression of the conditional formatting of the cell.
GetFormula2()Gets and sets the value or expression associated with conditional formatting.
GetFormula2(int32_t row, int32_t column)Gets the formula of the conditional formatting of the cell.
GetIconSet()Get the conditional formatting’s “IconSet” instance. The default instance’s IconSetType is TrafficLights31. Valid only for type = IconSet.
GetOperator()Gets and sets the conditional format operator type.
GetPriority()The priority of this conditional formatting rule. This value is used to determine which format should be evaluated and rendered. Lower numeric values are higher priority than higher numeric values, where ‘1’ is the highest priority.
GetStopIfTrue()True, no rules with lower priority may be applied over this rule, when this rule evaluates to true. Only applies for Excel 2007;.
GetStyle()Gets or setts style of conditional formatted cell ranges.
GetText()The text value in a “text contains” conditional formatting rule. Valid only for type = containsText, notContainsText, beginsWith and endsWith. The default value is null.
GetTimePeriod()The applicable time period in a “date occurring…” conditional formatting rule. Valid only for type = timePeriod. The default value is TimePeriodType.Today.
GetTop10()Get the conditional formatting’s “Top10” instance. The default instance’s rule highlights cells whose values fall in the top 10 bracket. Valid only for type is Top10.
GetType()Gets and sets whether the conditional format Type.
IsNull() constChecks whether the implementation object is nullptr.
explicit operator bool() constoperator bool()
operator=(const FormatCondition& src)operator=
SetFormula1(const U16String& formula, bool isR1C1, bool isLocal)Sets the value or expression associated with this format condition.
SetFormula1(const char16_t* formula, bool isR1C1, bool isLocal)Sets the value or expression associated with this format condition.
SetFormula1(const U16String& value)Gets and sets the value or expression associated with conditional formatting.
SetFormula1(const char16_t* value)Gets and sets the value or expression associated with conditional formatting.
SetFormula2(const U16String& formula, bool isR1C1, bool isLocal)Sets the value or expression associated with this format condition.
SetFormula2(const char16_t* formula, bool isR1C1, bool isLocal)Sets the value or expression associated with this format condition.
SetFormula2(const U16String& value)Gets and sets the value or expression associated with conditional formatting.
SetFormula2(const char16_t* value)Gets and sets the value or expression associated with conditional formatting.
SetFormulas(const U16String& formula1, const U16String& formula2, bool isR1C1, bool isLocal)Sets the value or expression associated with this format condition.
SetFormulas(const char16_t* formula1, const char16_t* formula2, bool isR1C1, bool isLocal)Sets the value or expression associated with this format condition.
SetOperator(OperatorType value)Gets and sets the conditional format operator type.
SetPriority(int32_t value)The priority of this conditional formatting rule. This value is used to determine which format should be evaluated and rendered. Lower numeric values are higher priority than higher numeric values, where ‘1’ is the highest priority.
SetStopIfTrue(bool value)True, no rules with lower priority may be applied over this rule, when this rule evaluates to true. Only applies for Excel 2007;.
SetStyle(const Style& value)Gets or setts style of conditional formatted cell ranges.
SetText(const U16String& value)The text value in a “text contains” conditional formatting rule. Valid only for type = containsText, notContainsText, beginsWith and endsWith. The default value is null.
SetText(const char16_t* value)The text value in a “text contains” conditional formatting rule. Valid only for type = containsText, notContainsText, beginsWith and endsWith. The default value is null.
SetTimePeriod(TimePeriodType value)The applicable time period in a “date occurring…” conditional formatting rule. Valid only for type = timePeriod. The default value is TimePeriodType.Today.
SetType(FormatConditionType value)Gets and sets whether the conditional format Type.
~FormatCondition()Destructor.

Fields

FieldDescription
_implThe implementation object.

Examples

Aspose::Cells::Startup();
//Instantiating a Workbook object
Workbook workbook;
Worksheet sheet = workbook.GetWorksheets().Get(0);

//Adds an empty conditional formatting
int index = sheet.GetConditionalFormattings().Add();
FormatConditionCollection fcs = sheet.GetConditionalFormattings().Get(index);

//Sets the conditional format range.
CellArea ca;
ca.StartRow = 0;
ca.EndRow = 0;
ca.StartColumn = 0;
ca.EndColumn = 0;
fcs.AddArea(ca);

ca = CellArea();
ca.StartRow = 1;
ca.EndRow = 1;
ca.StartColumn = 1;
ca.EndColumn = 1;
fcs.AddArea(ca);

//Adds condition.
int conditionIndex = fcs.AddCondition(FormatConditionType::CellValue, OperatorType::Between, u"=A2", u"100");

//Adds condition.
int conditionIndex2 = fcs.AddCondition(FormatConditionType::CellValue, OperatorType::Between, u"50", u"100");

//Sets the background color.
FormatCondition fc = fcs.Get(conditionIndex);
fc.GetStyle().SetBackgroundColor(Color{ 0xff, 0xff, 0, 0 });

//Saving the Excel file
workbook.Save(u"output.xls");

Aspose::Cells::Cleanup();

See Also