This KB illustrates that how to set header and footer in the PDF/Excel/Word exported page. SolutionYou can set the header and footer in PDF, Excel, and Word exported documents by using the following events:
In the ExportPDF event, properties are written under the PDFExportSettings class. To display header and footer in the exported document, the properties ShowPDFHeader and ShowPDFFooter should be set to true. The header and footer text can be set by using the PDFHeaderText and PDFFooterText properties, respectively. In addition to this, PDFHeaderDescription property helps you to set the description of the header.
In the ExportExcel event, properties are written under the PageSetup class. The properties, CenterHeader and CenterFooter allow you to set the header and footer in the middle of a page. Likewise, the properties, LeftHeader, LeftFooter, RightHeader, and RightFooter allow the user to set the header and footer in the left or right side of a page.
Note: Header and footer are not displayed in an Excel sheet, by default. You can enable the header and footer under the Insert tab to show them page wise and also while printing.
In the ExportWord event, properties are written under the WordExportSettings class. To display header and footer in the exported document, the properties ShowHeader and ShowFooter should be set to true. The header and footer text can be set by using the HeaderText and FooterText properties, respectively.
The following code example illustrates how to add header and footer in the PDF, Excel, and Word exported document. C#protected void Page_Load(object sender, EventArgs e) { this.OlapClient1.OlapGrid.ExportPDF += OlapGrid_ExportPDF; this.OlapClient1.OlapGrid.ExportExcel += OlapGrid_ExportExcel; this.OlapClient1.OlapGrid.ExportWord += OlapGrid_ExportWord; } public void OlapGrid_ExportPDF(object sender, ExportPDFEventArgs e) { e.PDFExportSettings.PDFHeaderText = "Header"; e.PDFExportSettings.PDFFooterText = "Footer"; e.PDFExportSettings.PDFHeaderDescription = ""; e.PDFExportSettings.ShowPDFFooter = true; e.PDFExportSettings.ShowPDFHeader = true; } private void OlapGrid_ExportExcel(object sender, ExportExcelEventArgs e) { e.PageSetup.CenterHeader = "Center Header"; e.PageSetup.CenterFooter = "Center Footer"; e.PageSetup.LeftFooter = "Left Footer"; e.PageSetup.LeftHeader = "Left Header"; e.PageSetup.RightFooter = "Right Footer"; e.PageSetup.RightHeader = "Right Header"; } public void OlapGrid_ExportWord(object sender, ExportWordEventArgs e) { e.WordExportSettings.FooterText = "Footer"; e.WordExportSettings.HeaderText = "Header"; e.WordExportSettings.ShowHeader = true; e.WordExportSettings.ShowFooter = true; }
VBProtected Sub Page_Load(sender As Object, e As EventArgs) AddHandler Me.OlapClient1.OlapGrid.ExportPDF, AddressOf OlapGrid_ExportPDF AddHandler Me.OlapClient1.OlapGrid.ExportExcel, AddressOf OlapGrid_ExportExcel AddHandler Me.OlapClient1.OlapGrid.ExportWord, AddressOf OlapGrid_ExportWord End Sub Public Sub OlapGrid_ExportPDF(sender As Object, e As ExportPDFEventArgs) e.PDFExportSettings.PDFHeaderText = "Header" e.PDFExportSettings.PDFFooterText = "Footer" e.PDFExportSettings.PDFHeaderDescription = "" e.PDFExportSettings.ShowPDFFooter = True e.PDFExportSettings.ShowPDFHeader = True End Sub Private Sub OlapGrid_ExportExcel(sender As Object, e As ExportExcelEventArgs) e.PageSetup.CenterHeader = "Center Header" e.PageSetup.CenterFooter = "Center Footer" e.PageSetup.LeftFooter = "Left Footer" e.PageSetup.LeftHeader = "Left Header" e.PageSetup.RightFooter = "Right Footer" e.PageSetup.RightHeader = "Right Header" End Sub Public Sub OlapGrid_ExportWord(sender As Object, e As ExportWordEventArgs) e.WordExportSettings.FooterText = "Footer" e.WordExportSettings.HeaderText = "Header" e.WordExportSettings.ShowHeader = True e.WordExportSettings.ShowFooter = True End Sub
|
This page will automatically be redirected to the sign-in page in 10 seconds.