Search Results for

    Show / Hide Table of Contents

    Interface IFont

    Interface for cell font value

    Namespace: IronXL.Styles
    Assembly: IronXL.dll
    Syntax
    public interface IFont

    Controlling the typeface of an Excel cell in C# runs through IFont. It describes the font applied to a cell or range, the family, size, weight, and decoration, and is the part of a cell's style a developer touches whenever text needs to stand out as a heading, a total, or a flagged value. It pairs with the borders and fill on the same cell to produce the finished look.

    A developer reaches IFont through IStyle.Font, the get-only property on the style returned by Cell.Style or Range.Style. There is no separate construction step: read .Style.Font and assign to its members, and assigning through a range's style applies the font to every cell in that range at once. This keeps header rows and labeled columns consistent without per-cell code.

    The members map closely to Excel's font dialog. Name sets the typeface and Height the point size, while Bold and Italic control the weight and slant a heading or total usually needs. Underline takes a FontUnderlineType for single or double underlining, Strikeout draws a line through the text for struck-out values, and FontScript raises or lowers text for superscript and subscript. Color is set either through the Color string property or the SetColor method, which accepts a Color value or an RGB string for convenience, so a developer can pass whichever form is already on hand. Because IFont is reached through IStyle.Font, the usual idiom chains the two: range.Style.Font.Bold = true, and the same font members carry over whether the target is one cell or a whole range.

    using IronXL;
    
    WorkBook workbook = WorkBook.Load("report.xlsx");
    WorkSheet sheet = workbook.DefaultWorkSheet;
    IFont font = sheet["A1"].Style.Font;
    font.Name = "Calibri";
    font.Height = 14;
    font.Bold = true;
    font.SetColor("#C00000");

    The cell font size how-to covers sizing and weight, the style cells, borders, and fonts example shows fonts alongside the rest of a cell's styling, and the border and alignment how-to covers the borders and layout that pair with a font on the same style.

    Properties

    Bold

    Property that indicates if cell font is bold

    Declaration
    bool Bold { get; set; }
    Property Value
    Type Description
    System.Boolean

    Color

    Property that returns font color in rgb format.

    Declaration
    string Color { get; set; }
    Property Value
    Type Description
    System.String

    FontScript

    Gets or sets script property of font. Also take a look at FontScript to get list of available options

    Declaration
    FontScript FontScript { get; set; }
    Property Value
    Type Description
    FontScript

    Height

    Gets or sets font size in px

    Declaration
    short Height { get; set; }
    Property Value
    Type Description
    System.Int16

    Italic

    Property that indicates if cell font is italic

    Declaration
    bool Italic { get; set; }
    Property Value
    Type Description
    System.Boolean

    Name

    Gets or sets font name

    Declaration
    string Name { get; set; }
    Property Value
    Type Description
    System.String

    Strikeout

    Get whether to use a strikeout horizontal line through the text or not

    Declaration
    bool Strikeout { get; set; }
    Property Value
    Type Description
    System.Boolean

    Underline

    Gets or sets underline property of font. Also take a look at FontUnderlineType to get list of available options

    Declaration
    FontUnderlineType Underline { get; set; }
    Property Value
    Type Description
    FontUnderlineType

    Methods

    SetColor(Color)

    Method for setting font color with Color value

    Declaration
    void SetColor(Color color)
    Parameters
    Type Name Description
    IronSoftware.Drawing.Color color

    Color value

    SetColor(String)

    Method for setting font color with the rgb string.

    Declaration
    void SetColor(string rgb)
    Parameters
    Type Name Description
    System.String rgb

    Color rgb value

    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget
    %s requires a valid license key for further deployment. Get Trial Below.
    ironsuite
    Blue key in circleGet Started for Free
    30 days full access • No credit card required
    Test in a live environment

    Test in production without watermarks.
    Works wherever you need it to.

    Fully-functional product

    Get 30 days of fully functional product.
    Have it up and running in minutes.

    24/5 technical support

    Full access to our support engineering team during your product trial

    Grey key in circleGet Started for Free
    The trial form was submitted successfully.
    Grey check in circleTrial key delivered
    Your key has been issued and sent to your email.
    Calendar in circleBook Free Live Demo
    No cards • no pitches • no commitments Pick a time for a quick, personalized demo
    Get the most out of your 30-day trial with:

    Live product and key features walk-through

    Project-specific recommendations

    All your questions answered

    Grey key in circleBook Free Live Demo
    Your booking has been completed Check your e-mail for confirmation

    Want to deploy Iron Suite
    to a live project for FREE?

    What’s included?

    • Test in production without watermarks
    • 30 days fully functional product
    • 24/5 technical support during trial
    ironpdf Logo
    ironword Logo
    ironxl Logo
    ironppt Logo
    ironocr Logo
    ironbarcode Logo
    ironqr Logo
    ironprint Logo
    ironzip Logo
    ironwebscraper Logo
    Iron Software sales team
    Online 24/5
    Have Enterprise licensing requirements?
    Request Iron Suite Enterprise trial
    Key in blue circle

    Get your free 30-day Trial Key instantly

    Your trial license will be sent to your email address

    No limitations. 100% unlocked. No credit card.

    bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
    Or
    Key in blue circle

    Complete Your Trial Key Signup

    Tell us a little more about yourself.

    Key in blue circleNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
    Key in blue circle

    Your license key has been delivered to your inbox

    Can't find it? Check your spam folder.

    What’s next?
    Install with NuGet
    Add IronXL to your project
    Quickstart Guide
    Helpful resources to get started

    Need help getting started?

    Book a Free Live Demo

    See IronXL in action and get your licensing questions answered, or

    Key in blue circle

    Your demo request is in.

    You'll receive an invite via email shortly.

    What’s next?
    Explore Documentation
    Review Licensing Options
    badge_greencheck_in_yellowcircle
    Thank you
    Your trial key should be in the email.
    If it is not, please contact support@ironsoftware.com
    • Logo Aetna
    • Logo NASA
    • Logo GE
    • Logo Porsche
    • Logo USDA
    • Logo Qatar
    Join Millions of Engineers who’ve tried IronXL
    Your trial key should be in the email.
    If it is not, please contact support@ironsoftware.com