docxtemplater icon indicating copy to clipboard operation
docxtemplater copied to clipboard

XLSX Module - how to loop in excel repeating a row, but only for a given set of columns ?

Open virendraworkmail opened this issue 2 years ago • 3 comments

Environment

  • Version of docxtemplater : 3.29.0
  • Used docxtemplater-modules : docxtemplater-xlsx-module (V 3.9.3)
  • Runner : Node.JS - (16.13.0), NPM - (8.1.0)

How to reproduce my problem :

My template is the following : (Upload the docx file here inside github, which you have to name template.zip (github doesn't accept the docx extension))

With the following js file :

const fs = require('fs');
const Docxtemplater = require('docxtemplater');

const content = fs
    .readFileSync(__dirname + "/template.zip", "binary");

const zip = new PizZip(content);
const doc = new Docxtemplater(zip)

doc.render({
	items: [{
            name: "First product",
            quantity: 1,
            unit_price: { type: "currency", value: 200 },
        },
        {
            name: "Other product",
            quantity: 3,
            unit_price: { type: "currency", value: 100 },
        }, {
            name: "Third product",
            quantity: 3,
            unit_price: { type: "currency", value: 100 },
        },
    ]
});

const buf = doc.getZip()
             .generate({type:"nodebuffer"});

fs.writeFileSync(__dirname+"/output.docx",buf);

Generated Output - gen_demo.xlsx

Used Template demo_template.xlsx

I would expect it to :

it should not repeate the whole row. As I have other tables side by side.

virendraworkmail avatar Apr 12 '22 10:04 virendraworkmail

Hello Virendra,

I'm Sorry for the late response.

Currently, there is no way to loop over rows but only on specific columns.

It would be possible to create a new tag, like this : {$} which would mean that a particular cell should not be repeated.

So in your case of the uploaded template, the cell should be : {$} This should not repeate

However, this tag : {$} should then be placed on each of the "static" cells.

You are speaking about having multiple tables side-by-side, and the {$} would not handle this case.

edi9999 avatar Apr 14 '22 10:04 edi9999

Hi Edgar,

Thanks for the information but we are not willing to use the module. Please process the refund. I also sent an email to you but did not get any reply. So commenting in here.

Thanks.

virendraworkmail avatar Apr 21 '22 10:04 virendraworkmail

Hello Virendra,

I'm sorry for the late reply, the refund was processed and should appear in your bank account when Stripe sends the money.

Best,

Edgar

edi9999 avatar Apr 22 '22 09:04 edi9999