Export to Excel from Crystal Reports without page headers / footers

It's just interesting if anyone has an example of working code (in C #) for exporting a crystal report to Excel from a .NET application without report page headers and footer.

I am using Crystal Reports v9 reports.

+7
c # crystal-reports
source share
2 answers

To do this, you really need to do this in Crystal Report. My recommendation is to add a parameter to it, and then edit the header and footer suppression formulas to test the parameter. So we have achieved this. If there is a way to do this from your code, I would be interested to know it as well.

Good luck

+1
source share

Here's my extension method for ReportDocument suppresses all headers and footers. I use it to export Excel.

/// <summary> /// Clears header/footer. /// </summary> /// <param name="rpt">The reportdocument</param> public static void ClearReportHeaderAndFooter(this ReportDocument rpt) { foreach (Section section in rpt.ReportDefinition.Sections) { if (section.Kind == AreaSectionKind.ReportHeader || section.Kind == AreaSectionKind.ReportFooter || section.Kind == AreaSectionKind.PageFooter || section.Kind == AreaSectionKind.PageHeader) { section.SectionFormat.EnableSuppress = true; section.SectionFormat.BackgroundColor = Color.White; foreach (var repO in section.ReportObjects) { if (repO is ReportObject) { var reportObject = repO as ReportObject; reportObject.ObjectFormat.EnableSuppress = true; reportObject.Border.BorderColor = Color.White; } } } } } 

Use it as follows:

 myReportDocument.ClearReportHeaderAndFooter(); 
+1
source share

All Articles