Back to Devexpress

Worksheet.HeaderFooterOptions Property

officefileapi-devexpress-dot-spreadsheet-dot-worksheet-796f9b69.md

latest4.6 KB
Original Source

Worksheet.HeaderFooterOptions Property

Provides access to header and footer options for a worksheet.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
WorksheetHeaderFooterOptions HeaderFooterOptions { get; }
vb
ReadOnly Property HeaderFooterOptions As WorksheetHeaderFooterOptions

Property Value

TypeDescription
WorksheetHeaderFooterOptions

An object that contains header and footer options.

|

Remarks

Use the Worksheet.HeaderFooterOptions property to add headers and footers to printed pages.

PropertyDescription
WorksheetHeaderFooterOptions.DifferentOddEvenSpecifies whether odd and even pages have different headers and footers.
WorksheetHeaderFooterOptions.OddHeader
WorksheetHeaderFooterOptions.OddFooterDefine headers and footers for odd pages.
WorksheetHeaderFooterOptions.EvenHeader
WorksheetHeaderFooterOptions.EvenFooterDefine headers and footers for even pages.
WorksheetHeaderFooterOptions.DifferentFirstSpecifies whether the first page has a unique header and footer.
WorksheetHeaderFooterOptions.FirstHeader
WorksheetHeaderFooterOptions.FirstFooterDefine a header and footer for the first page.
WorksheetHeaderFooterOptions.ScaleWithDocSpecifies whether headers and footers should resize when you scale a worksheet.
WorksheetHeaderFooterOptions.AlignWithMarginsSpecifies whether to align header and footer margins with the left and right page margins.

The following example shows how to specify the header and footer for the first page.

csharp
WorksheetHeaderFooterOptions options = worksheet.HeaderFooterOptions;

// Specify that the first page has a unique header and footer.
options.DifferentFirst = true;

// Insert the rich formatted text into the header's left section.
options.FirstHeader.Left = string.Format("{0}&BDev{1}AV",
   HeaderFooterCode.FontColor(4, -50), HeaderFooterCode.FontColor(4,10));

// Insert the sheet name into the header's right section.
options.FirstHeader.Right = "&A";

// Insert the current date into the footer's left section.
options.FirstFooter.Left = "&D";

// Insert the current page number into the footer's right section.
options.FirstFooter.Right = string.Format("Page {0} of {1}", "&P", "&N");
vb
Dim options As WorksheetHeaderFooterOptions = worksheet.HeaderFooterOptions

' Specify that the first page has a unique header and footer. 
options.DifferentFirst = True

' Insert the rich formatted text into the header's left section.
options.FirstHeader.Left = String.Format("{0}&BDev{1}AV",
   HeaderFooterCode.FontColor(4, -50), HeaderFooterCode.FontColor(4,10))

' Insert the sheet name into the header's right section.
options.FirstHeader.Right = "&A"

' Insert the current date into the footer's left section.
options.FirstFooter.Left = "&D"

' Insert the current page number into the footer's right section.
options.FirstFooter.Right = String.Format("Page {0} of {1}", "&P", "&N")

See Also

Worksheet Interface

Worksheet Members

DevExpress.Spreadsheet Namespace