【问题标题】:jsreport - handlebars - Xlsx Recipe: add image fail when using a templatejsreport - 车把 - Xlsx 配方:使用模板时添加图像失败
【发布时间】:2020-01-14 23:29:58
【问题描述】:

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提供的示例代码添加图像,然后在谷歌驱动器上创建空的xlsx文件>下载它>作为模板上传并包含在报告中。

请参考这个https://playground.jsreport.net/w/anon/nDSs3WAd

【问题讨论】:

    标签: excel image handlebars.js xlsx jsreport


    【解决方案1】:

    看起来我没有做错任何事情,但文件格式与他们预期的不同,问题将在下一个版本中修复,因为他们在论坛中回答:

    https://forum.jsreport.net/topic/1410/xlsx-recipe-add-image-fail-when-using-a-template/5

    我将把它留在这里以供参考......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多