Class Font

Font class

Encapsulates the font object used in a spreadsheet.

public class Font

Properties

NameDescription
ArgbColor { get; set; }Gets and sets the color with a 32-bit ARGB value.
CapsType { get; set; }Gets and sets the text caps type.
Charset { get; set; }Represent the character set.
Color { get; set; }Gets or sets the Color of the font.
DoubleSize { get; set; }Gets and sets the double size of the font.
IsBold { get; set; }Gets or sets a value indicating whether the font is bold.
IsItalic { get; set; }Gets or sets a value indicating whether the font is italic.
IsNormalizeHeights { get; set; }Indicates whether the normalization of height that is to be applied to the text run.
IsStrikeout { get; set; }Gets or sets a value indicating whether the font is single strikeout.
IsSubscript { get; set; }Gets or sets a value indicating whether the font is subscript.
IsSuperscript { get; set; }Gets or sets a value indicating whether the font is super script.
virtual Name { get; set; }Gets or sets the name of the Font.
SchemeType { get; set; }Gets and sets the scheme type of the font.
ScriptOffset { get; set; }Gets and sets the script offset,in unit of percentage
Size { get; set; }Gets or sets the size of the font.
StrikeType { get; set; }Gets the strike type of the text.
ThemeColor { get; set; }Gets and sets the theme color.
Underline { get; set; }Gets or sets the font underline type.

Methods

NameDescription
Equals(Font)Checks if two fonts are equals.
override ToString()Returns a string represents the current Cell object.

Examples

namespace AsposeCellsExamples
{
    using Aspose.Cells;
    using System;
    using System.Drawing;

    public class FontDemo
    {
        public static void FontExample()
        {
            // Instantiating a Workbook object
            Workbook workbook = new Workbook();

            // Obtaining the reference of the newly added worksheet by passing its sheet index
            Worksheet worksheet = workbook.Worksheets[0];

            // Accessing the "A1" cell from the worksheet
            Aspose.Cells.Cell cell = worksheet.Cells["A1"];

            // Adding some value to the "A1" cell
            cell.PutValue("Hello Aspose!");

            // Accessing the font object of the cell style
            Aspose.Cells.Font font = cell.GetStyle().Font;

            // Setting the font name to "Times New Roman"
            font.Name = "Times New Roman";

            // Setting font size to 14
            font.Size = 14;

            // Setting font color as Red
            font.Color = Color.Red;

            // Setting additional font properties
            font.IsBold = true;
            font.IsItalic = true;
            font.Underline = FontUnderlineType.Single;
            font.IsStrikeout = false;
            font.IsSuperscript = false;
            font.IsSubscript = false;
            font.Charset = 1;
            font.CapsType = TextCapsType.None;
            font.StrikeType = TextStrikeType.None;
            font.ScriptOffset = 0;
            font.DoubleSize = 14.0;
            font.ThemeColor = new ThemeColor(ThemeColorType.Accent1, 0.5);
            font.ArgbColor = Color.Red.ToArgb();
            font.IsNormalizeHeights = false;
            font.SchemeType = FontSchemeType.None;

            // Saving the Excel file
            workbook.Save("FontExample.xlsx");
            workbook.Save("FontExample.pdf");
            return;
        }
    }
}

See Also