Reports in C # MVC [closed]

0

How do I report to ?

Do I use a third-party component or do I make an HTML page?

What do you use on a day-to-day basis?

I ask, therefore, I need to print reports that follow a government standard. In I do with my feet in the back, but in C # is the my first need.

    
asked by anonymous 26.03.2014 / 12:06

3 answers

2

I recommend using Crystal Reports. Here are some links:

The implementation is simple and very similar to any reporting software. Here is a simple example that returns the report by entering some parameters in the report:

  public ActionResult relatorio_pdf()
    {
        connection.ConectarBanco();

        ReportClass rptH = new ReportClass();

        rptH.FileName = Server.MapPath("~/Views/Relatorios/relatorio.rpt");//Indica o endereço do relatório
        rptH.Load();//Carrega o relatório
        rptH.OpenSubreport("relatorio.rpt");
        rptH.SetDatabaseLogon("usuario_banco","senha_banco");//Indica o usuário e senha do banco no qual o relatório está relacionado
        rptH.SetParameterValue("id_produto", 120);//Indica o parametro para o relatório
        Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);//Diz o tipo de stream, no pdf para Crystal Reports

        connection.FecharConexaoBanco();

        return File(stream, "application/pdf");
    }

Note: This example applies to reports that are linked to a database in your configuration. This process does not become necessary in reports with a related DataSet, just use a Controller where you load the page by returning a Stream from your report.

    
26.03.2014 / 13:53
2

Dude, I would not recommend using any component. Use a well-made model that returns your fields correctly. The components to export to pdf, Excel most have natives.

So you get performance and do not get stuck on any version of components.

    
26.03.2014 / 19:04
1

I think HTML is not the way out of this case - you're going to bother a lot to build and then fine-tune the layout.

If your need in C # is timely (you will continue to develop in Delphi), you can continue processing the report in Delphi resulting in a PDF file, which can then be Viewed to the end user in the browser (For some legacy reports we have, we do this with ASP .NET + COBOL!) .

On top of that, there are several good tools on the market - worth (very) worth the investment if this type of project turns out to be worth it. Here are the report rendering interfaces in the (not necessarily MVC) web :

26.03.2014 / 13:05