how to dynamically create excel columns using xlsx recipe and handlebars
-
Hi,
I have an array of objects where object keys are not fixed and are dynamic. I want to create an excel sheet using xlsx recipe to dynamically create columns of a row. I do see example for creating rows as we iterate an array. Please create an example for creating columns dynamically.I tried with code like this which fails.
{{#each transactions}} {{#xlsxAdd "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row"}} <row> {{#each this}} {{#xlsxAdd "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row[1].c"}} <c t="inlineStr"><is><t>{{@key}}</t></is></c> {{/xlsxAdd}} {{/each}} </row> {{/xlsxAdd}} {{/each}}
Thank you,
Rashmi
-
hi, can you show us what you have tried so far in a playground url? it will help to know your base xlsx template and the data that you have.
-
https://playground.jsreport.net/studio/workspace/rymqIRXiG/3
Right now, row 1 should print the keys of object as header and row 2 should have the values.
Eventually I want to have one row of header.Thanks,
Rashmi
-
ok, i think this example can give you an idea how to make it work for more complex cases https://playground.jsreport.net/studio/workspace/rymqIRXiG/10
hope it helps.
-
Thank you bjrmatos. It really helped. Truly appreciate your help.