Multi-row "foreach" crashes

Hello. There is a crash NullPointerException when trying to generate two rows using “foreach” via template and second row contains Aspose tag.
Everything is ok when Aspose tag in second row gets replaced with some constant text.

Sample attached.
HtmlTableCrash.zip (10.7 KB)

@zuzuzu

Please use the <</foreach>> in new row as shown below to avoid this exception.

String html = ("<table>\n" +
        "<tr>\n" +
        "  <td><<foreach [car in cars]>><<[car.p1]>></td>\n" +
        "  <td><<[car.p2]>></td>\n" +
        "</tr>\n" +
        "<tr>\n" +
        "  <td colspan='2'>" + crashCause + "</td>\n" +
        "</tr>\n" +
        "<tr>\n" +
        "  <td colspan='2'><</foreach>></td>\n" +
        "</tr>\n" +
        "</table>")
        // escape Aspose tags in HTML
        .replaceAll("<<", "&lt;&lt;")
        .replaceAll(">>", "&gt;&gt;");

Thanks a lot, that helped to avoid the crash. Unfortunately, it adds extra row at the bottom of the table (please see attached image). Our design requires borders around table cells so this extra row becomes visible. Is there a way to remove the extra row?
Extra-row.jpg (5.7 KB)

@zuzuzu

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-18741. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@zuzuzu

The fix of this issue will be available in the next version of Aspose.Words i.e. 19.7. We suggest you please check the greedy switch from the following article.
Working with Table-Row Data Bands

After the fix of this issue, you need to use greedy switch for closing tag of foreach in your template document as shown below.

<</foreach -greedy>>

1 Like

The issues you have found earlier (filed as WORDSNET-18741) have been fixed in this Aspose.Words for .NET 19.7 update and this Aspose.Words for Java 19.7 update.