How to set the default font and font size in an Excel Workbook?

23 Jul 20253 minutes to read

You can programmatically set the default font and font size in an Excel workbook using the StandardFont and StandardFontSize properties of the IWorkbook interface. The following code examples demonstrate how to do this in C# (Cross-platform and Windows-specific) and VB.NET.

using (ExcelEngine excelEngine = new ExcelEngine())
{
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Xlsx;

    IWorkbook workbook = application.Workbooks.Create(1);
    IWorksheet sheet = workbook.Worksheets[0];

    //Set default font and font size
    workbook.StandardFont = "Calibri";
    workbook.StandardFontSize = 12;

    //Add some text
    sheet.Range["A1"].Text = "This is default font and size";

    //Save to file
    FileStream outputStream = new FileStream("Output/Output.xlsx", FileMode.Create, FileAccess.Write);
    workbook.SaveAs(outputStream);
    outputStream.Dispose();
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Xlsx;
    IWorkbook workbook = application.Workbooks.Create(1);
    IWorksheet sheet = workbook.Worksheets[0];

    //Set default font and font size
    workbook.StandardFont = "Calibri";
    workbook.StandardFontSize = 12;

    //Add some text
    sheet.Range["A1"].Text = "This is default font and size";

    //Save the workbook
    workbook.SaveAs("Output.xlsx");
}
Imports Syncfusion.XlsIO

Using excelEngine As New ExcelEngine()
    Dim application As IApplication = excelEngine.Excel
    Dim workbook As IWorkbook = application.Workbooks.Create(1)
    Dim sheet As IWorksheet = workbook.Worksheets(0)

    'Set default font and font size
    workbook.StandardFont = "Calibri"
    workbook.StandardFontSize = 12

    'Add some text
    sheet.Range("A1").Text = "This is default font and size"

    'Save the workbook
    workbook.SaveAs("Output.xlsx")
End Using

A complete working example to set the default font and font size in an Excel Workbook using C# is available on this GitHub page.