jsReport xlsx Recipe beforeRender
jsReport xlsx Recipe beforeRender
使用来自 mssql 的数据呈现 XLSX 配方时出现此错误
Error occured - Error during rendering report: Cannot read property
'xl/worksheets/sheet1.xml' of undefined Stak - TypeError: Cannot read
property 'xl/worksheets/sheet1.xml' of undefined
at Object.add (evalmachine.:176:42)
at Object. (evalmachine.:406:17)
at Object.eval (eval at createFunctionContext
我已将链接脚本设置为加载数据。示例:
var sql = require('mssql');
var config = {
"user": "jsreport",
"password": "password",
"server": "janblaha-PC\SQLEXPRESS",
"database": "northwind"
}
function beforeRender(done) {
sql.connect(config).then(function() {
var req = new sql.Request();
return req.query('select count(*) as Count, ShipCountry from Orders group by ShipCountry').then(function(recordset) {
request.data = { countries: recordset };
done();
});
}).catch(done);
}
我可以将数据加载到 pdf、html 甚至 html-xlsx 中而不会出现错误。我尝试只使用一个基本的 sheet,我可以在没有脚本的情况下加载它,如下所示。我也尝试过使用 {{#each }}
语句中的数据。我总是得到同样的错误。想知道是否有人尝试过这样做 and/or 如果我需要以不同的方式加载数据。
{{#xlsxAdd "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row"}}
<row>
<c t="inlineStr"><is><t>Hello world</t></is></c>
<c><v>11</v></c>
</row>
{{/xlsxAdd}}
{{{xlsxPrint}}}
在 Github 上收到回复:
//old
request.data = { countries: recordset };
//new
Object.assign(request.data, { countries: recordset })
The recipe is passing some additional data to the templating engines
processing and you are overwriting them.
使用来自 mssql 的数据呈现 XLSX 配方时出现此错误
Error occured - Error during rendering report: Cannot read property 'xl/worksheets/sheet1.xml' of undefined Stak - TypeError: Cannot read property 'xl/worksheets/sheet1.xml' of undefined at Object.add (evalmachine.:176:42) at Object. (evalmachine.:406:17) at Object.eval (eval at createFunctionContext
我已将链接脚本设置为加载数据。示例:
var sql = require('mssql');
var config = {
"user": "jsreport",
"password": "password",
"server": "janblaha-PC\SQLEXPRESS",
"database": "northwind"
}
function beforeRender(done) {
sql.connect(config).then(function() {
var req = new sql.Request();
return req.query('select count(*) as Count, ShipCountry from Orders group by ShipCountry').then(function(recordset) {
request.data = { countries: recordset };
done();
});
}).catch(done);
}
我可以将数据加载到 pdf、html 甚至 html-xlsx 中而不会出现错误。我尝试只使用一个基本的 sheet,我可以在没有脚本的情况下加载它,如下所示。我也尝试过使用 {{#each }}
语句中的数据。我总是得到同样的错误。想知道是否有人尝试过这样做 and/or 如果我需要以不同的方式加载数据。
{{#xlsxAdd "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row"}}
<row>
<c t="inlineStr"><is><t>Hello world</t></is></c>
<c><v>11</v></c>
</row>
{{/xlsxAdd}}
{{{xlsxPrint}}}
在 Github 上收到回复:
//old
request.data = { countries: recordset };
//new
Object.assign(request.data, { countries: recordset })
The recipe is passing some additional data to the templating engines processing and you are overwriting them.