Is there any way to pass data to a file based sub-report ?
I have a Report which contains a file link to a sub report, but when I run the report I need to pass in the data to the sub-report, otherwise when I generate the pdf the contents of the sub report are taken from the original report design.
Passing JSON data to a sub report.
-
- Posts: 3
- Joined: Wed Sep 06, 2017 9:01 am
Re: Passing JSON data to a sub report.
Hello,
Sorry, maybe we did not exactly understand your task. Could you explain your issue in more details?
If possible please send us a sample report and test data which reproduces the issue.
Thank you.
Sorry, maybe we did not exactly understand your task. Could you explain your issue in more details?
If possible please send us a sample report and test data which reproduces the issue.
Thank you.
-
- Posts: 3
- Joined: Wed Sep 06, 2017 9:01 am
Re: Passing JSON data to a sub report.
I am in the process of evaluating the JS version of your application but have a problem.
I am running the javascript code below within node.js to automate the creation of a report.
The data for the main report and child report are both placed in JSON format and supplied to report.regData call.
However the steps only seem to result in the parent report picking up the supplied JSON format data and when the pdf file is rendered the child report still has the data used in the creation of the report in the designed and has not picked up the data supplied at run-time.
The child report is
let templatePath = './reports/templates/'
let reportName = `./reports/pdf/${reportData.pdf_file_name}.pdf`;
let report = new sr.Report.StiReport();
let reportTemplateName = `${templatePath}${templateFile}`;
report.loadFile(reportTemplateName);
sr.Base.StiFontCollection.addOpentypeFontFile("c://Windows/Fonts/Calibri.ttf");
report.dictionary.databases.clear();
report.regData('Trades', 'Trades', JSON.stringify(reportData));
report.render();
var pdfData = report.exportDocument(sr.Report.StiExportFormat.Pdf);
let buffer = new Buffer( pdfData, 'utf-8');
fs.writeFile(reportName, buffer, (err) => {
if (err)
{
this.onError(state,`Error writing PDF file ${reportName}.`,err)
}
this.onReportPDFWriteComplete(reportName);
});
I am running the javascript code below within node.js to automate the creation of a report.
The data for the main report and child report are both placed in JSON format and supplied to report.regData call.
However the steps only seem to result in the parent report picking up the supplied JSON format data and when the pdf file is rendered the child report still has the data used in the creation of the report in the designed and has not picked up the data supplied at run-time.
The child report is
let templatePath = './reports/templates/'
let reportName = `./reports/pdf/${reportData.pdf_file_name}.pdf`;
let report = new sr.Report.StiReport();
let reportTemplateName = `${templatePath}${templateFile}`;
report.loadFile(reportTemplateName);
sr.Base.StiFontCollection.addOpentypeFontFile("c://Windows/Fonts/Calibri.ttf");
report.dictionary.databases.clear();
report.regData('Trades', 'Trades', JSON.stringify(reportData));
report.render();
var pdfData = report.exportDocument(sr.Report.StiExportFormat.Pdf);
let buffer = new Buffer( pdfData, 'utf-8');
fs.writeFile(reportName, buffer, (err) => {
if (err)
{
this.onError(state,`Error writing PDF file ${reportName}.`,err)
}
this.onReportPDFWriteComplete(reportName);
});
- Attachments
-
- TradeReport.mrt
- Sample Report
- (25.92 KiB) Downloaded 160 times
Re: Passing JSON data to a sub report.
Hello,
We need some additional time to check the issue with SubReports in Node.JS
We will let you know about the result.
Thank you.
We need some additional time to check the issue with SubReports in Node.JS
We will let you know about the result.
Thank you.
Re: Passing JSON data to a sub report.
Hello,
The issue is fixed.
The fix will be available in the next release 2017.2
Thank you.
The issue is fixed.
The fix will be available in the next release 2017.2
Thank you.
-
- Posts: 3
- Joined: Wed Sep 06, 2017 9:01 am
Re: Passing JSON data to a sub report.
Aleksey,
I've downloaded 2017.2 and retried this, but it seems that the sub-report still does not pick up the JSON data files supplied at run-time.
Is there anything I can try / change in my code which might help ?
Thanks
Nick
I've downloaded 2017.2 and retried this, but it seems that the sub-report still does not pick up the JSON data files supplied at run-time.
Is there anything I can try / change in my code which might help ?
Thanks
Nick
Re: Passing JSON data to a sub report.
Hello,
We couldn't reproduce the issue on our samples.
Please send us a sample project which reproduces the issue for analysis.
Thank you.
We couldn't reproduce the issue on our samples.
Please send us a sample project which reproduces the issue for analysis.
Thank you.