XlHeaderFooter Class

Represents the object that specifies headers and footers of a worksheet.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v21.1.Core.dll

Declaration

public class XlHeaderFooter

The following members accept/return XlHeaderFooter objects:

Remarks

An instance of the XlHeaderFooter class is accessible by using the IXlSheet.HeaderFooter property. The XlHeaderFooter object provides properties you can use to specify 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 more information on how to insert headers and footers at the top and bottom of a printed worksheet, 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.

// 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);

Inheritance

Object
XlHeaderFooter
See Also