XlRichTextString.Runs Property

Provides access to the collection of cell text regions, each formatted with its own font.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v21.1.Core.dll


public IList<XlRichTextRun> Runs { get; }

Property Value

Type Description

A collection of XlRichTextRun objects.


A worksheet cell may contain a rich formatted text that represents a cell text divided into separate regions (so-called text runs), each of which has its own set of font characteristics. Each run is defined by the XlRichTextRun object and is stored in the collection of runs accessible from the Runs property.


When you create a new XlRichTextString object and set its content using the XlRichTextString.Text property, the Runs collection includes a single run that holds the full cell text formatted with the default font. You can access this run object by its index in the collection and change its font settings using the XlRichTextRun.Font property.

You can also add more runs to the Runs collection to divide the cell text into text regions and specify font properties for each region, as illustrated in the example below.

// Create a new worksheet.
using (IXlSheet sheet = document.CreateSheet())
    // Create the first column and set its width.
    using (IXlColumn column = sheet.CreateColumn())
        column.WidthInPixels = 180;
    // Create the first row.
    using (IXlRow row = sheet.CreateRow())
        // Create the cell A1.
        using (IXlCell cell = row.CreateCell())
            // Create an XlRichTextString instance.
            XlRichTextString richText = new XlRichTextString();
            // Add three text runs to the collection. 
            richText.Runs.Add(new XlRichTextRun("Formatted ", XlFont.CustomFont("Arial", 14.0, XlColor.FromArgb(0x53, 0xbb, 0xf4))));
            richText.Runs.Add(new XlRichTextRun("cell ", XlFont.CustomFont("Century Gothic", 14.0, XlColor.FromArgb(0xf1, 0x77, 0x00))));
            richText.Runs.Add(new XlRichTextRun("text", XlFont.CustomFont("Consolas", 14.0, XlColor.FromArgb(0xe3, 0x2c, 0x2e))));
            // Add the rich formatted text to the cell. 

For details on how to apply different fonts to specific regions of the cell text, refer to the How to: Apply Rich Formatting to the Cell Text document.

See Also