I'm having some issues after upgrading from v2 to v3 involving the xlsx recipe. I am using a setup involving jsreport-core, jsreport-handlebars, and jsreport-assets. The error I'm getting:
Error: Missing helper: "xlsxTableSheet"
at Object.<anonymous> (C:\Projects2\cmd_api\node_modules\handlebars\dist\cjs\handlebars\helpers\helper-missing.js:19:13)
at Object.wrapper (C:\Projects2\cmd_api\node_modules\handlebars\dist\cjs\handlebars\internal\wrapHelper.js:15:19)
at eval (eval at compile (C:\Projects2\cmd_api\node_modules@jsreport\jsreport-handlebars\lib\handlebarsEngine.js:35:30), <anonymous>:11:133)
at Object.main (eval at compile (C:\Projects2\cmd_api\node_modules@jsreport\jsreport-handlebars\lib\handlebarsEngine.js:35:30), <anonymous>:19:4)
at C:\Projects2\cmd_api\node_modules@jsreport\jsreport-handlebars\async-helpers\index.js:61:22
at ret (C:\Projects2\cmd_api\node_modules\handlebars\dist\cjs\handlebars\runtime.js:212:12)
at Object.execute (C:\Projects2\cmd_api\node_modules@jsreport\jsreport-handlebars\lib\handlebarsEngine.js:80:14)
at Object.execute (C:\Projects2\cmd_api\node_modules@jsreport\jsreport-handlebars\lib\worker.js:27:43)
at executionFn (C:\Projects2\cmd_api\node_modules@jsreport\jsreport-core\lib\worker\render\executeEngine.js:216:40)
at sandbox.js:16:18
I've looked around on the forums/github/stackoverflow and have run out of potential solutions, but have garnered a better understanding of what may be causing the issue. Before rendering the template object with jsreport, it looks like this:
{
engine: 'handlebars',
recipe: 'xlsx',
content: '{{!-- Resize and fill table --}}\r\n' +
'{{xlsxTableSheet "Data" headers rows}}\r\n' +
'{{xlsxWrapText}}\r\n' +
'\r\n' +
'{{!-- Enforces recalculation of formula cells when file is opened --}}\r\n' +
'{{xlsxCalcOnLoad 1}}\r\n' +
'\r\n' +
'{{!-- Generates the spreadsheet --}}\r\n' +
'{{{xlsxPrint}}}\r\n',
helpers: ';(function (global) {\r\n' +
'\r\n' +
" const path = require('path');\r\n" +
' require(path.resolve(__rootDirectory, "reports/helpers/xlsx"))(global);\r\n' +
' require(path.resolve(__rootDirectory, "reports/helpers/math"))(global);\r\n' +
' require(path.resolve(__rootDirectory, "reports/helpers/util"))(global);\r\n' +
'\r\n' +
' // additional functions\r\n' +
'\r\n' +
' Object.assign(global, {\r\n' +
' // additional functions\r\n' +
' });\r\n' +
' \r\n' +
'})(this);',
xlsx: { templateAsset: [Object] }
}
When I tried hard coding the helpers instead of requiring them as I am above it worked correctly, leading me to believe that the render function is having trouble parsing the 'require' statements within the imported file. The helper files listed have a rough structure as follows:
module.exports = function (global) {
....functions listed here
Object.assign(global, {
functions aliased here
}
This worked previously with v2, I have already verified that handlebars versions are synced correctly between packages, I am using the newer packages with @jsreport/jsreport-core, and I've run out of ideas on how to move forward with this issue. Thanks for any help.