Aspose::Cells::Top10 class

Top10 class

Describe the Top10 conditional formatting rule. This conditional formatting rule highlights cells whose values fall in the top N or bottom N bracket, as specified.

class Top10

Methods

MethodDescription
GetRank()Get or set the value of “n” in a “top/bottom n” conditional formatting rule. If IsPercent is true, the value must between 0 and 100. Otherwise it must between 0 and 1000. Default value is 10.
IsBottom()Get or set whether a “top/bottom n” rule is a “bottom n” rule. Default value is false.
IsNull() constChecks whether the implementation object is nullptr.
IsPercent()Get or set whether a “top/bottom n” rule is a “top/bottom n percent” rule. Default value is false.
explicit operator bool() constoperator bool()
operator=(const Top10& src)operator=
SetIsBottom(bool value)Get or set whether a “top/bottom n” rule is a “bottom n” rule. Default value is false.
SetIsPercent(bool value)Get or set whether a “top/bottom n” rule is a “top/bottom n percent” rule. Default value is false.
SetRank(int32_t value)Get or set the value of “n” in a “top/bottom n” conditional formatting rule. If IsPercent is true, the value must between 0 and 100. Otherwise it must between 0 and 1000. Default value is 10.
Top10()Default constructor.
Top10(Top10_Impl* impl)Constructs from an implementation object.
Top10(const Top10& src)Copy constructor.
~Top10()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 = CellArea::CreateCellArea(0, 0, 10, 10);
fcs.AddArea(ca);

//Adds condition.
int conditionIndex = fcs.AddCondition(FormatConditionType::Top10, OperatorType::None, nullptr, nullptr);
//Sets the background color.
FormatCondition fc = fcs.Get(conditionIndex);
fc.GetStyle().SetBackgroundColor(Color{ 0xff, 0xff, 0, 0 });
Top10 top10 = fc.GetTop10();
//Set the Top N
top10.SetRank(5);
//Saving the Excel file
workbook.Save(u"output.xls");

Aspose::Cells::Cleanup();

See Also