Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

ASP.NET Sample for IList Report

Christoph Wille edited this page Apr 7, 2014 · 3 revisions

Overview

This sample shows how generate a report from a collection of objects. A PDF document is generated on the fly and sent to the client as response.

  • Technologies: ASP.NET
  • Data source: IList
  • Programming language: C#
  • Features: PDF Export
  • Location: samples\Web\IListReport

Code Discussion

The report generation is triggered by a client-side button click. The CreateTestList method has been omitted.

protected void Button1_Click(object sender, EventArgs e)
{
    contributors = CreateTestList();

    // instance reporting engine
    // assign parameters

    ReportEngine engine = new ReportEngine();

    string reportPath = Server.MapPath("ContributorList.srd");

    ReportModel reportModel = ReportEngine.LoadReportModel(reportPath);

    PageBuilder pageBuilder = engine.CreatePageBuilder(reportModel, contributors);
    pageBuilder.BuildExportList();
    string outputPath = Server.MapPath("ContributorList.pdf");

    // render report
    PdfRenderer pdfRenderer =
        PdfRenderer.CreateInstance(pageBuilder.Pages, outputPath, false);
    pdfRenderer.Start();
    pdfRenderer.RenderOutput();
    pdfRenderer.End();

    // send report to the client
    Response.ContentType = "Application/pdf";
    Response.WriteFile(outputPath);
    Response.End();
}

Screenshots

None applicable.

Setup

No database setup necessary, only ASP.NET with IIS or ASP.NET Development Server required.

SharpDevelop Reports

Clone this wiki locally