Syncfusion.XlsIO.Base
Example 


Clear Method (IRichTextString)

Clears text and formatting.
Syntax
'Declaration
 
Sub Clear() 
'Usage
 
Dim instance As IRichTextString
 
instance.Clear()
void Clear()
Example
The following code illustrates how to clear RichText's text and formatting applied.
using Syncfusion.XlsIO;
            
class Program
{
    static void Main()
    {
        using (ExcelEngine excelEngine = new ExcelEngine())
        {
            //Create worksheet
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook = application.Workbooks.Create(1);
            IWorksheet worksheet = workbook.Worksheets[0];
            
            //Add style
            IStyle style = workbook.Styles.Add("CustomStyle");
            
            //Set style
            worksheet["C2"].CellStyle = style;
            
            //Set text
            worksheet["C2"].Text = "Sample text";
            
            //Set RichText
            IRichTextString richText = worksheet["C2"].RichText;
            
            //Get font
            IFont font = style.Font;
            
            //Set color
            font.Color = ExcelKnownColors.Red;
            
            //Set format to RichText
            richText.SetFont(0, 5, font);
            
            //Clear RichText
            richText.Clear();
            
            //Save and Dispose
            workbook.SaveAs("CellFormats.xlsx");
            workbook.Close();
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 17.2460.0.34

See Also