问题
Stimulsoft report:
How can I render the report with its variables and parameters in asp.net core and show it in angular?
Angular:
viewer: any = new Stimulsoft.Viewer.StiViewer(null, 'StiViewer', false);
report: any = new Stimulsoft.Report.StiReport();
this.report.load("the report get from my api"); // ???
this.viewer.report = this.report;
this.viewer.renderHtml('viewer');
Asp.net core:
public async Task<IActionResult> GetReport()
{
StiReport report = new StiReport();
report.Load(@"D:\myreport.mrt"); // for example load it from local
// set parameters and variables here.it's ok
// this return does not prepare report for showing in angular.It uses for view of action
return StiNetCoreViewer.GetReportResult(this, report);
}
How do I prepare report in this method for showing correctly in angular?
回答1:
Asp.net core:
public async Task<IActionResult> GetReport()
{
StiReport report = new StiReport();
report.Load(@"D:\myreport.mrt");
// set parameters and variables here.it's ok
// render the report
report.Render(false);
return report.SaveDocumentJsonToString();
// OR return report.SaveDocumentToString();
}
So we use the result of GetReport method into component
Angular component:
this.report.load("result of GetReport method");
回答2:
Have you tried to build the same example:
https://www.stimulsoft.com/en/documentation/online/programming-manual/reports_js_binding_data.htm.
Update:
I did something like this before, what I go to is to let the client open a popup window requesting a specific MVC action that will generate the report.
Another idea is to generate the PDF and use a PDF viewer on the client to show what you already generated.
来源:https://stackoverflow.com/questions/54087229/stimulsoft-how-to-render-report-in-asp-net-core-and-show-it-in-angular