Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telerik reporting in ASP.NET MVC project [closed]

Tags:

asp.net-mvc

Can anyone help me in implementing telerik reporting in ASP.NET MVC project?

like image 720
sushrose Avatar asked Jul 20 '10 09:07

sushrose


People also ask

How do I open Telerik report in Visual Studio?

It is accessible through the Telerik Menu --> Reporting for Visual Studio versions up to 2017. For Visual Studio 2019 through the Extensions Menu --> Telerik --> Reporting.

Is Telerik Reporting free?

Telerik Reporting is royalty-free with a license price starting at $599 annually per developer. This . NET reporting tool is available for purchase with flexible pricing options, based on developers' support needs.

Is Telerik Reporting open source?

We are happy to announce that Telerik UI for Universal Windows Platform by Progress is now free and open-source. Yes, you read that correctly! Telerik UI for UWP is now open sourced under the Apache Software License (ASLv2) and is available for download for FREE.


1 Answers

The way I have reporting implemented is without a viewer, instead a user is presented with a "pdf" report, that can be downloaded.

Here is a scenario, user purchases a product online and at the end of the check out process a receipt is presented via a Telerik report.

  1. Add the references to the Telerik reporting assemblies in your project.
  2. Create a report. Telerik TV has some great tutorials on getting started with Telerik reporting.
  3. Controller would make a call to the repository, and serve the byte stream back to the browser.

    public virtual ActionResult DownloadReceiptReport(Order model)
    {
         byte[] contents = ShoppingCartRepository.GetReceiptReport(model);
         return File(contents, "application/pdf", "Receipt.pdf");
    }
    
  4. In your repository create a function to generate the report, in this case the report isn't directly linked to a sqldatasource, the data source is being supplied an objectdatasource component:

    public byte[] GetReceiptReport(Order order)
    {
        Telerik.Reporting.ObjectDataSource objectDataSource = new Telerik.Reporting.ObjectDataSource();
        objectDataSource.DataSource new PurchaseReceiptReportModel() 
        {
            CustomerName = order.CustomerName, 
            Total= order.Total, 
            PurchaseDate= DateTime.Now
        };
    
        PurchaseReceiptReport report = new PurchaseReceiptReport();
        report.DataSource = objectDataSource;
    
        ReportProcessor reportProcessor = new ReportProcessor();
        RenderingResult result = reportProcessor.RenderReport("PDF", report, null);
        return result.DocumentBytes;
    }
    

In the end, user will receive a download pop-up window with a pdf report.

Hope this helps.

like image 59
Igorrious Avatar answered Sep 30 '22 12:09

Igorrious