Getting Headers or Footers

How to Get Headers and Footers in MS Excel

  1. Click the worksheet where you want to view or change headers or footers.
  2. On the View tab, in the Workbook Views group, click Page Layout.
    Excel displays the worksheet in Page Layout view.
  3. To view or edit a header or footer, click the left, center, or right header or footer text box at the top or the bottom of the worksheet page (under Header or above Footer).

How to Get Headers and Footers using Aspose.Cells for Python Excel Library

With Worksheet.page_setup.get_header and Worksheet.page_setup.get_footer methods, .NET developers can simply retrieve headers or footers from a workbook.

  1. Construct a Workbook to open the file.
  2. Get the worksheet from which you want to retrieve the header or footer.
  3. Get the header or footer using a specific section ID.

How to Parse Headers and Footers to Command List

The header or footer text can contain special commands, for example a placeholder for the page number, current date, or text‑formatting attributes.

Special commands are represented by a single letter with a leading ampersand ("&").

The header and footer strings are constructed using ABNF grammar. It’s not easy to understand without a viewer.

Aspose.Cells for Python via .NET provides the Worksheet.page_setup.get_commands method to parse headers and footers into a command list.

The following code shows how to parse the header or footer into a command list and process the commands: