Nested foreach does not Print the Data using Java | LINQ Reporting

version : aspose-words-21.1-jdk17.jar

Hi~

There is each list.

#TABLE1

ID TITLE
T00001 TEST LIST 1
T00002 TEST LIST 2

#TABLE2

ID SEQ AMT2
T00001 1 TEST LIST 1 DETAIL 1
T00001 2 TEST LIST 1 DETAIL 2
T00002 1 TEST LIST 2 DETAIL 1
T00002 2 TEST LIST 2 DETAIL 2

I’d like to print out 2 lists using foreach.

<<foreach [T1 in TABLE1]>>

ID SEQ AMT2
<<foreach [T2 in TABLE2]>><<[T2.ID]>> <<[T2.SEQ]>> <<[T2.TITLE]>><</foreach>>

<</foreach>>

However, the TABLE2 does not print.
Is there anything I can do?

TEST.ZIP (19.6 KB)

@hks

You are using nested foreach tag for ‘TABLE1’ and ‘TABLE2’ in template document. The JSON data source must contains the nested TABLE data source. Please use the following JSON string for nested foreach template to get the desired output.

String jsonData = "{\"TITLE\":\"Test\",\n" +
        "\n" +
        "\"TABLE1\":\n" +
        "[\n" +
        " {\"ID\":\"T00001\", \"TITLE\":\"TEST LIST 1\",\n" +
        "\"TABLE2\":[{\"ID\":\"T00001\", \"SEQ\":1, \"TITLE\":\"TEST LIST 1 DETAIL 1\"},{\"ID\":\"T00001\", \"SEQ\":2, \"TITLE\":\"TEST LIST 1 DETAIL 2\"},{\"ID\":\"T00002\", \"SEQ\":1, \"TITLE\":\"TEST LIST 2 DETAIL 1\"},{\"ID\":\"T00002\", \"SEQ\":2, \"TITLE\":\"TEST LIST 2 DETAIL 2\"}]\n" +
        "},\n" +
        "\n" +
        " {\"ID\":\"T00002\", \"TITLE\":\"TEST LIST 2\",\n" +
        "\n" +
        "\"TABLE2\":[{\"ID\":\"T00001\", \"SEQ\":1, \"TITLE\":\"TEST LIST 1 DETAIL 1\"},{\"ID\":\"T00001\", \"SEQ\":2, \"TITLE\":\"TEST LIST 1 DETAIL 2\"},{\"ID\":\"T00002\", \"SEQ\":1, \"TITLE\":\"TEST LIST 2 DETAIL 1\"},{\"ID\":\"T00002\", \"SEQ\":2, \"TITLE\":\"TEST LIST 2 DETAIL 2\"}]\n" +
        "}\n" +
        "]\n" +
        "}";

Please note that this JSON data source does not work for second table in the document. You need to use the data source according to template document.