Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XLSX/Image Module: Images are not correctly injected if the Excel file has several sheets #672

Closed
Pierre-Gilles opened this issue Sep 6, 2022 · 1 comment

Comments

@Pierre-Gilles
Copy link

Environment

  • Version of docxtemplater : 3.31.3
  • docxtemplater-image-module: 3.15.0
  • docxtemplater-xlsx-module: 3.11.2
  • Runner : Node.js

How to reproduce my problem :

My template is the following : multi.zip

With the following js file :

const fs = require("fs");
const path = require("path");

const PizZip = require("pizzip");
const Docxtemplater = require("docxtemplater");
const XlsxModule = require("docxtemplater-xlsx-module");
const ImageModule = require("docxtemplater-image-module");

const imageOpts = {
  centered: true,
  getImage: (tagValue, tagName) => fs.readFileSync(tagValue),
  getSize: (img, tagValue, tagName, options) => [160, 90],
};

const content = fs.readFileSync("multi.xlsx");

const xslxzip = new PizZip(content);
const doc = new Docxtemplater(xslxzip, {
  modules: [new ImageModule(imageOpts), new XlsxModule({})],
});
doc.render({
  image: path.resolve(__dirname, "image.jpg"),
});

const buffer = doc.getZip().generate({
  type: "nodebuffer",
  compression: "DEFLATE",
});

fs.writeFileSync("test.xlsx", buffer);

It should display the image in both sheets, but currently I don't see anything.

If I use a template with only 1 sheet, it works

Any idea what's wrong ?

Thanks for your help 🙏

@edi9999
Copy link
Member

edi9999 commented Sep 6, 2022

Hello @Pierre-Gilles , thanks for your detailed report, it helped to fix this issue quickly.

I have just released version 3.15.1 of the image module which fixes the issue.

@edi9999 edi9999 closed this as completed Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants