Xlsx食谱:使用模板时添加图像失败
它适用于空示例,但是如果我上传模板,则会出现错误:
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
仅通过获取jsreport
提供的示例代码来添加图像,然后在Google驱动器上创建空的xlsx
文件,然后下载并上传它作为模板并将其包含在报告中,就会发生此错误
答案 0 :(得分:0)
看起来我没做错任何事,但是文件格式与他们期望的不同,该问题将在下一个版本中得到解决,因为他们在论坛上回答了这个问题:
https://forum.jsreport.net/topic/1410/xlsx-recipe-add-image-fail-when-using-a-template/5
我将在这里留出参考...