Skip to main content

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.v24.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.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomFont(String) method.

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