In Spread.Services, you can use the LeftHeader property, LeftFooter property, CenterFooter property, RightHeader property, CenterHeader property, and the RightFooter property of the IPageSetup interface in order to configure header and footer for a page.
C# |
Copy Code |
---|---|
//Configure PageHeader and PageFooter //Set header for the page worksheet.PageSetup.LeftHeader = "&\"Arial,Italic\"LeftHeader"; worksheet.PageSetup.CenterHeader = "&P"; //Set footer graphic for the page worksheet.PageSetup.CenterFooter = "&G"; worksheet.PageSetup.CenterFooterPicture.Filename = @"Resource\logo.png"; |
For special settings, you can also perform the following tasks in order to customize the configuration of the header and footer of your page:
If you want a different header and footer in your first page, you first need to set the DifferentFirstPageHeaderFooter property of the IPageSetup interface to true. When this is done, you can use the properties of the IPageSetup interface in order to configure the first page header and footer.
C# |
Copy Code |
---|---|
//Set first page header and footer worksheet.PageSetup.DifferentFirstPageHeaderFooter = true; worksheet.PageSetup.FirstPage.CenterHeader.Text = "&T"; worksheet.PageSetup.FirstPage.RightFooter.Text = "&D"; //Set first page header and footer graphic worksheet.PageSetup.FirstPage.LeftFooter.Text = "&G"; worksheet.PageSetup.FirstPage.LeftFooter.Picture.Filename = @"Resource\logo.png"; |
If you want a different header and footer for all the even pages, you first need to set the OddAndEvenPagesHeaderFooter property to true. When this is done, you can use the properties of the IPageSetup interface in order to configure the even page header and footer.
C# |
Copy Code |
---|---|
//Set even page header and footer worksheet.PageSetup.OddAndEvenPagesHeaderFooter = true; worksheet.PageSetup.EvenPage.CenterHeader.Text = "&T"; worksheet.PageSetup.EvenPage.RightFooter.Text = "&D"; //Set even page header and footer graphic worksheet.PageSetup.EvenPage.LeftFooter.Text = "&G"; worksheet.PageSetup.EvenPage.LeftFooter.Picture.Filename = @"Resource\logo.png"; |