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

XlFontBase.Name Property

Gets or sets the name of the font applied to the cell content.

Namespace: DevExpress.Export.Xl

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

Declaration

public string Name { get; set; }

Property Value

Type Description
String

A String value that specifies the font name.

Remarks

To set a specific cell font, do one of the following:

  • Assign the required font name to the Name property of the XlFont object and set the XlFontBase.SchemeStyle property to None to indicate that the font is not a theme font.
  • Call the static XlFont.CustomFont method that returns the XlFont class instance with the specified font attributes (font name, size and/or color).

The example below demonstrates how to use these two approaches to set a custom cell font. For more examples on how to specify font settings for an individual cell, refer to the How to: Configure Cell Font Settings article.

// Add a new worksheet to the document. 
using (IXlSheet sheet = document.CreateSheet()) {
    // Create the first row.
    using (IXlRow row = sheet.CreateRow()){
        // Create the first cell in the row.
        using (IXlCell cell = row.CreateCell()){
            // Set the cell value.
            cell.Value = "Custom font #1";
            // Specify the custom font attributes.
            XlFont font = new XlFont();
            font.Name = "Century Gothic";
            font.SchemeStyle = XlFontSchemeStyles.None;
            font.Size = 14;
            font.Color = Color.DeepSkyBlue;
            font.Bold = true;
            // Apply the custom font to the cell content.
            cell.ApplyFormatting(font);
        }
    }

    sheet.SkipRows(1);

    // Create the third row.
    using (IXlRow row = sheet.CreateRow()){
        // Create the first cell in the row.
        using (IXlCell cell = row.CreateCell())
        {
            // Set the cell value.
            cell.Value = "Custom font #2";
            // Specify the custom font attributes.
            XlFont font = XlFont.CustomFont("Courier New", 14, Color.BlueViolet);
            font.Italic = true;
            // Apply the custom font to the cell content.
            cell.ApplyFormatting(font);
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Name property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also