Skip to main content

XlFont.CustomFont(String, Double, XlColor) Method

Creates the XlFont object that specifies a custom font with the given face name, size and color.

Namespace: DevExpress.Export.Xl

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

Declaration

public static XlFont CustomFont(
    string fontName,
    double size,
    XlColor color
)

Parameters

Name Type Description
fontName String

A String value that specifies the font name.

size Double

A Double value that specifies the font size in points.

color XlColor

An XlColor object that specifies the font color.

Returns

Type Description
XlFont

An XlFont class instance that is the custom font with specified characteristics.

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, XlFontBase.Size and XlFont.Color properties of the XlFont object to define a cell font with a particular face name, size and color. 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, Double, XlColor) 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