I found some bits of code from long ago but still can't figure it out.
Any up to date clear code You could give me ? I am using Angular/.NET core 5.0.
I am putting the report in the wwwroot and setting to copy always so the report seems to be there. The report has no parameters.
I get the error below
[HttpGet] //https://localhost:44374/reports/testreport public string TestReport() { string webRootPath = _webHostEnvironment.WebRootPath; var rptName = Path.Combine(webRootPath, "Reports\\AllForms.trdp"); var report = new Telerik.Reporting.Report { DocumentName = rptName }; var instanceReportSource = new InstanceReportSource { ReportDocument = report }; var reportProcessor = new ReportProcessor(); var result = reportProcessor.RenderReport("PDF", instanceReportSource, new Hashtable()); return "xxx"; }
The current data set presented in the report did not produce any significant content, so no pages were generated. If you need to see the whole report content, including blank pages, please contact the report author.
var report = new Telerik.Reporting.Report { DocumentName = rptName }; var instanceReportSource = new InstanceReportSource { ReportDocument = report };
Think your problem is in these 2 lines. If I understand it correctly, the first line is creating a blank report and giving that name. The name you give it has no meaning on what file is opened. In fact you are not opening a file, but just creating a new report in memory.
You need to use Telerik.Reporting.UriReportSource
I will give you a couple of the key lines from my code as I actually have pretty much your scenario already
var uriReportSource = new Telerik.Reporting.UriReportSource(); // Specifying an URL or a file path uriReportSource.Uri = reportsPath + "/Storage.trdp"; uriReportSource.Parameters.Clear(); uriReportSource.Parameters.Add("CustomerId", cust.Id); var result = processor.RenderReport("PDF", uriReportSource, deviceInfo); MemoryStream memStream = new MemoryStream(result.DocumentBytes); System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(memStream, "Storage.pdf");