Xlsx Recipe: add image fail when using a template
It works on empty example but if I upload a template I get an error :
Error while executing templating engine. Cannot read property 'r:id' of undefined. Error on line 270:98.
268 | var drawingFullName
269 | if (this.ctx.root.$xlsxTemplate['xl/worksheets/' + sheetFullName].worksheet.drawing) {
> 270 | var rid = this.ctx.root.$xlsxTemplate['xl/worksheets/' + sheetFullName].worksheet.drawing.$['r:id']
| ^
271 | this.ctx.root.$xlsxTemplate['xl/worksheets/_rels/' + sheetFullName + '.rels'].Relationships.Relationship.forEach(function (r) {
272 | if (r.$.Id === rid) {
273 | drawingFullName = r.$.Target.replace('../drawings/', '')
logs:
+0 Starting rendering request 987 (user: null)
+3 Rendering template { name: excel-image, recipe: xlsx, engine: handlebars, preview: true }
+4 Inline data specified.
+5 Resources not defined for this template.
+11 Base url not specified, skipping its injection.
+11 Rendering engine handlebars
TypeError: Cannot read property 'r:id' of undefined
at Object.ensureDrawingOnSheet (evaluate-template-engine-helpers.js:270:98)
at Object.addImage (evaluate-template-engine-helpers.js:345:48)
at Object.<anonymous> (evaluate-template-engine-helpers.js:429:17)
at Object.eval [as main] (eval at createFunctionContext (/app/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:257:23), <anonymous>:5:89)
at main (/app/node_modules/handlebars/dist/cjs/handlebars/runtime.js:175:32)
at ret (/app/node_modules/handlebars/dist/cjs/handlebars/runtime.js:178:12)
at ret (/app/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:526:21)
at /app/node_modules/jsreport-handlebars/lib/handlebarsEngine.js:33:20
at Object.base.apply (/app/node_modules/vm2/lib/contextify.js:469:32)
at evaluate-template-engine.js:1:64
This error occurs simply by taking the sample code provided by jsreport
for adding images, then creating empty xlsx
file on google drive > download it > upload it as a template and include it in the report.
please refere to this https://playground.jsreport.net/w/anon/nDSs3WAd
Look like I wasn't doing anything wrong but the file format was different from what they expected, the problem will be fixed in next release as they answered in their forum:
https://forum.jsreport.net/topic/1410/xlsx-recipe-add-image-fail-when-using-a-template/5
I will just leave this here for reference...