Step1 : Install NuGet
– AspNetCore.Reporting
– System.CodeDom
– System.Security.Permissions
Step2 : Create Project in Solution
– name “RDLCDesign” and select template “Windows Form App”
Step3 : New “Report1.rdlc” in RDLCDesign project and copy to Web project > wwwroot
Step4 : Controller file
...
public class HomeController : Controller
{
private readonly IWebHostEnvironment _webHostEnvironment;
public HomeController(IWebHostEnvironment webHostEnvironment)
{
_webHostEnvironment = webHostEnvironment;
}
...
public IActionResult RptSalesPerformanceByMarketTypeExportPdf()
{
string mimetype = "";
int extension = 1;
var path = $"{this._webHostEnvironment.WebRootPath}\\reports\\Report1.rdlc";
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("name", "RDLC Report");
LocalReport localReport = new LocalReport(path);
var result = localReport.Execute(RenderType.Pdf, extension, parameters, mimetype);
return File(result.MainStream, "application/pdf");
}
...
}
Recent Comments