excelapache-poijxls

JXLS- jx:each with jx:if condition in same comment markup


Using jxls 2.9.0 i have a problem receiving a list in my excel template which is empty or null, so i need to combine a "jx:each" insiede a jx:if markup to evaluate the list, is it possible?

I have in the cell comment markup (to iterate the list):

jx:each(items="myList.items" var="item" lastCell="B3")

In the cell :

${item}

thanks in advance..


Solution

  • By this way i can use for each loop inside an if condition in markups:

        jx:if(condition="myList!=null && !myList.isEmpty()", lastCell="C8", areas=["C4:C4","C8:C8"] )
        jx:each(items="myList" var="item" lastCell="C4")
    

    so, with this condition we avoid scrolling the columns to the left when the list is empty or null. Make sure to put the maximum size that the list could have in the if areas so that the cells do not overlap.

    There is an example that works for me:

    enter image description here

    Result:

    enter image description here