antonmihaylov / OpenXmlTemplates

Word .docx templating system that is designer (no scripting tags) and server-friendly (no word installation required)
GNU Lesser General Public License v3.0
92 stars 25 forks source link

Issues with populating Complex Repeating Fields from an JSON Array #50

Open SergeyFM opened 6 months ago

SergeyFM commented 6 months ago

The problem occurs in the RepeatingControlTests within Tests.cs. When attempting to populate the document, data from data.json does not fill the fields as expected; instead, only new empty lines are added. This issue specifically affects the complexItems array.

Here's the JSON data from the test:

  "complexItems": [
    {
      "name": "First Name",
      "address": "First Address"
    },
    {
      "name": "Second name",
      "address": "Second address"
    }
  ]

The template contains:

Complex, Legacy (using repeatingitem):
Name: Click or tap here to enter text.,  Address: Click or tap here to enter text.

However, the resulting document contains two rows with no data:

Complex, Legacy (using repeatingitem):
Name: Click or tap here to enter text.,  Address: Click or tap here to enter text., 
Name: Click or tap here to enter text.,  Address: Click or tap here to enter text.

I am investigating this behavior to identify the underlying cause. Additionally, I would like to ask the team: Does this issue occur only in my setup, or has anyone else encountered similar problems with the complexItems array?

I will provide updates as I progress and plan to submit a pull request once the issue is resolved. Any input from the team is appreciated.