Skip to main content
A newer version of this page is available. .

IXlSheet.HeaderFooter Property

Provides access to options which determine the worksheet header and footer characteristics.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v19.2.Core.dll

Declaration

XlHeaderFooter HeaderFooter { get; }

Property Value

Type Description
XlHeaderFooter

An XlHeaderFooter object containing options specific to headers and footers.

Remarks

Use the HeaderFooter property to get access to the XlHeaderFooter object, which allows you to define the header and footer for the first page (XlHeaderFooter.FirstHeader and XlHeaderFooter.FirstFooter), odd-numbered pages (XlHeaderFooter.OddHeader and XlHeaderFooter.OddFooter) and even-numbered pages (XlHeaderFooter.EvenHeader and XlHeaderFooter.EvenFooter) of a printed worksheet. For details on how to insert headers and footers at the top and bottom of a printout, refer to the How to: Add Headers and Footers to a Worksheet Printout example.

Example

The example below demonstrates how to specify different headers and footers for the odd-numbered and even-numbered pages of the printed worksheet.

Note

A complete sample project is available at https://github.com/DevExpress-Examples/xl-export-api-examples-t253492

// Specify different headers and footers for the odd-numbered and even-numbered pages.
sheet.HeaderFooter.DifferentOddEven = true;
// Add the bold text to the header left section, 
// and insert the workbook name into the header right section.
sheet.HeaderFooter.OddHeader = XlHeaderFooter.FromLCR(XlHeaderFooter.Bold + "Sample report", null, XlHeaderFooter.BookName);
// Insert the current page number into the footer right section. 
sheet.HeaderFooter.OddFooter = XlHeaderFooter.FromLCR(null, null, XlHeaderFooter.PageNumber);
// Insert the workbook file path into the header left section, 
// and add the worksheet name to the header right section. 
sheet.HeaderFooter.EvenHeader = XlHeaderFooter.FromLCR(XlHeaderFooter.BookPath, null, XlHeaderFooter.SheetName);
// Insert the current page number into the footer left section 
// and add the current date to the footer right section. 
sheet.HeaderFooter.EvenFooter = XlHeaderFooter.FromLCR(XlHeaderFooter.PageNumber, null, XlHeaderFooter.Date);
See Also