Hi Team,
I have a template in which table with single row and single cell.
In that table there is foreach tag and inside that foreach tag there is a -horz flag
and inside that table there is another table with 3 rows and in middle row there is a foreach loop with -greedy tag.
When I generate the document it throws the error -
System.InvalidOperationException: ‘Tag ‘foreach’ is not well-formed. Child placeholders of a data band or conditional block affecting table columns cannot capture a whole row.’
Below have attached the zip file which contains aspose syntax template and sample code.
I am from Conga organisation and we have a paid license as well. Table_Issue.7z (13.7 KB)
The error you’re encountering, System.InvalidOperationException: 'Tag 'foreach' is not well-formed. Child placeholders of a data band or conditional block affecting table columns cannot capture a whole row,' typically arises when the structure of your nested tables and the use of the -horz and -greedy flags are not compatible. Specifically, the foreach tag inside a nested table may be conflicting with the outer table’s structure.
Solution
To resolve this issue, ensure that the foreach tags are correctly nested and that the flags are applied appropriately. Here are some steps to consider:
Check Table Structure: Make sure that the outer table can accommodate the inner table without causing conflicts. The -greedy flag should be used in a way that it does not interfere with the layout of the outer table.
Adjust Flags: If the inner foreach loop is meant to generate multiple rows, consider whether the -greedy flag is necessary. Test removing it to see if that resolves the issue.
Simplify Nested Tables: If possible, simplify the structure of your nested tables. Reducing complexity can help avoid such errors.
Code
Here’s a simplified example of how you might structure your tables:
Review your template structure and ensure that the foreach tags are correctly placed.
Test the document generation after making adjustments to the flags and table structure.
If the issue persists, isolate the problem by creating a minimal version of your template to identify the conflicting elements.
Please implement these changes and let me know if they resolve the issue. If you have further questions or need additional assistance, feel free to ask.
For the sake of analysis and possible correction, we have opened the following new ticket(s) in our internal issue tracking system and will work on them according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-28465
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.