![Change Default Font 1.png](images/Change_Default_Font_1.png)
This topic describes how to change the default font of a worksheet when exporting to Microsoft Excel®.
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.
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.
As you can see, the default Font family is Times New Roman and the default Font size is 16 pt.
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;
workbook.Save(outputStream);
The following topics provide additional information related to this topic.