Syncfusion.XlsIO.Base
Example 


Text Property (IConditionalFormat)

Gets or sets the text value used in SpecificText conditional formatting rule. The default value is null.
Syntax
'Declaration
 
Property Text As String
'Usage
 
Dim instance As IConditionalFormat
Dim value As String
 
instance.Text = value
 
value = instance.Text
string Text {get; set;}
Example
To apply conditional formats based on the text present in the cells within conditional formatting range, then we set the text we want to apply formatting to Text and set ExcelCFType.SpecificText to FormatType. Here for example, we set "Test" to Text and set ExcelCFType.SpecificText to FormatType.
using Syncfusion.XlsIO;
using System;
            
class Example                                                  
{
    static void Main()
    {
        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];
            
            //Load data to Apply Conditional Formatting.
            worksheet["B1"].Text = "Conditional Formats";
            worksheet["B2"].Text = "Test";
            worksheet["B3"].Text = "Test";
            worksheet["B4"].Text = "Text";
            worksheet["B5"].Text = "Text";
            worksheet["B6"].Text = "Test";
            worksheet["B7"].Text = "Text";
            worksheet["B8"].Text = "Test";
            worksheet["B9"].Text = "Text";
            worksheet["B10"].Text = "Text";
            worksheet["B11"].Text = "Test";
            
            //Create instance of IConditionalFormats.
            IConditionalFormats formats = worksheet["B2:B11"].ConditionalFormats;
            
            //Add condition.
            IConditionalFormat format = formats.AddCondition();
            
            //Set FormatType.
            format.FormatType = ExcelCFType.SpecificText;
            
            //Set color.
            format.BackColor = ExcelKnownColors.Red;
            
            //Set Text.
            format.Text = "Test";
            
            //Save and Dispose.
            workbook.SaveAs("ConditionalFormats.xlsx");
            workbook.Close();
            Console.ReadKey();
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 17.1460.0.32

See Also