Reports for WinForms | ComponentOne
In This Topic
    Exporting the Report
    In This Topic

    Exporting the report to common file formats

    C1Report has a RenderToFile method that allows you to export your report to several file formats, including HTML, RTF, PDF, PDF/A (level 2B), TIFF, Text, and XLS. For example, the following code creates PDF and XLS versions of a report:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    ' Load report definition
    c1r.Load(reportFile, reportName)
     
    ' Export to PDF and Excel
    c1r.RenderToFile(outFile + ".pdf", FileFormatEnum.PDF)
    c1r.RenderToFile(outFile + ".pdf", FileFormatEnum.PDFA)
    c1r.RenderToFile(outFile + ".xls", FileFormatEnum.Excel)
    

    To write code in C#

    C#
    Copy Code
    // Load report definition
    c1r.Load(reportFile, reportName);
     
    // Export to PDF and Excel
    c1r.RenderToFile(outFile + ".pdf", FileFormatEnum.PDF);
    c1r.RenderToFile(outFile + ".pdf", FileFormatEnum.PDFA);
    c1r.RenderToFile(outFile + ".xls", FileFormatEnum.Excel);
    
    Note: When a document is exported to the RTF or the DOCX formats with the "preserve pagination" option selected, text is placed in text boxes and the ability to reflow text in the resulting document may be limited.

    Exporting the report to custom formats

    If you want to export the report to a format that is not supported by C1Report, you can write your own export filter class and use the C1Report.RenderToFilter method to render the report into your custom filter.

    Custom filters are classes that derive from the C1.Win.C1Report.ExportFilter class and override a few simple methods like StartReport, StartSection, RenderField, EndSection, and EndReport.

    Writing a custom export filter is not difficult. It can be used, for example, to create custom XML representations of your reports for later processing by other applications.