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

XlFont.CustomFont(String) Method

Creates the XlFont object that specifies a custom font with the given face name.

Namespace: DevExpress.Export.Xl

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

Declaration

public static XlFont CustomFont(
    string fontName
)

Parameters

Name Type Description
fontName String

A String value that specifies the font name.

Returns

Type Description
XlFont

An XlFont class instance that represents the custom font.

Remarks

Use the static CustomFont methods to create the XlFont class instance with the specified font attributes (font name, size and/or color). To apply this font to cell content, assign the XlFont object to the IXlCell.Formatting property or pass it to the IXlCell.ApplyFormatting method as a parameter, as shown in the example below.

using (IXlSheet sheet = document.CreateSheet()) {
    // Create the first row in the worksheet.
    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";
            // Specify the custom font attributes.
            XlFont font = XlFont.CustomFont("Century Gothic", 14, Color.DeepSkyBlue);
            font.Bold = true;
            // Apply the custom font to the cell content.
            cell.ApplyFormatting(font);
        }
    }
}

You can also use the XlFontBase.Name property of the XlFont object to define a particular cell font. For more information on how to specify font settings for an individual cell, refer to the How to: Configure Cell Font Settings article.

See Also