open-xml-templating / docxtemplater

Generate docx, pptx, and xlsx from templates (Word, Powerpoint and Excel documents), from Node.js or the browser. Demo: https://www.docxtemplater.com/demo. #docx #office #generator #templating #report #json #generate #generation #template #create #pptx #docx #xlsx #react #vuejs #angularjs #browser #typescript #image #html #table #chart
https://www.docxtemplater.com
Other
3.07k stars 350 forks source link

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

Open virendraworkmail opened 2 years ago

virendraworkmail commented 2 years ago

Environment

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 commented 2 years ago

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.

virendraworkmail commented 2 years ago

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 commented 2 years ago

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