facebooktwittermenuarrow-up

GemBox Support Forum

Format HeaderFooters

Is there a way to change the font and size of the HeaderFooter section?

Hi Toon,

Try this:

var workbook = new ExcelFile();
var worksheet = workbook.Worksheets.Add("Sheet1");
worksheet.ViewOptions.ViewType = ViewType.PageLayout;

var header = worksheet.HeadersFooters.DefaultPage.Header;

// Append text with Arial 8pt to center section.
header.CenterSection.Append("Center header.", new ExcelFont() { Name = "Arial", Size = 8 * 20 });

header.LeftSection.Append("Left header.");

// Set Courier New 12pt on left section.
header.LeftSection.Content = "&\"Courier New\"&12" + header.LeftSection.Content;

workbook.Save("Output.xlsx");

I hope this helps.

Regards,
Mario

Awesome, that worked - thanks!