Asp.Net Mvc Reporting Solutions
Jul 20
.Net, Development Asp.Net Mvc, Reporting No Comments
I am currently working on a MVC project that requires a very simple reporting solution. The requirements are as follows:
- Present each report to the user as a PDF
- It must use the existing complex business objects found in the solution
- No ad hoc reporting required and no online report viewer required
- Has to use existing database connection strings, I don’t want to deal with duplicate connection strings that have to be updated whenever the solution gets deployed
Below are my thoughts on the various solutions I tried before finally choosing Telerik Reporting.
PDF Reporting using ASP.NET MVC3
I took a look at this project, but quickly dismissed this approach because I did not want to create the report in HTML. The working copy, if you could call it that, was already in HTML. A HTML report would have required way too much time to get it formatted according to the report specifications.
Microsoft Report Builder
I spent many hours trying to get Microsoft Report Builder to work with my project. First of all you cannot pass a single object to the report. So if you are generating an invoice, or in my case, a work order, you have to place the object into a List<> and use the list as the data source. Report Builder will supposedly use complex business objects if all the classes are serializeable.
For example, my WorkOrder object has a Client object which has an Address object and a Contact object. In theory I could place the Client’s name onto the report using =First(Client.Value.Name). I could not get that to work. The only other option I could see was the use of subreports. That meant a lot of nested subreports, where each subreport was querying the database. That’s not a good option.
The other thing about Report Builder that really frustrated me was the lack of a zoom option. So placing fields onto the report was a royal pain.
Stimulsoft Reports.Web for MVC
Next up was the Stimulsoft Reports.Web for MVC. It looks great, just what I needed. However when I ran the designer, it wanted to load Flash. I promptly uninstalled this product. Given the number of security holes and the constant updates to Flash, I am not interested in running anything that requires Flash.
Perpetuum SharpShooter Reports.Web
This product, Perpetuum SharpShooter Reports.Web, looks very good. First of all I could not find the web version of the SharpShooter reports on NuGet when I first looked. I saw the web version a couple of days later when I shared this experience with a friend. The install adds several examples of adding SharpShooter to a MVC solution. One example can be found here.
The best information I found for using Business Objects as a data source indicated you had to create a class derived from ReportServiceBase. Then you add DataSets to your new class and the report then has access to the data. Really? Screw that! If the product can’t or won’t use my existing business objects, it’s time to look for another.
Telerik Reporting
I finally settled on Telerik Reporting. I installed the trial version and started creating my report. It found my business objects and allowed me to place them onto the report. I could even specify a property several layers deep in the business object.
The report has two subreports, each of which display tabular data from the same table. Creating the subreports was very easy. I pass the parent ID as a parameter and the subreport reads the data from the database using existing connection strings! I even had a problem with one of the subreports and got the correct answer to the problem from a Telerik employee via the Telerik forums. All while using a trial copy.
public ActionResult WorkOrder(long id)
{
try
{
WorkOrder workOrder = Repository.WorkOrderByKey(id);
ReportWorkOrder report = new ReportWorkOrder();
report.DataSource = workOrder;
ReportProcessor reportProcessor = new ReportProcessor();
RenderingResult result = reportProcessor.RenderReport("<wbr>PDF", report, null);
return File(result.DocumentBytes, "application/pdf", "WorkOrder.pdf");
}
catch (Exception ex)
{
AddMessage(UIMessageType.<wbr>Error, ex);
Logging.Error(ex);
}
return RedirectToAction("List", "WorkOrder");
}
Some of the features that I really like about the Telerik Reporting solutions are:
- Easy to use complex business objects in the report
- The report designer has zoom capabilities
- Connecting to the database uses the connection strings from your web.config
- The report designer is very easy to use. It’s intuitive.
- Implemented a PDF export in six lines of code
For more info on Telerik Reporting, check the Telerik website.













Recent Comments