Class FormatConditionCollection
Contents
[
Hide
]FormatConditionCollection class
Represents conditional formatting. The FormatConditions can contain up to three conditional formats.
public class FormatConditionCollection
Properties
| Name | Description |
|---|---|
| Count { get; } | Gets the count of the conditions. |
| Item { get; } | Gets the formatting condition by index. |
| RangeCount { get; } | Gets count of conditionally formatted ranges. |
Methods
| Name | Description |
|---|---|
| Add(CellArea, FormatConditionType, OperatorType, string, string) | Adds a formatting condition and effected cell rang to the FormatConditions The FormatConditions can contain up to three conditional formats. References to the other sheets are not allowed in the formulas of conditional formatting. |
| AddArea(CellArea) | Adds a conditional formatted cell range. |
| AddCondition(FormatConditionType) | Add a format condition. |
| AddCondition(FormatConditionType, OperatorType, string, string) | Adds a formatting condition. |
| GetCellArea(int) | Gets the conditional formatted cell range by index. |
| RemoveArea(int) | Removes conditional formatted cell range by index. |
| RemoveArea(int, int, int, int) | Remove conditional formatting int the range. |
| RemoveCondition(int) | Removes the formatting condition by index. |
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using System;
public class FormatConditionCollectionDemo
{
public static void FormatConditionCollectionExample()
{
// Create a new Workbook
Workbook workbook = new Workbook();
// Get the first worksheet
Worksheet sheet = workbook.Worksheets[0];
// Adds an empty conditional formatting
int index = sheet.ConditionalFormattings.Add();
FormatConditionCollection fcs = sheet.ConditionalFormattings[index];
// Sets the conditional format range
CellArea ca = new CellArea { StartRow = 0, EndRow = 0, StartColumn = 0, EndColumn = 0 };
fcs.AddArea(ca);
ca = new CellArea { StartRow = 1, EndRow = 1, StartColumn = 1, EndColumn = 1 };
fcs.AddArea(ca);
// Adds conditions
int conditionIndex1 = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "=A2", "100");
int conditionIndex2 = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "50", "100");
// Sets the background color
FormatCondition fc1 = fcs[conditionIndex1];
fc1.Style.BackgroundColor = System.Drawing.Color.Red;
// Saving the Excel file
workbook.Save("FormatConditionCollectionExample.xlsx");
workbook.Save("FormatConditionCollectionExample.pdf");
return;
}
}
}
See Also
- namespace Aspose.Cells
- assembly Aspose.Cells