Issue with -horz and -greedy flag when we have nested tables

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)

@dwagh

Cause

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:

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

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

  3. 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:

<table>
    <tr>
        <td>
            <foreach tag="outerLoop" -horz>
                <table>
                    <tr>
                        <td>Outer Row</td>
                    </tr>
                    <tr>
                        <td>
                            <foreach tag="innerLoop" -greedy>
                                <tr>
                                    <td>Inner Row</td>
                                </tr>
                            </foreach>
                        </td>
                    </tr>
                </table>
            </foreach>
        </td>
    </tr>
</table>

Next Steps

  1. Review your template structure and ensure that the foreach tags are correctly placed.
  2. Test the document generation after making adjustments to the flags and table structure.
  3. 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.

As per above comment,
Yes, foreach tag is correctly nested and -horz and -greedy flags are required.
Still we are getting above mentioned error.

@dwagh

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.

The issues you have found earlier (filed as WORDSNET-28465) have been fixed in this Aspose.Words for .NET 25.8 update also available on NuGet.