Aspose::Cells::ConditionalFormattingCollection class

ConditionalFormattingCollection class

Encapsulates a collection of FormatCondition objects.

class ConditionalFormattingCollection

Methods

MethodDescription
Add()Adds a FormatConditions to the collection.
ConditionalFormattingCollection(ConditionalFormattingCollection_Impl* impl)Constructs from an implementation object.
ConditionalFormattingCollection(const ConditionalFormattingCollection& src)Copy constructor.
Copy(const ConditionalFormattingCollection& cfs)Copies conditional formatting.
Get(int32_t index)Gets the FormatConditions element at the specified index.
GetCount()
IsNull() constChecks whether the implementation object is nullptr.
explicit operator bool() constoperator bool()
operator=(const ConditionalFormattingCollection& src)operator=
RemoveArea(int32_t startRow, int32_t startColumn, int32_t totalRows, int32_t totalColumns)Remove all conditional formatting in the range.
~ConditionalFormattingCollection()Destructor.

Fields

FieldDescription
_implThe implementation object.

Examples

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

//Get Conditional Formatting
ConditionalFormattingCollection cformattings = sheet.GetConditionalFormattings();
//Adds an empty conditional formatting
int index = cformattings.Add();
//Get newly added Conditional formatting
FormatConditionCollection fcs = cformattings.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);

//Add condition.
int conditionIndex = fcs.AddCondition(FormatConditionType::CellValue, OperatorType::Between, u"=A2", u"100");
//Add 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