[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Collapse]Spreadsheet
    Product Structure
   [Expand]Getting Started
   [Expand]Spreadsheet Document
    Supported Formats
   [Expand]Cell Basics
   [Expand]Formulas
    Defined Names
    Data Binding
    Data Validation
   [Expand]Data Presentation
   [Expand]Pivot Table Overview
   [Expand]Charts and Graphics
    Printing
    Events
    Protection
    Operation Restrictions
    Find and Replace
   [Expand]Mail Merge
   [Expand]Visual Elements
    Services
    Themes and Templates
   [Expand]Shortcuts
   [Collapse]Examples
    [Expand]Files
    [Expand]Workbooks
    [Expand]Worksheet
    [Expand]Rows and Columns
    [Expand]Cells
    [Expand]Formulas
    [Expand]Data Binding
    [Expand]Formatting Cells
    [Expand]Conditional Formatting
    [Expand]Group Data
    [Expand]Filter Data
    [Expand]Tables
    [Expand]Pivot Tables
    [Collapse]Printing
      How to: Print a Workbook
      How to: Specify Print Settings
      How to: Show a Print Preview Form for a Document
      How to: Add Headers and Footers to a Worksheet Printout
      How to: Define a Print Area
      How to: Insert Page Breaks in a Worksheet
      How to: Print Titles on a Worksheet
    [Expand]Pictures
    [Expand]Shapes
    [Expand]Charts
    [Expand]Sparklines
    [Expand]Protection
    [Expand]Mail Merge
    [Expand]Cell Templates
    [Expand]Commands
    [Expand]Customization
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Add Headers and Footers to a Worksheet Printout

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

Properties

Description

WorksheetHeaderFooterOptions.FirstHeader,

WorksheetHeaderFooterOptions.FirstFooter

Specify the header and footer for the first page.

WorksheetHeaderFooterOptions.OddHeader,

WorksheetHeaderFooterOptions.OddFooter

Specify the header and footer for odd pages.

WorksheetHeaderFooterOptions.EvenHeader,

WorksheetHeaderFooterOptions.EvenFooter

Specify the header and footer for even pages.

Expanded Header and Footer Options

Property Description
WorksheetHeaderFooterOptions.DifferentOddEven Gets or sets whether odd and even pages have different headers and footers.
WorksheetHeaderFooterOptions.DifferentFirst Gets or sets whether the first page has a unique header and footer.
WorksheetHeaderFooterOptions.ScaleWithDoc Gets or sets whether headers and footers should resize when you scale the worksheet.
WorksheetHeaderFooterOptions.AlignWithMargins Gets or sets whether to align the header and footer margins with the left and right page margins.

Expanded Header and Footer Codes

The Spreadsheet supports special codes you can use to add dynamic data to a header or footer. These codes are also available as constant fields and static methods of the HeaderFooterCode class.

Code

HeaderFooterCode Member

Description

&L

HeaderFooterCode.LeftSection

Aligns text to the left.

&C

HeaderFooterCode.CenterSection

Aligns text to the center.

&R

HeaderFooterCode.RightSection

Aligns text to the right.

&P

HeaderFooterCode.PageNumber

Inserts the current page number.

&P+number

HeaderFooterCode.CustomPageNumber

Inserts the current page number plus the specified number.

&P-number

HeaderFooterCode.CustomPageNumber

Inserts the current page number minus the specified number.

&N

HeaderFooterCode.PageTotal

Inserts the total number of pages in a workbook.

&N+number

HeaderFooterCode.CustomPageTotal

Inserts the total number of pages plus the specified number.

&N-number

HeaderFooterCode.CustomPageTotal

Inserts the total number of pages minus the specified number.

&D

HeaderFooterCode.Date

Inserts the current date.

&T

HeaderFooterCode.Time

Inserts the current time.

&Z

HeaderFooterCode.WorkbookFilePath

Inserts the path to the document.

&F

HeaderFooterCode.WorkbookFileName

Inserts the document's name.

&A

HeaderFooterCode.WorksheetName

Inserts the current worksheet's name.

&G

HeaderFooterCode.Picture

Inserts an image.

&&

HeaderFooterCode.Ampersand

Inserts an ampersand.

Note

The WPF Spreadsheet control does not support format settings for the header and footer text.

Expanded Example

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

The image below shows the result.

Expanded See Also

Is this topic helpful?​​​​​​​