Page 1 of 1
Run Report from NodeJS Backend
Posted: Wed Jun 27, 2018 1:23 pm
by jclPTSG
So looking at Several Examples i still cannot grasp how to load a report from server side of a Node js application.
Could you please show an example?
I do know from example 6.
Code: Select all
// Creating new report
var report = new Stimulsoft.Report.StiReport();
// Loading report template
report.loadFile("report/SimpleList.mrt");
// Renreding report
report.render();
// Saving rendered report to JSON string
var reportJson = report.saveDocumentToJsonString();
Does not load the mySQL data.
Also from example 5.
Code: Select all
var dataSet = new Stimulsoft.System.Data.DataSet("Demo");
// Load JSON data file from specified URL to the DataSet object
dataSet.readJsonFile("Demo.json");
// Remove all connections from the report template
report.dictionary.databases.clear();
// Register DataSet object
report.regData("Demo", "Demo", dataSet);
this will load data, but why do i have to delete the connection and re-add it? the connection string/query/fields are already in the mrt file.
any help will be nice.
Re: Run Report from NodeJS Backend
Posted: Sat Jun 30, 2018 9:05 pm
by HighAley
Hello.
The MySQL adapter is working in an async mode.
Please, try next code:
Code: Select all
var report = new Stimulsoft.Report.StiReport();
report.loadFile("report/WorkOrder.mrt");
report.renderAsync(function(){
var reportJson = report.saveDocumentToJsonString();
res.end(reportJson);
});
Thank you.
Re: Run Report from NodeJS Backend
Posted: Thu Jul 12, 2018 6:04 pm
by jclPTSG
Sorry to say, but that still does not help.
From the previous post, there is no code that calleds the MySQL Adapter.
do you have a sample that you could show me that loads a report (in Node.js) that queries a mysql database and saves the report as a PDF?
that would help out alot.
Re: Run Report from NodeJS Backend
Posted: Fri Jul 13, 2018 3:51 am
by cucr
i have same problem,when i use render,i can not get data from the mrt file define.(i have define connection string in mrt file,connection test ok,when i preview,it can get data from database),but i use nodejs as backend,it can not get data from database.
when i use renderAsync to export pdf,pdf is exported,but when i open it,it show this file is broken and can not open.
report.renderAsync(function() {
// Export to PDF
var pdfData = report.exportDocument(Stimulsoft.Report.StiExportFormat.Pdf);
// Converting Array into buffer
var buffer = new Buffer(pdfData, "utf-8")
// File System module
var fs = require('fs');
// Saving string with rendered report in PDF into a file
fs.writeFileSync('report/SimpleList.pdf', buffer);
console.log("Rendered report saved into PDF-file.");
});
Re: Run Report from NodeJS Backend
Posted: Mon Jul 16, 2018 8:10 am
by Lech Kulikowski
Hello,
Please check samples at the following link:
https://github.com/stimulsoft/Samples-J ... er/Node.js
Thank you.
Re: Run Report from NodeJS Backend
Posted: Mon Jul 23, 2018 3:12 pm
by jclPTSG
Please see my first post on this.
The code that i posted came from those samples.
Re: Run Report from NodeJS Backend
Posted: Tue Jul 24, 2018 11:06 pm
by Lech Kulikowski
Hello,
Please check the following article:
https://www.stimulsoft.com/en/documenta ... tabase.htm
Thank you.
Re: Run Report from NodeJS Backend
Posted: Tue Jul 31, 2018 12:38 pm
by jclPTSG
SO how do i use:
In Nodejs when i use:
Code: Select all
var Stimulsoft = require("stimulsoft-reports-js");
Re: Run Report from NodeJS Backend
Posted: Thu Aug 02, 2018 2:07 pm
by Lech Kulikowski
Hello,
In NodeJS samples, there is sample "04. Start SQL Adapters from Http Server", please check it.
Thank you.