IRONSOFTWAREHOME

How to Set Cell Font & Size in C# with IronXL

Curtis Chau
Curtis Chau
Updated: July 21, 2026

IronXL enables you to set cell font properties including name, size, color, bold, italic, underline, strikeout, and script positioning in C# .NET without Microsoft Office interop, using simple properties like workSheet["A1"].Style.Font.Height = 18 for instant font customization.

Customizing font properties offers numerous benefits in document formatting. These options improve readability, emphasize critical information, and create visually appealing documents. With IronXL, you can edit font properties without interop in C# .NET, simplifying the process and enabling you to create professional materials effortlessly.

Quickstart: Change a Cell's Font Size in One Line

Use IronXL to instantly adjust cell font size with minimal setup. This code shows how to target a cell and set its font height in a single line.

  1. 1Install IronXL with NuGet Package Manager

    PM > Install-Package IronXL.Excel

  2. 2Copy and run this code snippet.

    workSheet["C3"].Style.Font.Height = 18;
    C#
  3. 3Deploy to test on your live environment

    Start using IronXL in your project today with a free trial
    arrow pointer

How Do I Set Cell Font and Size?

To personalize the font of a selected cell, column, row, or range, set the Font properties of the Style. Use the Name property to set the font family, the Height property to adjust font size, and the Bold property to emphasize font weight. Use the Underline property to add underlining for visual emphasis.

Please note: The Name property sets the font name exactly as provided. For instance, to use "Times New Roman", input it exactly with the same spaces and capital letters.

When working with Excel spreadsheets in C#, font customization is essential for creating professional documents. IronXL provides comprehensive font styling capabilities that match Excel's native functionality, allowing you to create polished Excel files with precise formatting control.

using IronXL;
using IronXL.Styles;

WorkBook workBook = WorkBook.Create();
WorkSheet workSheet = workBook.DefaultWorkSheet;

workSheet["B2"].StringValue = "Font and Size";

// Set font family
workSheet["B2"].Style.Font.Name = "Times New Roman";

// Set font size
workSheet["B2"].Style.Font.Height = 15;

// Set font to bold
workSheet["B2"].Style.Font.Bold = true;

// Set underline
workSheet["B2"].Style.Font.Underline = FontUnderlineType.Single;

workBook.SaveAs("fontAndSize.xlsx");
Excel Font section showing Times New Roman size 15 selected with Bold, Italic, Underline buttons and cell displaying formatted text

What Advanced Font Options Are Available?

Beyond basic font options, you can further customize font appearance in Excel. This includes setting the font to Italic, applying Strikeout, using FontScript for superscripts and subscripts, and choosing specific font colors. The example below demonstrates how to use these additional options to create personalized font styles for your cells.

These advanced formatting options are particularly useful when working with complex Excel reports that require professional presentation. You can combine multiple font properties to create distinctive headers, highlight important data, or format scientific notations appropriately.

using IronXL;
using IronXL.Styles;

WorkBook workBook = WorkBook.Create();
WorkSheet workSheet = workBook.DefaultWorkSheet;

workSheet["B2"].StringValue = "Advanced";

// Set font family
workSheet["B2"].Style.Font.Name = "Lucida Handwriting";

// Set font script
workSheet["B2"].Style.Font.FontScript = FontScript.None;

// Set underline
workSheet["B2"].Style.Font.Underline = FontUnderlineType.Double;

// Set bold property
workSheet["B2"].Style.Font.Bold = true;

// Set italic property
workSheet["B2"].Style.Font.Italic = false;

// Set strikeout property
workSheet["B2"].Style.Font.Strikeout = false;

// Set font color
workSheet["B2"].Style.Font.Color = "#00FFFF";

workBook.SaveAs("fontAndSizeAdvanced.xlsx");
Excel font formatting menu showing Lucida Handwriting font selection and Double Underline option highlighted

Which Underline Types Should I Use?

Excel offers different underline types for text formatting. The Accounting underline features additional spacing between characters and lines compared to the normal underline. For text entries, the underline extends beyond the value both front and back. For numeric data formats, the underline stays within the value. When a cell contains both numbers and other characters, the Accounting underline behaves like text formatting.

When creating financial reports, the accounting underline style is valuable for emphasizing totals and subtotals in a professional manner that follows standard accounting practices.

Excel cells showing underline formatting options: none, single, double, single accounting, and double accounting

When Should I Use Font Script?

Font script in IronXL offers three options: none, super, and sub.

  • none: The default option, setting font on the baseline for regular text appearance.
  • super: Positions text characters above the baseline for exponents or footnotes.
  • sub: Positions text characters below the baseline for chemical formulas and math notations.

These script options are essential when working with scientific data or mathematical formulas in Excel spreadsheets. For example, use superscript for power notation (x²) or subscript for chemical formulas (H₂O).

Spreadsheet showing font script options: None, Super, and Sub in column B rows 2-4

How Do I Set Font Color?

You can set font color using either the Color property or the SetColor method. The SetColor method accepts input as Color or a Hex color code. This flexibility allows you to match brand colors precisely or apply conditional formatting based on data values.

using IronXL;
using IronSoftware.Drawing;

WorkBook workBook = WorkBook.Create();
WorkSheet workSheet = workBook.DefaultWorkSheet;

// Set Color property
workSheet["B2"].Style.Font.Color = "#00FFFF";

// Use Hex color code
workSheet["B2"].Style.Font.SetColor("#00FFFF");

// Use IronSoftware.Drawing
workSheet["B2"].Style.Font.SetColor(Color.Red);

Practical Example: Creating a Styled Header Row

Here's a comprehensive example that combines multiple font properties to create a professional-looking header row for a data table. This demonstrates how to apply consistent formatting across multiple cells while managing worksheets effectively:

using IronXL;
using IronXL.Styles;
using IronSoftware.Drawing;

// Create workbook and worksheet
WorkBook workBook = WorkBook.Create();
WorkSheet workSheet = workBook.DefaultWorkSheet;

// Define header titles
string[] headers = { "Product ID", "Product Name", "Price", "Stock", "Category" };

// Apply consistent header formatting
for (int i = 0; i < headers.Length; i++)
{
    var cell = workSheet[1, i + 1];
    cell.StringValue = headers[i];
    
    // Apply header styling
    cell.Style.Font.Name = "Arial";
    cell.Style.Font.Height = 12;
    cell.Style.Font.Bold = true;
    cell.Style.Font.Color = "#FFFFFF";
    
    // Add background color for headers
    cell.Style.SetBackgroundColor(Color.DarkBlue);
}

// Add sample data with different font styles
workSheet["A2"].Value = "PROD001";
workSheet["B2"].Value = "Premium Widget";
workSheet["C2"].Value = 29.99;
workSheet["C2"].Style.Font.Color = "#008000"; // Green for positive values

workSheet["D2"].Value = 15;
workSheet["E2"].Value = "Electronics";

// Save the styled workbook
workBook.SaveAs("styledProducts.xlsx");

This example showcases how IronXL's font styling capabilities integrate seamlessly with other formatting features like background colors and patterns, enabling you to create visually appealing and professional Excel documents programmatically.

Frequently Asked Questions

How can I set the font size in an Excel cell using IronXL?

To set the font size in an Excel cell using IronXL, you can use the `Height` property of the `Font` object associated with the cell's style. For example: `workSheet["A1"].Style.Font.Height = 18;` sets the font height to 18.

What font properties can be customized with IronXL?

IronXL allows you to customize various font properties such as name, size, color, bold, italic, underline, strikeout, and script positioning without Microsoft Office interop.

Is it possible to apply underline styles to text in Excel with IronXL?

Yes, IronXL supports different underline styles for text formatting, including single and double underlines, as well as accounting underlines for financial reports.

Can I set the font color in IronXL? If so, how?

You can set the font color in IronXL using either the `Color` property or the `SetColor` method. Both allow specifying colors with Hex codes or predefined color names, such as `workSheet["B2"].Style.Font.SetColor("#00FFFF");`.

How do I create bold text in an Excel cell using IronXL?

To make text bold in an Excel cell using IronXL, set the `Bold` property of the `Font` object to `true`. For example: `workSheet["B2"].Style.Font.Bold = true;`.

What is the function of FontScript in IronXL?

FontScript in IronXL is used to set the text position to normal, superscript, or subscript with options `none`, `super`, and `sub`, which are essential for scientific notation and formatting chemical formulas.

How can I change the font type in Excel files using IronXL?

You can change the font type in Excel files by setting the `Name` property of the `Font` object. For example: `workSheet["B2"].Style.Font.Name = "Times New Roman";` to set the font to Times New Roman.

Is it possible to perform font customization in Excel without Microsoft Office using C#?

Yes, IronXL allows you to perform comprehensive font customization in Excel from C# applications without needing Microsoft Office interop, providing methods to adjust font style, size, weight, and more.

What are the benefits of customizing fonts in Excel using IronXL?

Customizing fonts in Excel using IronXL benefits document formatting by improving readability, emphasizing critical information, and creating visually appealing and professional documents programmatically.

How can I make use of advanced font options like Italic or Strikeout in IronXL?

Advanced font options such as Italic or Strikeout can be implemented by setting properties like `Italic` and `Strikeout` in IronXL. For instance, `workSheet["B2"].Style.Font.Italic = true;` sets the font to italic.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 2,237,574Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronXL.Excel
nuget.org/packages/IronXL.Excel/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronXL"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronXL to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronXL.dll"

Licenses from $999

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.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required