Interface IIconConditionValue
Represents a condition value for IIconSet conditions.
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.Base.dll
Syntax
public interface IIconConditionValue : IConditionValue
Properties
IconSet
Returns or sets IconSet for individual IconSet criteria. It allows the custom Iconset and works based in the index.
Declaration
ExcelIconSetType IconSet { get; set; }
Property Value
Type | Description |
---|---|
ExcelIconSetType |
Remarks
Custom IconSet Conditional Formatting allows you to format your data based the IconSet criteria value from ExcelIconSetType. For example the icon set is initially set to use the FiveBoxes icon set, but this IconSet property is used to override which icons are used for the first or seconde and third criteria. You can set individual icon based on the index of the IconSet Type.
Examples
The following code illustrates how to use the Custom Iconset.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create a worksheet.
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
// Create icon sets for the data in specified range
IConditionalFormats conditionalFormats = worksheet.Range["H1:K6"].ConditionalFormats;
IConditionalFormat conditionalFormat = conditionalFormats.AddCondition();
conditionalFormat.FormatType = ExcelCFType.IconSet;
IIconSet iconSet = conditionalFormat.IconSet;
iconSet.IconSet = ExcelIconSetType.FiveBoxes;
IIconConditionValue iconValue1 = iconSet.IconCriteria[0] as IIconConditionValue;
//Set the Iconset for first IconSet Criteria
iconValue1.IconSet = ExcelIconSetType.FiveArrowsGray;
iconValue1.Index = 2;
iconValue1.Type = ConditionValueType.Percent;
iconValue1.Value = "25";
iconValue1.Operator = ConditionalFormatOperator.GreaterThanorEqualTo;
IIconConditionValue iconValue2 = iconSet.IconCriteria[1] as IIconConditionValue;
//Set the Iconset for second IconSet Criteria
iconValue2.IconSet = ExcelIconSetType.ThreeArrows;
iconValue2.Index = 0;
iconValue2.Type = ConditionValueType.Percent;
iconValue2.Value = "50";
iconValue2.Operator = ConditionalFormatOperator.GreaterThan;
IIconConditionValue iconValue3 = iconSet.IconCriteria[2] as IIconConditionValue;
//Set the Iconset for third IconSet Criteria
iconValue3.IconSet = ExcelIconSetType.FourArrows;
iconValue3.Index = 1;
iconValue3.Type = ConditionValueType.Percent;
iconValue3.Value = "75";
iconValue3.Operator = ConditionalFormatOperator.GreaterThanorEqualTo;
//Save and Dispose.
workbook.SaveAs("ConditionalFormats.xlsx");
workbook.Close();
}
Index
Gets or sets index of the iconset type's individual icon index.
Declaration
int Index { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
Custom IconSet Conditional Formatting allows you to format your IconSet data based the IconSet index criteria. For example the index is initially set to 0. In ThreeArrows, there are three icons, but the Index property represents the first Icon based on the index value.
Examples
The following code illustrates how to use the Custom Iconset index.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create a worksheet.
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
// Create icon sets for the data in specified range
IConditionalFormats conditionalFormats = worksheet.Range["H1:K6"].ConditionalFormats;
IConditionalFormat conditionalFormat = conditionalFormats.AddCondition();
conditionalFormat.FormatType = ExcelCFType.IconSet;
IIconSet iconSet = conditionalFormat.IconSet;
iconSet.IconSet = ExcelIconSetType.FiveBoxes;
IIconConditionValue iconValue1 = iconSet.IconCriteria[0] as IIconConditionValue;
iconValue1.IconSet = ExcelIconSetType.FiveArrowsGray;
//Set the Iconset index for first IconSet Criteria
iconValue1.Index = 2;
iconValue1.Type = ConditionValueType.Percent;
iconValue1.Value = "25";
iconValue1.Operator = ConditionalFormatOperator.GreaterThanorEqualTo;
IIconConditionValue iconValue2 = iconSet.IconCriteria[1] as IIconConditionValue;
iconValue2.IconSet = ExcelIconSetType.ThreeArrows;
//Set the Iconset index for second IconSet Criteria
iconValue2.Index = 0;
iconValue2.Type = ConditionValueType.Percent;
iconValue2.Value = "50";
iconValue2.Operator = ConditionalFormatOperator.GreaterThan;
IIconConditionValue iconValue3 = iconSet.IconCriteria[2] as IIconConditionValue;
iconValue3.IconSet = ExcelIconSetType.FourArrows;
//Set the Iconset index for third IconSet Criteria
iconValue3.Index = 1;
iconValue3.Type = ConditionValueType.Percent;
iconValue3.Value = "75";
iconValue3.Operator = ConditionalFormatOperator.GreaterThanorEqualTo;
//Save and Dispose.
workbook.SaveAs("ConditionalFormats.xlsx");
workbook.Close();
}