Search code examples
crystal-reportsexport-to-excel

Crystal Report: export to excell generates "page break", column header is reapeated



Trying to export a report to excel, the generated document has kind of page break. The column header is repeated. The "page break" are in the same positition than if I generate a PDF report.
How can I remove this page break when exporting to excel? Is there some page size definition?


Solution

  • Have you tried ExportFormatType.ExcelRecord instead of ExportFormatType.Excel? The xls file will be created without formatting.


    If actually the user is exporting report using ReportViewer Toolbar Export button you can:

    • Replace the CrystalReportViewer Control with the ReportExporter Control. It will export the report in the format you choose.

    Or hide Export button from toolbar and put in the page buttons that exports programmatically

    CrystalReportSource1.ReportDocument.ExportToHttpResponse(ExportFormatType.ExcelRecord, this.Response , false, "report.xls");

    reportDocument.ExportToDisk(ExportFormatType.ExcelRecord, "report.xls");

    You can choose the way that best fits your needs, but you must try if it works with the runtime you use either in development or in release server.

    ExportFormatType.ExcelRecord means that is generated an xls file, without formatting. If you set ExportFormatType.Excel fields that are marked as "Can Grow" are merged with an otherwise blank row below them.