Enum HeaderFooterCommandType

HeaderFooterCommandType enumeration

Represents the command type of header and footer.

public enum HeaderFooterCommandType

Values

NameValueDescription
Text0The text.
CurrentPage1Current page number
Pagecount2Page count
CurrentDate3Current date
CurrentTime4Current time
SheetName5Sheet name
FileName6File name without path
FilePath7File path without file name
Picture8Picture

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using System;

    public class HeaderFooterCommandTypeDemo
    {
        public static void HeaderFooterCommandTypeExample()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            // Access the header/footer of the worksheet
            PageSetup pageSetup = worksheet.PageSetup;

            // Set the header with different HeaderFooterCommandType values
            pageSetup.SetHeader(0, "&T"); // Text
            pageSetup.SetHeader(1, "&P"); // Current page number
            pageSetup.SetHeader(2, "&N"); // Page count
            pageSetup.SetHeader(0, "&D"); // Current date
            pageSetup.SetHeader(1, "&T"); // Current time
            pageSetup.SetHeader(2, "&A"); // Sheet name
            pageSetup.SetHeader(0, "&F"); // File name without path
            pageSetup.SetHeader(1, "&Z"); // File path without file name
            pageSetup.SetHeader(2, "&G"); // Picture

            // Save the workbook
            workbook.Save("HeaderFooterCommandTypeExample.xlsx");
            workbook.Save("HeaderFooterCommandTypeExample.pdf");
            return;
        }
    }
}

See Also