Changing the Default Font

Topic Overview


This topic describes how to change the default font of a worksheet when exporting to Microsoft Excel®.

In this topic

This topic contains the following sections:


There is a special type of style in Infragistics Excel workbook named Normal style, which can be accessed by Workbook.Styles NormalStyle property. This style contains the default properties for all cells in the workbook, unless otherwise specified on a row, column, or cell. Changing properties of the Normal style will change the default cell format properties in the workbook.

Code Example: Change Default Font


You can change the default font by setting the Workbook.Styles.NormalStyles.StyleFormat Font property or some of its properties to the desired values.

The code example below creates a new Workbook and adds one sheet to the workbook. It creates a new Font , which will be the default style for the workbook. Font family is changed to Times New Roman and font size is changed to 16 pt. Finally, the workbook is saved.


The following screenshot is a preview of the final result.

Change Default Font 1.png

As you can see, the default Font family is Times New Roman and the default Font size is 16 pt.


In Visual Basic:

' Create new workbook and add worksheet
Dim workbook As New Infragistics.Documents.Excel.Workbook(Infragistics.Documents.Excel.WorkbookFormat.Excel2007)
Dim worksheet As Infragistics.Documents.Excel.Worksheet = workbook.Worksheets.Add("Sheet1")
Dim normalFont As Infragistics.Documents.Excel.IWorkbookFont = workbook.Styles.NormalStyle.StyleFormat.Font
' Specifying the name of default font
normalFont.Name = "Times New Roman"
' Specifying the font size. Font size height is measured in twips. One twips is 1/20th of a point
normalFont.Height = 16 * 20
Dim saveFileDialog As New SaveFileDialog() With { _
    .Filter = "Excel 2007 files|*.xlsx", _
    .DefaultExt = "xlsx" _
If saveFileDialog.ShowDialog() = True Then
    Dim stream As Stream = saveFileDialog.OpenFile()
End If

In C#:

// Create new workbook and add worksheet
Infragistics.Documents.Excel.Workbook workbook = new Infragistics.Documents.Excel.Workbook(Infragistics.Documents.Excel.WorkbookFormat.Excel2007);
Infragistics.Documents.Excel.Worksheet worksheet = workbook.Worksheets.Add("Sheet1");
Infragistics.Documents.Excel.IWorkbookFont normalFont = workbook.Styles.NormalStyle.StyleFormat.Font;
// Specifying the name of default font
normalFont.Name = "Times New Roman";
// Specifying the font size. Font size height is measured in twips. One twips is 1/20th of a point
normalFont.Height = 16 * 20;

Related Topics

The following topics provide additional information related to this topic.

Topic Purpose

The Infragistics Excel Engine allows you to customize the look and behavior of a cell.

This section is your gateway to important task-based information that will help you to effectively use the various features and functionalities provided by the Infragistics Excel Engine.