Articles in this section
Category / Section

How to set font style of excel header and footer using Syncfusion XlsIO?

4 mins read

Syncfusion XIsIO is a .NET Excel libray that allows you to create, read, and edit Microsoft Excel files in any .NET application. This article explains how to set font style to a page header using Syncfusion XlsIO and convert the document to PDF.

C#   

using (ExcelEngine excelEngine = new ExcelEngine())
{
    //Get the application.
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Xlsx;
 
    //Create the workbook.
    IWorkbook workbook = application.Workbooks.Create(1);
 
    //Get the first worksheet.
    IWorksheet worksheet = workbook.Worksheets[0];
 
    //Create some Wingdings circles in the left page header.
    worksheet.PageSetup.LeftHeader = @"Header: &""Wingdings,Regular""lllll";
 
    //Create some Wingdings circles the first row.
    worksheet["A1"].Text = "Cell:";
    worksheet["B1"].Text = "lllll";
    worksheet["B1"].CellStyle.Font.FontName = "Wingdings";
 
    //Set the remaining headers and footers as well.
    worksheet.PageSetup.CenterHeader = "&Z";
    worksheet.PageSetup.RightHeader = "&N";
    worksheet.PageSetup.LeftFooter = "&F";
    worksheet.PageSetup.CenterFooter = "&P";
    worksheet.PageSetup.RightFooter = "&A";
 
    //Save the Excel document.
    workbook.SaveAs("../../Output/Output.xlsx");
}
using (ExcelToPdfConverter converter = new ExcelToPdfConverter("../../Output/Output.xlsx"))
{
    ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings()
    {
        EmbedFonts = true
    };
 
    PdfDocument pdf = converter.Convert(settings);
    pdf.Save("../../Output/ExcelToPDF.pdf");
}

 

A complete working sample can be downloaded from SetFontInHeader.zip.

Please find the output screenshot below.

Font style for header and footer

Font style for header and footer

Take a moment to peruse the documentation, where you can find basic worksheet data manipulation options along with features like Conditional Formatting, worksheet calculations through Formulas, adding Charts in worksheet or workbook, organizing and analyzing data through Tables and Pivot Tables, appending multiple records to worksheet using Template Markers, and most importantly PDF and Image conversions etc. with code examples.

Click here to explore the rich set of Syncfusion Excel (XlsIO) library features.

Note:

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer the link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.


Conclusion

I hope you enjoyed learning about how to highlight a text by using how to highlight a text by using Essential PDF.

You can refer to our .NET Excel library page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our .NET Excel library example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or  feedbackportal. We are always happy to assist you!


 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied