docxtemplater
docxtemplater copied to clipboard
The generated docx file is corrupted

{
ACCOUNT_ID: 1699,
ACCOUNT_DETAIL: [
{
CATEGORY: "Cat1",
DETAIL: [
{
TRANS_ID: 1,
DATE_: 930305,
TYPE: "ABC",
AMOUNT: 5224
},
{
TRANS_ID: 2,
DATE_: 930305,
TYPE: "XYZ",
AMOUNT: 2234
}
]
},
{
CATEGORY: "Cat2",
DETAIL: [
{
TRANS_ID: 6,
DATE_: 930114,
TYPE: "ZXC",
AMOUNT: 800
},
{
TRANS_ID: 7,
DATE_: 930114,
TYPE: "ABC",
AMOUNT: 600
}
]
}
]
}
I confirm this corruption in this case.
I don't know yet exactly why it happens, I have to investigate further.
Thanks a lot!
Hello again,
Could you please explain what you would want to have as the output ?
The ACCOUNT_DETAIL loop will create one row for each element of the ACCOUNT_DETAIL array.
The $isLast loop will put either "." or ";", and it will put ";" for almost all ACCOUNT_DETAIL elements except for the last ACCOUNT_DETAIL loop
However, it is not clear to me what you want to achieve with the DETAIL loop.
In docxtemplater, when a loop tag starts in a table cell and ends in another table cell, the loop will be expanded to a table row, which means that it will create a row for each element in the array.
However, with the placement of your tags, it is I think not what you want.
This is still a bug, the docx should not get corrupted, a proper error should be shown if we want to error because this is an invalid usage of loop.
#551 The two problems are the same, and my goal is to merge the cells in the loop. I look forward to seeing you implement this feature soon, and I will buy it. I'm sure that's what many people need.