@page
@model IndexModel
@{
@ViewData["heading"];
}
<style>
body, html, #reportviewer {
overflow: hidden !important;
height: 100%;
width: 100%;
}
</style>
<ej-report-viewer id="reportviewer1" report-service-url="../ReportApi" processing-mode="Remote" />
<ej-script-manager></ej-script-manager>
|
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace ReportViewerCore.Pages
{
public class IndexModel : PageModel
{
public void OnGet()
{
ViewData["heading"] = "ReportViewer Sample";
}
}
}
|
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Syncfusion.EJ.ReportViewer;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.AspNetCore.Hosting;
using System.IO;
namespace ReportViewerCore.API
{
public partial class ReportApiController : Controller, IReportController
{
private IMemoryCache _cache;
private IHostingEnvironment _hostingEnvironment;
public ReportApiController(IMemoryCache memoryCache, IHostingEnvironment hostingEnvironment)
{
_cache = memoryCache;
_hostingEnvironment = hostingEnvironment;
}
[HttpPost]
public object PostReportAction([FromBody] Dictionary<string, object> jsonResult)
{
return ReportHelper.ProcessReport(jsonResult, this, this._cache);
}
[ActionName("GetResource")]
[AcceptVerbs("GET")]
public object GetResource(ReportResource resource)
{
return ReportHelper.GetResource(resource, this, _cache);
}
[HttpPost]
public object PostFormReportAction()
{
return ReportHelper.ProcessReport(null, this, this._cache);
}
public void OnInitReportOptions(ReportViewerOptions reportOption)
{
string basePath = _hostingEnvironment.WebRootPath;
FileStream reportStream = new FileStream(basePath + @"\ReportRDL\GroupingAgg.rdl", FileMode.Open, FileAccess.Read);
reportOption.ReportModel.Stream = reportStream;
}
public void OnReportLoaded(ReportViewerOptions reportOption)
{
}
}
}
|