FastReport: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
Line 65: Line 65:
* [https://www.fast-report.com/en/blog/270/show/ How to use multi-level JSON in a Report]
* [https://www.fast-report.com/en/blog/270/show/ How to use multi-level JSON in a Report]
* [https://www.fast-report.com/en/blog/57/show/ Register Json data in FastReport.NET]
* [https://www.fast-report.com/en/blog/57/show/ Register Json data in FastReport.NET]
* [https://www.fast-report.com/en/blog/262/show/ Use Multiple Databases in a Report]
* [https://www.fast-report.com/en/blog/102/show/ How to use data in JSON format]
* [https://www.fast-report.com/en/blog/102/show/ How to use data in JSON format]
* [https://www.fast-report.com/en/download/fast-report-net/ FastReport .NET Download]
* [https://www.fast-report.com/en/download/fast-report-net/ FastReport .NET Download]
* [https://www.fast-report.com/en/download/fast-cube-net/ FastCube .NET Download]
* [https://www.fast-report.com/en/download/fast-cube-net/ FastCube .NET Download]
* [https://www.nuget.org/packages/FastReport.Core/ Nuget FastReport.Core]
* [https://www.nuget.org/packages/FastReport.Core/ Nuget FastReport.Core]

Revision as of 07:05, 28 November 2020

FastReport.dll
FastReport.Bars.dll
FastReport.Json.dll
FastReport.Editor.dll
Oracle.ManagedDataAccess.dll
using FastReport.Export.Pdf;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace ChorkeAcademiaReport.Controllers.Report
{
    public class ReportController : Controller
    {
        //private readonly ReportDao reportDao;
        private readonly IWebHostEnvironment hostingEnvironment;
        public ReportController(IConfiguration configuration, IWebHostEnvironment _hostingEnvironment)
        {
            //this.reportDao = new ReportDao(configuration);
            this.hostingEnvironment = _hostingEnvironment;
        }

        [HttpGet("/api/rest/report")]
        public IActionResult GetData(string FromDate, string ToDate)
        {
            try
            {
                using (var report = new FastReport.Report())
                {
                    report.Load($"{hostingEnvironment.WebRootPath}/reports/R0TM00X00.frx");
                    var data = reportDao.GetData("EN", FromDate, ToDate);
                    report.SetParameterValue("FromDate", FromDate);
                    report.SetParameterValue("ToDate", ToDate);
                    report.RegisterData(data, "M00TM00X00");
                    report.Prepare();
                    using (var ms = new MemoryStream())
                    {
                        var pdfExport = new PDFExport();
                        report.Export(pdfExport, ms);
                        return File(ms.ToArray(), "Application/PDF");
                    }
                }
            }
            catch (Exception e)
            {
                string text = e.Message;
                Console.WriteLine(e.Message);
                return BadRequest(new { msg = "No data found!" });
            }
        }
    }
}


References