Skip to main content
A newer version of this page is available. .

XlRichTextRun Class

Represents a region of the cell text with its own set of font characteristics.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v20.2.Core.dll

NuGet Packages: DevExpress.Printing.Core, DevExpress.WindowsDesktop.Printing.Core

Declaration

public class XlRichTextRun

Remarks

A cell in a worksheet may contain a rich formatted text (XlRichTextString) grouped into one or more runs. Each run is specified by the XlRichTextRun object and defines a region of the cell text (XlRichTextRun.Text) with its own set of font characteristics (XlRichTextRun.Font). The XlRichTextString.Runs property provides access to the collection that stores text runs. Use the collection’s methods to divide the cell text into regions and specify font settings for each text region. For details, refer to the How to: Apply Rich Formatting to the Cell Text example.

Example

// 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. 
            cell.SetRichText(richText);
        }
    }
}

Inheritance

Object
XlRichTextRun
See Also