How to display FastReport in Razor Pages
below code i try to display FastReport in Razor Pages
[BindProperty]
public HomeModel model { get; set; }
public IActionResult OnGet(int? reportIndex = 0)
{
model = new HomeModel()
{
WebReport = new WebReport(),
ReportsList = new[]
{
"Simple List"
},
};
var reportToLoad = model.ReportsList[0];
if (reportIndex >= 0 && reportIndex < model.ReportsList.Length)
reportToLoad = model.ReportsList[reportIndex.Value];
var reportPath = System.IO.Path.Combine(_hostingEnvironment.WebRootPath, "Reports");
model.WebReport.Report.Load(System.IO.Path.Combine(reportPath, $"{reportToLoad}.frx"));
var dataSet = new DataSet();
dataSet.ReadXml(System.IO.Path.Combine(reportPath, "nwind.xml"));
model.WebReport.Report.RegisterData(dataSet, "NorthWind");
model.WebReport.Width = "1000";
model.WebReport.Height = "1000";
model.WebReport.Mode = WebReportMode.Preview;
return Page();
}
in View
<div class="webreport">
@await Model.model.WebReport.Render()
</div>