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 Module - how to loop in excel repeating a row, but only for a given set of columns ? #646

Open
virendraworkmail opened this issue Apr 12, 2022 · 3 comments

Comments

@virendraworkmail
Copy link

virendraworkmail commented Apr 12, 2022

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.

@edi9999
Copy link
Member

edi9999 commented Apr 14, 2022

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 edi9999 changed the title Docxtemplater XLSX Module - Loop in excel repeating whole row Docxtemplater XLSX Module - how to loop in excel repeating a row, but only for a given set of columns ? Apr 14, 2022
@edi9999 edi9999 changed the title Docxtemplater XLSX Module - how to loop in excel repeating a row, but only for a given set of columns ? XLSX Module - how to loop in excel repeating a row, but only for a given set of columns ? Apr 14, 2022
@virendraworkmail
Copy link
Author

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.

@edi9999
Copy link
Member

edi9999 commented Apr 22, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants