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

The generated docx file is corrupted #552

Open
ching2018 opened this issue Sep 26, 2020 · 4 comments
Open

The generated docx file is corrupted #552

ching2018 opened this issue Sep 26, 2020 · 4 comments

Comments

@ching2018
Copy link

image

{
        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
              }
            ]
          }
        ]
      }

loop-table.docx

@edi9999
Copy link
Member

edi9999 commented Sep 26, 2020

I confirm this corruption in this case.

I don't know yet exactly why it happens, I have to investigate further.

@ching2018
Copy link
Author

Thanks a lot!

@edi9999
Copy link
Member

edi9999 commented Sep 26, 2020

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.

@ching2018
Copy link
Author

#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.

@edi9999 edi9999 changed the title The generated docx file is corrupted。 The generated docx file is corrupted Oct 5, 2020
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