Quantcast
Channel: doddlereport Wiki & Documentation Rss Feed
Viewing all 28 articles
Browse latest View live

Updated Wiki: Documentation


Updated Wiki: Home

$
0
0

DoddleReport generates tabular reports from any IEnumerable datasource.

Out of the box it can render reports to Excel, PDF, HTML, and CSV – fully pluggable of course. I designed the project to provide reporting output over the LINQ queries we had already written for the application, but maybe you can find other uses for it.

Blog Updates

For updates and other topics please visit my blog at http://www.matthidinger.com or follow@matthidinger

New to DoddleReport?

Get it!

NuGet Packages

DoddleReport has been split into multiple packages to support more users’ needs. See their Descriptions within NuGet for more on the differences

  • Install-Package DoddleReport
  • Install-Package DoddleReport.Web
  • Install-Package DoddleReport.iTextSharp
  • Install-Package DoddleReport.AbcPdf
  • Install-Package DoddleReport.OpenXml
  • Install-Package DoddleReport.Dynamic

New in v1.2

  • NEW WRITER: A new OpenXML ExcelReportWriter found in the DoddleReport.OpenXml package, courtesy of Louis-Philippe Perras
  • NEW WRITER: A new iTextSharp PDF writer can be found in the DoddleReport.iTextSharp package, courtesy of Louis-Philippe Perras (thanks again!)
  • Breaking change: The root namespace changed from Doddle.Reporting to justDoddleReport
  • Breaking change: The Default Orientation for reports is now Portrait
  • All Web references moved to separate project to allow for .NET Client Profile support for WinForms/WPF
  • Added “myReport.RenderHints.BooleansAsYesNo = true” to write Yes/No on the reports for boolean fields
  • Added custom FileName support for web reporting as requested in Discussions
  • Added MVC Areas support by calling areaRegistrationContext.MapReportingRoute();
  • Various Bug fixes and enhancements as reported in the Discussion forum and Issue Tracker

So what does it generate?

The following samples are generated live in real-time (notice the data will change every time you open the report)

Excel Report (OpenXML)

  • Creates a native Excel file using OpenXML
  • Requires the DoddleReport.OpenXml package
  • See it live!

Excel Report (HTML)

  • Creates an Excel file using HTML (downside being an Excel security prompt when opening the report)
  • Automatic Sticky/Frozen Headers stay at the top when scrolling through the data
  • See it live!

doddlexlsreport 

doddlexlsreport

PDF Report (iTextSharp)

  • Automatically repeats title and column headers numbers on every page
  • Requires the DoddleReport.iTextSharp package
  • See it live!

PDF Report (ABCpdf)

  • Automatically repeats title, column headers, and page numbers on every page
  • Requires the DoddleReport.AbcPdf package
  • Requires an ABCpdf license
  • See it live!

image

doddlepdfreport

CSV/Delimited

HTML Report

doddleTxtReport

doddleHtmlReport

Basic Usage

// Get the data for the report (any IEnumerable will work)var query = ProductRepository.GetAll();var totalProducts = query.Count;var totalOrders = query.Sum(p => p.OrderCount);// Create the report and turn our query into a ReportSourcevar report = new Report(query.ToReportSource());// Customize the Text Fieldsreport.TextFields.Title = "Products Report";
report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works";
report.TextFields.Footer = "Copyright 2011 © The Doddle Project";
report.TextFields.Header = string.Format(@"
    Report Generated: {0}
    Total Products: {1}
    Total Orders: {2}
    Total Sales: {3:c}", DateTime.Now, totalProducts, totalOrders, totalProducts * totalOrders);// Render hints allow you to pass additional hints to the reports as they are being renderedreport.RenderHints.BooleanCheckboxes = true;// Customize the data fieldsreport.DataFields["Id"].Hidden = true;
report.DataFields["Price"].DataFormatString = "{0:c}";
report.DataFields["LastPurchase"].DataFormatString = "{0:d}";

New Comment on "Configuration"

$
0
0
The web.config version above is old when the root namespace was Doddle.Reporting. The root namespace has been updated and is now DoddleReport. Here is the updated web.config for version 1.2.2: <configSections> <section name="doddleReport" type="DoddleReport.Configuration.DoddleReportSection, DoddleReport"/> </configSections> <doddleReport defaultWriter="Html" dataRowStyle="DataRowStyle" headerRowStyle="HeaderRowStyle" footerRowStyle="FooterRowStyle"> <styles> <style name="DataRowStyle" /> <style name="HeaderRowStyle" bold="true" underline="true"/> <style name="FooterRowStyle" bold="true"/> <style name="Footer" italic="true"/> <style name="Title" fontSize="16"/> </styles> <writers> <clear/> <add format="Html" type="DoddleReport.Writers.HtmlReportWriter, DoddleReport" contentType="text/html;charset=UTF-8" fileExtension=".html"/> <add format="Text" type="DoddleReport.Writers.DelimitedTextReportWriter, DoddleReport" contentType="text/plain;charset=UTF-8" fileExtension=".txt" offerDownload="true"/> <add format="ExcelOpenXml" type="DoddleReport.OpenXml.ExcelReportWriter, DoddleReport.OpenXml" contentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" offerDownload="true" fileExtension=".xlsx"/> <add format="Excel" type="DoddleReport.Writers.ExcelReportWriter, DoddleReport" contentType="application/vnd.ms-excel" offerDownload="true" fileExtension=".xls"/> <add format="iTextSharpPdf" type="DoddleReport.iTextSharp.PdfReportWriter, DoddleReport.iTextSharp" contentType="application/pdf" offerDownload="false" fileExtension=".pdf" /> <add format="AbcPdf" type="DoddleReport.AbcPdf.PdfReportWriter, DoddleReport.AbcPdf" contentType="application/pdf" offerDownload="false" fileExtension=".pdf"/> </writers> </doddleReport>

Updated Wiki: Key Components

$
0
0

Key Components to DoddleReport

A Report relies on 2 distinct (and entirely extensible) mechanisms:

  • IReportSource - The Report must be supplied a collection of columns/rows using an IReportSource
  • IReportWriter - The Report needs to be written to a Stream using an IReportWriter

Report Sources

DoddleReport ships with all the Report Sources you should need, but even if it doesn't, you can write your own very easily by implementing a simple interface.

  • EnumerableReportSource - provides reporting for a variety of IEnumerable data types (including any .NET collection, LINQ queries, etc)
  • DataTableReportSource - provides reporting for any DataTable
  • SPListReportSource - provides reporting for any SharePoint List

Report Writers

The DoddleReport assembly ships with 3 types of Report Writers. The Extended report writers are included in stand-alone assemblies because they require additional libraries to function. You can write of course your own ReportWriters very easily by implementing a simple interface - and we would love if you could contribute them back to the project if so!

Default Report Writers

  • HtmlReportWriter - writes a basic HTML report
  • ExcelReportWriter - writes an Excel report using HTML internally. This will raise a confirmation prompt when the file is opened, telling the user that this is not a native Excel file.Use the OpenXML ExcelReportWriter described below if you want to avoid this.
  • DelimitedTextReportWriter– writes a delimited text file, the delimiter can be customized (the default is tab-delimited)

Extended Report Writers (provided via stand-alone assemblies)

PDF

  • DoddleReport.AbcPdf.PdfReportWriter - writes a PDF report using ABCpdf (NOTE: the implementation I have written relies onABCPdf, you will need to license AbcPdf or write another PDF writer if this won’t work. Alternatively they do provide a 30 day trial)
  • DoddleReport.iTextSharp.PdfReportWriter - writes a PDF report usingiTextSharp. iTextSharp is an open source product at source forge, please check licensing to make sure it compllies with your project.


OpenXML / Excel

this ExcelReportWriter uses OpenXML instead of the default ExcelReportWriter which uses HTML. This writer is also more robust than the default, but requires 2 additional assemblies to function (which will be included automatically if you use the NuGet install mechanism)

  • DoddleReport.OpenXml.ExcelReportWriter -

 

Updated Wiki: Key Components

$
0
0

Key Components to DoddleReport

A Report relies on 2 distinct (and entirely extensible) mechanisms:

  • IReportSource - The Report must be supplied a collection of columns/rows using an IReportSource
  • IReportWriter - The Report needs to be written to a Stream using an IReportWriter

Report Sources

DoddleReport ships with all the Report Sources you should need, but even if it doesn't, you can write your own very easily by implementing a simple interface.

  • EnumerableReportSource - provides reporting for a variety of IEnumerable data types (including any .NET collection, LINQ queries, etc)
  • DataTableReportSource - provides reporting for any DataTable
  • SPListReportSource - provides reporting for any SharePoint List

Report Writers

The DoddleReport assembly ships with 3 types of Report Writers. The Extended report writers are included in stand-alone assemblies because they require additional libraries to function. You can write of course your own ReportWriters very easily by implementing a simple interface - and we would love if you could contribute them back to the project if so!

Default Report Writers

  • HtmlReportWriter - writes a basic HTML report
  • ExcelReportWriter - writes an Excel report using HTML internally. This will raise a confirmation prompt when the file is opened, telling the user that this is not a native Excel file.Use the OpenXML ExcelReportWriter described below if you want to avoid this.
  • DelimitedTextReportWriter– writes a delimited text file, the delimiter can be customized (the default is tab-delimited)

Extended Report Writers (provided via stand-alone assemblies)

PDF

  • DoddleReport.AbcPdf.PdfReportWriter - writes a PDF report using ABCpdf (NOTE: the implementation I have written relies onABCPdf, you will need to license AbcPdf or write another PDF writer if this won’t work. Alternatively they do provide a 30 day trial)
  • DoddleReport.iTextSharp.PdfReportWriter - writes a PDF report usingiTextSharp. iTextSharp is an open source product at source forge, please check licensing to make sure it compllies with your project.


OpenXML / Excel

  • DoddleReport.OpenXml.ExcelReportWriter - this ExcelReportWriter uses OpenXML instead of the default ExcelReportWriter which uses HTML. This writer is also more robust than the default, but requires 2 additional assemblies to function (which will be included automatically if you use the NuGet install mechanism)

 

New Comment on "Web Reporting"

$
0
0
Hi, I have successfully used it with asp.net mvc3. there is a little hiccup when i try to do the same for the asp.net MVC Areas. how to handle .MapReportingRoute(); for MVC AreaRegisration file.. thanks

Updated Wiki: Web Reporting

$
0
0

Web Reporting

ASP.NET WebForms

The simplest way to add reporting to an ASP.NET application is to add a "Generic Handler (.ashx)" to your project. If you are unfamiliar with .ashx files, they are basic HTTP handlers like .aspx, but they do not have the overhead of building a Page object and a control heirarchy. They are for serving any kind of content over the web, including HTML, binary data like PDF, images, etc. They are accessed via URL just like a regular .aspx, and can be passed querystrings the same way.

WebReport will handle all serving of the report for you. It will determine what type of report to send based on the?ReportType querystring.

Configuration

Check out the Configuring DoddleReport documentation to map the ReportType parameter to specific Report Writers.


When you create your ashx you can replace all the code inside as follows, you just need to implement a few basic abstract members.

publicclass ProductsReport : WebReport
{publicoverridestring FileName
    {get { return"ProductsReport"; }
    }publicoverride IReportSource ReportSource
    {get
        {// LINQ queryvar query = from p in db.Productsselect p;return query.ToReportSource();
        }
    }publicoverridevoid CustomizeReport(Report report)
    {// Text Fields
        report.TextFields.Title = "Products Report";
        report.TextFields.Footer = "Copyright 2009 &copy; The Doddle Project";
        report.TextFields.Header = string.Format("Report Generated: {0}", DateTime.Now);// Data Fields
        report.DataFields["ProductID"].Hidden = true;
        report.DataFields["CategoryID"].Hidden = true;
        report.DataFields["SupplierID"].Hidden = true;
    }
}

ASP.NET MVC

And for my MVC friends I have provided a ReportResult to use as an Action Result that will serve up the report.

The ReportResult will actually read the extension of the request on the controller and return the correct type of report.

  • PDF - http://myserver.com/reports/ProductsReport.pdf
  • Excel - http://myserver.com/reports/ProductsReport.xls
  • HTML - http://myserver.com/reports/ProductsReport.html
  • Delimited - http://myserver.com/reports/ProductsReport.txt

Configuration

Check out the Configuring DoddleReport documentation to map the URL extension with a specific Report Writer.

IMPORTANT

Before using DoddleReport with ASP.NET MVC, you will probably want to register a Route that DoddleReport can use to dynamically load the requested report writer based on the URL extension. In order to do this simply go to where you define your routes (in Global.asax for many people) and add the following line:

routes.MapReportingRoute();

Next simply create your report like you normally would and return it inside an instance of ReportResult. DoddleReport will handle the rest.

public ReportResult ProductReport()
{// Get the data for the report (any IEnumerable will work)var query = ProductRepository.GetAll();var totalProducts = query.Count;var totalOrders = query.Sum(p => p.OrderCount);// Create the report and turn our query into a ReportSourcevar report = new Report(query.ToReportSource());// Customize the Text Fieldsreport.TextFields.Title = "Products Report";
    report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works";
    report.TextFields.Footer = "Copyright 2011 &copy; The Doddle Project";
    report.TextFields.Header = string.Format(@"
        Report Generated: {0}
        Total Products: {1}
        Total Orders: {2}
        Total Sales: {3:c}", DateTime.Now, totalProducts, totalOrders, totalProducts * totalOrders);// Render hints allow you to pass additional hints to the reports as they are being renderedreport.RenderHints.BooleanCheckboxes = true;// Customize the data fieldsreport.DataFields["Id"].Hidden = true;
    report.DataFields["Price"].DataFormatString = "{0:c}";
    report.DataFields["LastPurchase"].DataFormatString = "{0:d}";// Return the ReportResult
    // the type of report that is rendered will be determined by the extension in the URL (.pdf, .xls, .html, etc)return new ReportResult(report);
}

Updated Wiki: Web Reporting

$
0
0

Web Reporting

ASP.NET WebForms

The simplest way to add reporting to an ASP.NET application is to add a "Generic Handler (.ashx)" to your project. If you are unfamiliar with .ashx files, they are basic HTTP handlers like .aspx, but they do not have the overhead of building a Page object and a control heirarchy. They are for serving any kind of content over the web, including HTML, binary data like PDF, images, etc. They are accessed via URL just like a regular .aspx, and can be passed querystrings the same way.

WebReport will handle all serving of the report for you. It will determine what type of report to send based on the?ReportType querystring.

  • PDF: http://myserver.com/Reports/ProductsReport.ashx?ReportType=PDF
  • Excel: http://myserver.com/Reports/ProductsReport.ashx?ReportType=Excel

Configuration

Check out the Configuring DoddleReport documentation to map the ReportType parameter to specific Report Writers.


When you create your ashx you can replace all the code inside as follows, you just need to implement a few basic abstract members.

publicclass ProductsReport : WebReport
{publicoverridestring FileName
    {get { return"ProductsReport"; }
    }publicoverride IReportSource ReportSource
    {get
        {// LINQ queryvar query = from p in db.Productsselect p;return query.ToReportSource();
        }
    }publicoverridevoid CustomizeReport(Report report)
    {// Text Fields
        report.TextFields.Title = "Products Report";
        report.TextFields.Footer = "Copyright 2009 &copy; The Doddle Project";
        report.TextFields.Header = string.Format("Report Generated: {0}", DateTime.Now);// Data Fields
        report.DataFields["ProductID"].Hidden = true;
        report.DataFields["CategoryID"].Hidden = true;
        report.DataFields["SupplierID"].Hidden = true;
    }
}

ASP.NET MVC

And for my MVC friends I have provided a ReportResult to use as an Action Result that will serve up the report.

The ReportResult will actually read the extension of the request on the controller and return the correct type of report.

  • PDF - http://myserver.com/reports/ProductsReport.pdf
  • Excel - http://myserver.com/reports/ProductsReport.xls
  • HTML - http://myserver.com/reports/ProductsReport.html
  • Delimited - http://myserver.com/reports/ProductsReport.txt

Configuration

Check out the Configuring DoddleReport documentation to map the URL extension with a specific Report Writer.

IMPORTANT

Before using DoddleReport with ASP.NET MVC, you will probably want to register a Route that DoddleReport can use to dynamically load the requested report writer based on the URL extension. In order to do this simply go to where you define your routes (in Global.asax for many people) and add the following line:

routes.MapReportingRoute();

Next simply create your report like you normally would and return it inside an instance of ReportResult. DoddleReport will handle the rest.

public ReportResult ProductReport()
{// Get the data for the report (any IEnumerable will work)var query = ProductRepository.GetAll();var totalProducts = query.Count;var totalOrders = query.Sum(p => p.OrderCount);// Create the report and turn our query into a ReportSourcevar report = new Report(query.ToReportSource());// Customize the Text Fieldsreport.TextFields.Title = "Products Report";
    report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works";
    report.TextFields.Footer = "Copyright 2011 &copy; The Doddle Project";
    report.TextFields.Header = string.Format(@"
        Report Generated: {0}
        Total Products: {1}
        Total Orders: {2}
        Total Sales: {3:c}", DateTime.Now, totalProducts, totalOrders, totalProducts * totalOrders);// Render hints allow you to pass additional hints to the reports as they are being renderedreport.RenderHints.BooleanCheckboxes = true;// Customize the data fieldsreport.DataFields["Id"].Hidden = true;
    report.DataFields["Price"].DataFormatString = "{0:c}";
    report.DataFields["LastPurchase"].DataFormatString = "{0:d}";// Return the ReportResult
    // the type of report that is rendered will be determined by the extension in the URL (.pdf, .xls, .html, etc)return new ReportResult(report);
}

Updated Wiki: Web Reporting

$
0
0

Web Reporting

ASP.NET WebForms

The simplest way to add reporting to an ASP.NET application is to add a "Generic Handler (.ashx)" to your project. If you are unfamiliar with .ashx files, they are basic HTTP handlers like .aspx, but they do not have the overhead of building a Page object and a control heirarchy. They are for serving any kind of content over the web, including HTML, binary data like PDF, images, etc. They are accessed via URL just like a regular .aspx, and can be passed querystrings the same way.

WebReport will handle all serving of the report for you. It will determine what type of report to send based on the?ReportType querystring.

  • PDF: http://myserver.com/Reports/ProductsReport.ashx?ReportType=PDF
  • Excel: http://myserver.com/Reports/ProductsReport.ashx?ReportType=Excel

Configuration

Check out the Configuring DoddleReport documentation to map the ReportType parameter to specific Report Writers.


When you create your ashx you can replace all the code inside as follows, you just need to implement a few basic abstract members.

publicclass ProductsReport : WebReport
{publicoverridestring FileName
    {get { return"ProductsReport"; }
    }publicoverride IReportSource ReportSource
    {get
        {// LINQ queryvar query = from p in db.Productsselect p;return query.ToReportSource();
        }
    }publicoverridevoid CustomizeReport(Report report)
    {// Text Fields
        report.TextFields.Title = "Products Report";
        report.TextFields.Footer = "Copyright 2009 &copy; The Doddle Project";
        report.TextFields.Header = string.Format("Report Generated: {0}", DateTime.Now);// Data Fields
        report.DataFields["ProductID"].Hidden = true;
        report.DataFields["CategoryID"].Hidden = true;
        report.DataFields["SupplierID"].Hidden = true;
    }
}

ASP.NET MVC

And for my MVC friends I have provided a ReportResult to use as an Action Result that will serve up the report.

The ReportResult will actually read the extension of the request on the controller and return the correct type of report.

  • PDF - http://myserver.com/reports/ProductsReport.pdf
  • Excel - http://myserver.com/reports/ProductsReport.xls
  • HTML - http://myserver.com/reports/ProductsReport.html
  • Delimited - http://myserver.com/reports/ProductsReport.txt

Configuration

Check out the Configuring DoddleReport documentation to map the URL extension with a specific Report Writer.

IMPORTANT ROUTING STEP

DoddleReport can automatically determine which IReportWriter to use based on the file extension of the route. To enable this, you must do the following:

// Add using DoddleReport.Web;
// put this line at the _top_ of your route configuration
routes.MapReportingRoute();

Next simply create your report like you normally would and return it inside an instance of ReportResult. DoddleReport will handle the rest.

public ReportResult ProductReport()
{// Get the data for the report (any IEnumerable will work)var query = ProductRepository.GetAll();var totalProducts = query.Count;var totalOrders = query.Sum(p => p.OrderCount);// Create the report and turn our query into a ReportSourcevar report = new Report(query.ToReportSource());// Customize the Text Fieldsreport.TextFields.Title = "Products Report";
    report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works";
    report.TextFields.Footer = "Copyright 2011 &copy; The Doddle Project";
    report.TextFields.Header = string.Format(@"
        Report Generated: {0}
        Total Products: {1}
        Total Orders: {2}
        Total Sales: {3:c}", DateTime.Now, totalProducts, totalOrders, totalProducts * totalOrders);// Render hints allow you to pass additional hints to the reports as they are being renderedreport.RenderHints.BooleanCheckboxes = true;// Customize the data fieldsreport.DataFields["Id"].Hidden = true;
    report.DataFields["Price"].DataFormatString = "{0:c}";
    report.DataFields["LastPurchase"].DataFormatString = "{0:d}";// Return the ReportResult
    // the type of report that is rendered will be determined by the extension in the URL (.pdf, .xls, .html, etc)return new ReportResult(report);
}

Updated Wiki: Web Reporting

$
0
0

Web Reporting

ASP.NET WebForms

The simplest way to add reporting to an ASP.NET application is to add a "Generic Handler (.ashx)" to your project. If you are unfamiliar with .ashx files, they are basic HTTP handlers like .aspx, but they do not have the overhead of building a Page object and a control heirarchy. They are for serving any kind of content over the web, including HTML, binary data like PDF, images, etc. They are accessed via URL just like a regular .aspx, and can be passed querystrings the same way.

WebReport will handle all serving of the report for you. It will determine what type of report to send based on the?ReportType querystring.

  • PDF: http://myserver.com/Reports/ProductsReport.ashx?ReportType=PDF
  • Excel: http://myserver.com/Reports/ProductsReport.ashx?ReportType=Excel

Configuration

Check out the Configuring DoddleReport documentation to map the ReportType parameter to specific Report Writers.


When you create your ashx you can replace all the code inside as follows, you just need to implement a few basic abstract members.

publicclass ProductsReport : WebReport
{publicoverridestring FileName
    {get { return"ProductsReport"; }
    }publicoverride IReportSource ReportSource
    {get
        {// LINQ queryvar query = from p in db.Productsselect p;return query.ToReportSource();
        }
    }publicoverridevoid CustomizeReport(Report report)
    {// Text Fields
        report.TextFields.Title = "Products Report";
        report.TextFields.Footer = "Copyright 2009 &copy; The Doddle Project";
        report.TextFields.Header = string.Format("Report Generated: {0}", DateTime.Now);// Data Fields
        report.DataFields["ProductID"].Hidden = true;
        report.DataFields["CategoryID"].Hidden = true;
        report.DataFields["SupplierID"].Hidden = true;
    }
}

ASP.NET MVC

And for my MVC friends I have provided a ReportResult to use as an Action Result that will serve up the report.

The ReportResult will actually read the extension of the request on the controller and return the correct type of report.

  • PDF - http://myserver.com/reports/ProductsReport.pdf
  • Excel - http://myserver.com/reports/ProductsReport.xls
  • HTML - http://myserver.com/reports/ProductsReport.html
  • Delimited - http://myserver.com/reports/ProductsReport.txt

Configuration

Check out the Configuring DoddleReport documentation to map the URL extension with a specific Report Writer.

IMPORTANT ROUTING STEP

DoddleReport can automatically determine which IReportWriter to use based on the file extension of the route. To enable this, you must do the following:

// Add using DoddleReport.Web;// put this line at the _top_ of your route configuration
routes.MapReportingRoute();

Next simply create your report like you normally would and return it inside an instance of ReportResult. DoddleReport will handle the rest.

public ReportResult ProductReport()
{// Get the data for the report (any IEnumerable will work)var query = ProductRepository.GetAll();var totalProducts = query.Count;var totalOrders = query.Sum(p => p.OrderCount);// Create the report and turn our query into a ReportSourcevar report = new Report(query.ToReportSource());// Customize the Text Fieldsreport.TextFields.Title = "Products Report";
    report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works";
    report.TextFields.Footer = "Copyright 2011 &copy; The Doddle Project";
    report.TextFields.Header = string.Format(@"
        Report Generated: {0}
        Total Products: {1}
        Total Orders: {2}
        Total Sales: {3:c}", DateTime.Now, totalProducts, totalOrders, totalProducts * totalOrders);// Render hints allow you to pass additional hints to the reports as they are being renderedreport.RenderHints.BooleanCheckboxes = true;// Customize the data fieldsreport.DataFields["Id"].Hidden = true;
    report.DataFields["Price"].DataFormatString = "{0:c}";
    report.DataFields["LastPurchase"].DataFormatString = "{0:d}";// Return the ReportResult
    // the type of report that is rendered will be determined by the extension in the URL (.pdf, .xls, .html, etc)return new ReportResult(report);
}

Updated Wiki: Web Reporting

$
0
0

Web Reporting

ASP.NET WebForms

The simplest way to add reporting to an ASP.NET application is to add a "Generic Handler (.ashx)" to your project. If you are unfamiliar with .ashx files, they are basic HTTP handlers like .aspx, but they do not have the overhead of building a Page object and a control heirarchy. They are for serving any kind of content over the web, including HTML, binary data like PDF, images, etc. They are accessed via URL just like a regular .aspx, and can be passed querystrings the same way.

WebReport will handle all serving of the report for you. It will determine what type of report to send based on the?ReportType querystring.

  • PDF: http://myserver.com/Reports/ProductsReport.ashx?ReportType=PDF
  • Excel: http://myserver.com/Reports/ProductsReport.ashx?ReportType=Excel

Configuration

Check out the Configuring DoddleReport documentation to map the ReportType parameter to specific Report Writers.


When you create your ashx you can replace all the code inside as follows, you just need to implement a few basic abstract members.

publicclass ProductsReport : WebReport
{publicoverridestring FileName
    {get { return"ProductsReport"; }
    }publicoverride IReportSource ReportSource
    {get
        {// LINQ queryvar query = from p in db.Productsselect p;return query.ToReportSource();
        }
    }publicoverridevoid CustomizeReport(Report report)
    {// Text Fields
        report.TextFields.Title = "Products Report";
        report.TextFields.Footer = "Copyright 2009 &copy; The Doddle Project";
        report.TextFields.Header = string.Format("Report Generated: {0}", DateTime.Now);// Data Fields
        report.DataFields["ProductID"].Hidden = true;
        report.DataFields["CategoryID"].Hidden = true;
        report.DataFields["SupplierID"].Hidden = true;
    }
}

ASP.NET MVC

And for my MVC friends I have provided a ReportResult to use as an Action Result that will serve up the report.

The ReportResult will actually read the extension of the request on the controller and return the correct type of report.

  • PDF - http://myserver.com/reports/ProductsReport.pdf
  • Excel - http://myserver.com/reports/ProductsReport.xls
  • HTML - http://myserver.com/reports/ProductsReport.html
  • Delimited - http://myserver.com/reports/ProductsReport.txt

Configuration

Check out the Configuring DoddleReport documentation to map the URL extension with a specific Report Writer.

IMPORTANT ROUTING STEP

DoddleReport can automatically determine which IReportWriter to use based on the file extension of the route. To enable this, you must do the following:

// Add using DoddleReport.Web;// put this line at the _top_ of your route configuration
routes.MapReportingRoute();

Next simply create your report like you normally would and return it inside an instance of ReportResult. DoddleReport will handle the rest.

public ReportResult ProductReport()
{// Get the data for the report (any IEnumerable will work)var query = ProductRepository.GetAll();var totalProducts = query.Count;var totalOrders = query.Sum(p => p.OrderCount);// Create the report and turn our query into a ReportSourcevar report = new Report(query.ToReportSource());// Customize the Text Fieldsreport.TextFields.Title = "Products Report";
    report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works";
    report.TextFields.Footer = "Copyright 2011 &copy; The Doddle Project";
    report.TextFields.Header = string.Format(@"
        Report Generated: {0}
        Total Products: {1}
        Total Orders: {2}
        Total Sales: {3:c}", DateTime.Now, totalProducts, totalOrders, totalProducts * totalOrders);// Render hints allow you to pass additional hints to the reports as they are being renderedreport.RenderHints.BooleanCheckboxes = true;// Customize the data fieldsreport.DataFields["Id"].Hidden = true;
    report.DataFields["Price"].DataFormatString = "{0:c}";
    report.DataFields["LastPurchase"].DataFormatString = "{0:d}";// Return the ReportResult
    // the type of report that is rendered will be determined by the extension in the URL (.pdf, .xls, .html, etc)return new ReportResult(report);
}

Updated Wiki: Documentation

Updated Wiki: Documentation

Updated Wiki: Documentation

Updated Wiki: Customization

$
0
0

Customization

DoddleReport automatically picks up on certain attributes on your model, specifically the Data Annotationsattributes.

If you put a [Display(Name = "Product Name")] on top on your property, DoddleReport will use that customized name when rendering the property on the report.

Additionally, there are 3 ways to further customize your reports.

  • Render Hints
  • Text Fields
  • Data Fields

 

// Render Hints
report.RenderHints.Orientation = ReportOrientation.Landscape;
report.RenderHints.BooleanCheckboxes = true;// Text Fields
report.TextFields.Title = "Products Report";
report.TextFields.Footer = "Copyright 2009 &copy; The Doddle Project";
report.TextFields.Header = string.Format("Report Generated: {0}", DateTime.Now);
report.TextFields["HtmlLogo"] = "<img src='http://www.matthidinger.com/doddlelogo.jpg' />";// Data Fields
report.DataFields["ProductID"].Hidden = true;
report.DataFields["CategoryID"].Hidden = true;
report.DataFields["SupplierID"].Hidden = true;
report.DataFields["ProductName"].HeaderText = "Product";
report.DataFields["UnitPrice"].DataFormatString = "{0:C}";
report.DataFields["UnitPrice"].ShowTotals = true;
report.DataFields[0].DataStyle.BackColor = Color.Maroon;
report.DataFields[0].DataStyle.ForeColor = Color.White;
// Advanced customization with a callback delegate
report.DataFields["OutOfStock"].FormatAs<bool>(value => value ? "Yes" : "No");

TextFields

Text Fields will be used by the Report Writers to supply key textual fields to a report writer.

The default TextFields are as follows:

  • Title - specify the page title
  • Header - specify additional page header information
  • Footer - specify the page footer


All Report Writers should understand how to write those 3 primary fields, but they can also go beyond that. The TextFields property also supports an indexer overload to set custom TextFields that only certain ReportWriters will interpret. This will allow you to use the same Report for a variety of writers.

In the example above you will notice I used a report.TextFields["HtmlLogo"] = "<img src='http://www.matthidinger.com/doddlelogo.jpg' />"; -- this is a custom TextField named "HtmlLogo" that only the HtmlReportWriter will be looking for. When the HtmlReportWriter begins render a report that specifies a custom HtmlLogo TextField it will append the image URL to its HTML output, allowing simple and flexible customization of the rendering with minimal work.

DataFields

Data Fields represent the columns of data written to the report. They are accesses via an indexer and allow customization via the following properties:

  • Hidden - hides a field from the report
  • HeaderText - specify custom header text for the column
  • ShowTotals - if a numeric column and set to true, this will automatically append a Totals Footer under the column
  • DataFormatString - specify a custom DataFormatString to write the data ("{0:C}" will format currency for example)
  • DataStyle - specify the Style of the data rows for this column
  • HeaderStyle - specify the Style of the header row for this column
  • FooterStyle - specify the Style of the footer row for this column

RenderHints

Render Hints are used to supply custom data that will be passed to ReportWriters giving them some additional insight in how you want your report to appear.

The default RenderHints are as follows:

  • Orientation - specify whether you want you report to appear Portrait or Landscape
  • BooleanCheckboxes - indicate that you want your report to render boolean fields as checkboxes


The RenderHints property behaves exactly like the TextFields property in that it supports an indexer to pass in custom RenderHints to the report writers.

In the example above you will notice I used a report.RenderHints["HtmlStyle"] = "p { font-size: 14px; }"; -- this is a custom RenderHint that only the HtmlReportWriter will be looking for, and when it writes a report that specifies a custom HtmlStyle it will append that style declaration to its HTML output, allowing simple and flexible customization of the rendering with minimal work.

RenderingRow Event

For maximum flexibility you can subscribe to the RenderingRow event and add per-row rendering logic to your report.

// Subscribe
report.RenderingRow += new EventHandler<ReportRowEventArgs>(report_RenderingRow);// Add logicvoid report_RenderingRow(object sender, ReportRowEventArgs e)
{if (e.Row.RowType == ReportRowType.DataRow)
    {decimal unitPrice = (decimal) e.Row["UnitPrice"];if (unitPrice < 10)
        {
            e.Row.Fields["UnitPrice"].DataStyle.Bold = true;
        }
    }
}

Updated Wiki: Customization

$
0
0

Customization

DoddleReport automatically picks up on certain attributes on your model, specifically the Data Annotationsattributes.

If you put a [Display(Name = "Product Name")] on top on your property, DoddleReport will use that customized name when rendering the property on the report.

Additionally, there are 3 ways to further customize your reports.

  • Render Hints
  • Text Fields
  • Data Fields

 

// Render Hints
report.RenderHints.Orientation = ReportOrientation.Landscape;
report.RenderHints.BooleanCheckboxes = true;// Text Fields
report.TextFields.Title = "Products Report";
report.TextFields.Footer = "Copyright 2009 &copy; The Doddle Project";
report.TextFields.Header = string.Format("Report Generated: {0}", DateTime.Now);
report.TextFields["HtmlLogo"] = "<img src='http://www.matthidinger.com/doddlelogo.jpg' />";// Data Fields
report.DataFields["ProductID"].Hidden = true;
report.DataFields["CategoryID"].Hidden = true;
report.DataFields["SupplierID"].Hidden = true;
report.DataFields["ProductName"].HeaderText = "Product";
report.DataFields["UnitPrice"].DataFormatString = "{0:C}";
report.DataFields["UnitPrice"].ShowTotals = true;
report.DataFields[0].DataStyle.BackColor = Color.Maroon;
report.DataFields[0].DataStyle.ForeColor = Color.White;
// Advanced customization with a callback delegate
report.DataFields["OutOfStock"].FormatAs<bool>(value => value ? "Yes" : "No");

TextFields

Text Fields will be used by the Report Writers to supply key textual fields to a report writer.

The default TextFields are as follows:

  • Title - specify the page title
  • Header - specify additional page header information
  • Footer - specify the page footer


All Report Writers should understand how to write those 3 primary fields, but they can also go beyond that. The TextFields property also supports an indexer overload to set custom TextFields that only certain ReportWriters will interpret. This will allow you to use the same Report for a variety of writers.

In the example above you will notice I used a report.TextFields["HtmlLogo"] = "<img src='http://www.matthidinger.com/doddlelogo.jpg' />"; -- this is a custom TextField named "HtmlLogo" that only the HtmlReportWriter will be looking for. When the HtmlReportWriter begins render a report that specifies a custom HtmlLogo TextField it will append the image URL to its HTML output, allowing simple and flexible customization of the rendering with minimal work.

DataFields

Data Fields represent the columns of data written to the report. They are accesses via an indexer and allow customization via the following properties:

  • Hidden - hides a field from the report
  • HeaderText - specify custom header text for the column
  • ShowTotals - if a numeric column and set to true, this will automatically append a Totals Footer under the column
  • DataFormatString - specify a custom DataFormatString to write the data ("{0:C}" will format currency for example)
  • DataStyle - specify the Style of the data rows for this column
  • HeaderStyle - specify the Style of the header row for this column
  • FooterStyle - specify the Style of the footer row for this column

RenderHints

Render Hints are used to supply custom data that will be passed to ReportWriters giving them some additional insight in how you want your report to appear.

The default RenderHints are as follows:

  • Orientation - specify whether you want you report to appear Portrait or Landscape
  • BooleanCheckboxes - indicate that you want your report to render boolean fields as checkboxes


The RenderHints property behaves exactly like the TextFields property in that it supports an indexer to pass in custom RenderHints to the report writers.

In the example above you will notice I used a report.RenderHints["HtmlStyle"] = "p { font-size: 14px; }"; -- this is a custom RenderHint that only the HtmlReportWriter will be looking for, and when it writes a report that specifies a custom HtmlStyle it will append that style declaration to its HTML output, allowing simple and flexible customization of the rendering with minimal work.

RenderingRow Event

For maximum flexibility you can subscribe to the RenderingRow event and add per-row rendering logic to your report.

// Subscribe
report.RenderingRow += new EventHandler<ReportRowEventArgs>(report_RenderingRow);// Add logicvoid report_RenderingRow(object sender, ReportRowEventArgs e)
{if (e.Row.RowType == ReportRowType.DataRow)
    {decimal unitPrice = (decimal) e.Row["UnitPrice"];if (unitPrice < 10)
        {
            e.Row.Fields["UnitPrice"].DataStyle.Bold = true;
        }
    }
}

Updated Wiki: Customization

$
0
0

Customization

DoddleReport automatically picks up on certain attributes on your model, specifically the Data Annotationsattributes.

If you put a [Display(Name = "Product Name")] on top on your property, DoddleReport will use that customized name when rendering the property on the report.

Additionally, there are 3 ways to further customize your reports.

  • Render Hints
  • Text Fields
  • Data Fields

 

// Render Hints
report.RenderHints.Orientation = ReportOrientation.Landscape;
report.RenderHints.BooleanCheckboxes = true;// Text Fields
report.TextFields.Title = "Products Report";
report.TextFields.Footer = "Copyright 2009 &copy; The Doddle Project";
report.TextFields.Header = string.Format("Report Generated: {0}", DateTime.Now);
report.TextFields["HtmlLogo"] = "<img src='http://www.matthidinger.com/doddlelogo.jpg' />";// Data Fields
report.DataFields["ProductID"].Hidden = true;
report.DataFields["CategoryID"].Hidden = true;
report.DataFields["SupplierID"].Hidden = true;
report.DataFields["ProductName"].HeaderText = "Product";
report.DataFields["UnitPrice"].DataFormatString = "{0:C}";
report.DataFields["UnitPrice"].ShowTotals = true;
report.DataFields[0].DataStyle.BackColor = Color.Maroon;
report.DataFields[0].DataStyle.ForeColor = Color.White;// Advanced customization with a callback delegate
report.DataFields["OutOfStock"].FormatAs<bool>(value => value ? "Yes" : "No");

TextFields

Text Fields will be used by the Report Writers to supply key textual fields to a report writer.

The default TextFields are as follows:

  • Title - specify the page title
  • Header - specify additional page header information
  • Footer - specify the page footer


All Report Writers should understand how to write those 3 primary fields, but they can also go beyond that. The TextFields property also supports an indexer overload to set custom TextFields that only certain ReportWriters will interpret. This will allow you to use the same Report for a variety of writers.

In the example above you will notice I used a report.TextFields["HtmlLogo"] = "<img src='http://www.matthidinger.com/doddlelogo.jpg' />"; -- this is a custom TextField named "HtmlLogo" that only the HtmlReportWriter will be looking for. When the HtmlReportWriter begins render a report that specifies a custom HtmlLogo TextField it will append the image URL to its HTML output, allowing simple and flexible customization of the rendering with minimal work.

DataFields

Data Fields represent the columns of data written to the report. They are accesses via an indexer and allow customization via the following properties:

  • Hidden - hides a field from the report
  • HeaderText - specify custom header text for the column
  • ShowTotals - if a numeric column and set to true, this will automatically append a Totals Footer under the column
  • DataFormatString - specify a custom DataFormatString to write the data ("{0:C}" will format currency for example)
  • DataStyle - specify the Style of the data rows for this column
  • HeaderStyle - specify the Style of the header row for this column
  • FooterStyle - specify the Style of the footer row for this column

RenderHints

Render Hints are used to supply custom data that will be passed to ReportWriters giving them some additional insight in how you want your report to appear.

The default RenderHints are as follows:

  • Orientation - specify whether you want you report to appear Portrait or Landscape
  • BooleanCheckboxes - indicate that you want your report to render boolean fields as checkboxes


The RenderHints property behaves exactly like the TextFields property in that it supports an indexer to pass in custom RenderHints to the report writers.

In the example above you will notice I used a report.RenderHints["HtmlStyle"] = "p { font-size: 14px; }"; -- this is a custom RenderHint that only the HtmlReportWriter will be looking for, and when it writes a report that specifies a custom HtmlStyle it will append that style declaration to its HTML output, allowing simple and flexible customization of the rendering with minimal work.

RenderingRow Event

For maximum flexibility you can subscribe to the RenderingRow event and add per-row rendering logic to your report.

// Subscribe
report.RenderingRow += new EventHandler<ReportRowEventArgs>(report_RenderingRow);// Add logicvoid report_RenderingRow(object sender, ReportRowEventArgs e)
{if (e.Row.RowType == ReportRowType.DataRow)
    {decimal unitPrice = (decimal) e.Row["UnitPrice"];if (unitPrice < 10)
        {
            e.Row.Fields["UnitPrice"].DataStyle.Bold = true;
        }
    }
}

Updated Wiki: Customization

$
0
0

Customization

DoddleReport automatically picks up on certain attributes on your model, specifically the Data Annotationsattributes.

If you put a [Display(Name = "Product Name")] on top on your property, DoddleReport will use that customized name when rendering the property on the report.

Additionally, there are 4 ways to further customize your reports.

  • Render Hints
  • Text Fields
  • Data Fields
  • RenderingRow event

 

// Render Hints
report.RenderHints.Orientation = ReportOrientation.Landscape;
report.RenderHints.BooleanCheckboxes = true;// Text Fields
report.TextFields.Title = "Products Report";
report.TextFields.Footer = "Copyright 2009 &copy; The Doddle Project";
report.TextFields.Header = string.Format("Report Generated: {0}", DateTime.Now);
report.TextFields["HtmlLogo"] = "<img src='http://www.matthidinger.com/doddlelogo.jpg' />";// Data Fields
report.DataFields["ProductID"].Hidden = true;
report.DataFields["CategoryID"].Hidden = true;
report.DataFields["SupplierID"].Hidden = true;
report.DataFields["ProductName"].HeaderText = "Product";
report.DataFields["UnitPrice"].DataFormatString = "{0:C}";
report.DataFields["UnitPrice"].ShowTotals = true;
report.DataFields[0].DataStyle.BackColor = Color.Maroon;
report.DataFields[0].DataStyle.ForeColor = Color.White;// Advanced customization with a callback delegate
report.DataFields["OutOfStock"].FormatAs<bool>(value => value ? "Yes" : "No");

TextFields

Text Fields will be used by the Report Writers to supply key textual fields to a report writer.

The default TextFields are as follows:

  • Title - specify the page title
  • Header - specify additional page header information
  • Footer - specify the page footer


All Report Writers should understand how to write those 3 primary fields, but they can also go beyond that. The TextFields property also supports an indexer overload to set custom TextFields that only certain ReportWriters will interpret. This will allow you to use the same Report for a variety of writers.

In the example above you will notice I used a report.TextFields["HtmlLogo"] = "<img src='http://www.matthidinger.com/doddlelogo.jpg' />"; -- this is a custom TextField named "HtmlLogo" that only the HtmlReportWriter will be looking for. When the HtmlReportWriter begins render a report that specifies a custom HtmlLogo TextField it will append the image URL to its HTML output, allowing simple and flexible customization of the rendering with minimal work.

DataFields

Data Fields represent the columns of data written to the report. They are accesses via an indexer and allow customization via the following properties:

  • Hidden - hides a field from the report
  • HeaderText - specify custom header text for the column
  • ShowTotals - if a numeric column and set to true, this will automatically append a Totals Footer under the column
  • DataFormatString - specify a custom DataFormatString to write the data ("{0:C}" will format currency for example)
  • DataStyle - specify the Style of the data rows for this column
  • HeaderStyle - specify the Style of the header row for this column
  • FooterStyle - specify the Style of the footer row for this column

RenderHints

Render Hints are used to supply custom data that will be passed to ReportWriters giving them some additional insight in how you want your report to appear.

The default RenderHints are as follows:

  • Orientation - specify whether you want you report to appear Portrait or Landscape
  • BooleanCheckboxes - indicate that you want your report to render boolean fields as checkboxes


The RenderHints property behaves exactly like the TextFields property in that it supports an indexer to pass in custom RenderHints to the report writers.

In the example above you will notice I used a report.RenderHints["HtmlStyle"] = "p { font-size: 14px; }"; -- this is a custom RenderHint that only the HtmlReportWriter will be looking for, and when it writes a report that specifies a custom HtmlStyle it will append that style declaration to its HTML output, allowing simple and flexible customization of the rendering with minimal work.

RenderingRow Event

For maximum flexibility you can subscribe to the RenderingRow event and add per-row rendering logic to your report.

// Subscribe
report.RenderingRow += new EventHandler<ReportRowEventArgs>(report_RenderingRow);// Add logicvoid report_RenderingRow(object sender, ReportRowEventArgs e)
{if (e.Row.RowType == ReportRowType.DataRow)
    {decimal unitPrice = (decimal) e.Row["UnitPrice"];if (unitPrice < 10)
        {
            e.Row.Fields["UnitPrice"].DataStyle.Bold = true;
        }
    }
}

Updated Wiki: Customization

$
0
0

Customizing the way your reports are rendered

DoddleReport automatically picks up on certain attributes on your model, specifically the Data Annotationsattributes.

If you put a [Display(Name = "Product Name")] on top on your property, DoddleReport will use that customized name when rendering the property on the report.

Additionally, there are 4 ways to further customize your reports.

  • Render Hints
  • Text Fields
  • Data Fields
  • RenderingRow event

 

// Render Hints
report.RenderHints.Orientation = ReportOrientation.Landscape;
report.RenderHints.BooleanCheckboxes = true;// Text Fields
report.TextFields.Title = "Products Report";
report.TextFields.Footer = "Copyright 2009 &copy; The Doddle Project";
report.TextFields.Header = string.Format("Report Generated: {0}", DateTime.Now);
report.TextFields["HtmlLogo"] = "<img src='http://www.matthidinger.com/doddlelogo.jpg' />";// Data Fields
report.DataFields["ProductID"].Hidden = true;
report.DataFields["CategoryID"].Hidden = true;
report.DataFields["SupplierID"].Hidden = true;
report.DataFields["ProductName"].HeaderText = "Product";
report.DataFields["UnitPrice"].DataFormatString = "{0:C}";
report.DataFields["UnitPrice"].ShowTotals = true;
report.DataFields[0].DataStyle.BackColor = Color.Maroon;
report.DataFields[0].DataStyle.ForeColor = Color.White;// Advanced customization with a callback delegate
report.DataFields["OutOfStock"].FormatAs<bool>(value => value ? "Yes" : "No");

TextFields

Text Fields will be used by the Report Writers to supply key textual fields to a report writer.

The default TextFields are as follows:

  • Title - specify the page title
  • Header - specify additional page header information
  • Footer - specify the page footer


All Report Writers should understand how to write those 3 primary fields, but they can also go beyond that. The TextFields property also supports an indexer overload to set custom TextFields that only certain ReportWriters will interpret. This will allow you to use the same Report for a variety of writers.

In the example above you will notice I used a report.TextFields["HtmlLogo"] = "<img src='http://www.matthidinger.com/doddlelogo.jpg' />"; -- this is a custom TextField named "HtmlLogo" that only the HtmlReportWriter will be looking for. When the HtmlReportWriter begins render a report that specifies a custom HtmlLogo TextField it will append the image URL to its HTML output, allowing simple and flexible customization of the rendering with minimal work.

DataFields

Data Fields represent the columns of data written to the report. They are accesses via an indexer and allow customization via the following properties:

  • Hidden - hides a field from the report
  • HeaderText - specify custom header text for the column
  • ShowTotals - if a numeric column and set to true, this will automatically append a Totals Footer under the column
  • DataFormatString - specify a custom DataFormatString to write the data ("{0:C}" will format currency for example)
  • DataStyle - specify the Style of the data rows for this column
  • HeaderStyle - specify the Style of the header row for this column
  • FooterStyle - specify the Style of the footer row for this column

RenderHints

Render Hints are used to supply custom data that will be passed to ReportWriters giving them some additional insight in how you want your report to appear.

The default RenderHints are as follows:

  • Orientation - specify whether you want you report to appear Portrait or Landscape
  • BooleanCheckboxes - indicate that you want your report to render boolean fields as checkboxes


The RenderHints property behaves exactly like the TextFields property in that it supports an indexer to pass in custom RenderHints to the report writers.

In the example above you will notice I used a report.RenderHints["HtmlStyle"] = "p { font-size: 14px; }"; -- this is a custom RenderHint that only the HtmlReportWriter will be looking for, and when it writes a report that specifies a custom HtmlStyle it will append that style declaration to its HTML output, allowing simple and flexible customization of the rendering with minimal work.

RenderingRow Event

For maximum flexibility you can subscribe to the RenderingRow event and add per-row rendering logic to your report.

// Subscribe
report.RenderingRow += new EventHandler<ReportRowEventArgs>(report_RenderingRow);// Add logicvoid report_RenderingRow(object sender, ReportRowEventArgs e)
{if (e.Row.RowType == ReportRowType.DataRow)
    {decimal unitPrice = (decimal) e.Row["UnitPrice"];if (unitPrice < 10)
        {
            e.Row.Fields["UnitPrice"].DataStyle.Bold = true;
        }
    }
}

Updated Wiki: Home

$
0
0

DoddleReport generates tabular reports from any IEnumerable datasource.

Out of the box it can render reports to Excel, PDF, HTML, and CSV – fully pluggable of course. I designed the project to provide reporting output over the LINQ queries we had already written for the application, but maybe you can find other uses for it.

Blog Updates

For updates and other topics please visit my blog at http://www.matthidinger.com or follow@matthidinger

New to DoddleReport?

Get it!

NuGet Packages

DoddleReport has been split into multiple packages to support more users’ needs. See their Descriptions within NuGet for more on the differences

  • Install-Package DoddleReport
  • Install-Package DoddleReport.Web
  • Install-Package DoddleReport.iTextSharp
  • Install-Package DoddleReport.AbcPdf
  • Install-Package DoddleReport.OpenXml

 

New in v1.2

  • NEW WRITER: A new OpenXML ExcelReportWriter found in the DoddleReport.OpenXml package, courtesy of Louis-Philippe Perras
  • NEW WRITER: A new iTextSharp PDF writer can be found in the DoddleReport.iTextSharp package, courtesy of Louis-Philippe Perras (thanks again!)
  • Breaking change: The root namespace changed from Doddle.Reporting to justDoddleReport
  • Breaking change: The Default Orientation for reports is now Portrait
  • All Web references moved to separate project to allow for .NET Client Profile support for WinForms/WPF
  • Added “myReport.RenderHints.BooleansAsYesNo = true” to write Yes/No on the reports for boolean fields
  • Added custom FileName support for web reporting as requested in Discussions
  • Added MVC Areas support by calling areaRegistrationContext.MapReportingRoute();
  • Various Bug fixes and enhancements as reported in the Discussion forum and Issue Tracker

So what does it generate?

The following samples are generated live in real-time (notice the data will change every time you open the report)

Excel Report (OpenXML)

  • Creates a native Excel file using OpenXML
  • Requires the DoddleReport.OpenXml package
  • See it live!

Excel Report (HTML)

  • Creates an Excel file using HTML (downside being an Excel security prompt when opening the report)
  • Automatic Sticky/Frozen Headers stay at the top when scrolling through the data
  • See it live!

doddlexlsreport 

doddlexlsreport

PDF Report (iTextSharp)

  • Automatically repeats title and column headers numbers on every page
  • Requires the DoddleReport.iTextSharp package
  • See it live!

PDF Report (ABCpdf)

  • Automatically repeats title, column headers, and page numbers on every page
  • Requires the DoddleReport.AbcPdf package
  • Requires an ABCpdf license
  • See it live!

image

doddlepdfreport

CSV/Delimited

HTML Report

doddleTxtReport

doddleHtmlReport

Basic Usage

// Get the data for the report (any IEnumerable will work)var query = ProductRepository.GetAll();var totalProducts = query.Count;var totalOrders = query.Sum(p => p.OrderCount);// Create the report and turn our query into a ReportSourcevar report = new Report(query.ToReportSource());// Customize the Text Fieldsreport.TextFields.Title = "Products Report";
report.TextFields.SubTitle = "This is a sample report showing how Doddle Report works";
report.TextFields.Footer = "Copyright 2011 &copy; The Doddle Project";
report.TextFields.Header = string.Format(@"
    Report Generated: {0}
    Total Products: {1}
    Total Orders: {2}
    Total Sales: {3:c}", DateTime.Now, totalProducts, totalOrders, totalProducts * totalOrders);// Render hints allow you to pass additional hints to the reports as they are being renderedreport.RenderHints.BooleanCheckboxes = true;// Customize the data fieldsreport.DataFields["Id"].Hidden = true;
report.DataFields["Price"].DataFormatString = "{0:c}";
report.DataFields["LastPurchase"].DataFormatString = "{0:d}";
Viewing all 28 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>