Reputation: 21
I am using JETT to transform some Excel sheet documents. I need to apply conditional formatting inside .
This is my code inside spreadsheet document cell:
<jt:forEach items="${getValues()}" var="item" indexVar="index" copyRight="true">
<jt:if test="${index%5 == 0}">
<jt:style style="border-left: medium">
${index}, ${item}
</jt:style>
</jt:if>
</jt:forEach>
This does well, loops trought values and inserting value/formatting into every 5th cell. However I need to format for example every 10th cell in other way. So basically another IF statement. But when i tried to put another IF statement after first one, nothing gets inserted/formatted. This is what i have tried:
<jt:forEach items="${getValues()}" var="item" indexVar="index" copyRight="true">
<jt:if test="${index%5 == 0}">
<jt:style style="border-left: medium">
${index}, ${item}
</jt:style>
</jt:if>
<jt:if test="${index == 14}">
<jt:style style="border-right: medium">
${index}, ${item}
</jt:style>
</jt:if>
</jt:forEach>
Any way to use multiple IF statements in one jt:forEach loop or something as ELSE-IF?
Thanks
Upvotes: 0
Views: 646
Reputation: 376
So, since the workaround provided in the ticket above can be confusing as it's using a bodyless script tag, here's some code that works with the logic in the jt:style
tag:
<jt:forEach items="${items}" var="item" indexVar="index">
<jt:style style="font-color: ${index % 2 == 0 ? 'red' : 'blue'}">
${item} / ${index}
</jt:style>
</jt:forEach>
Upvotes: 0
Reputation: 376
This is likely the issue already described here:
https://sourceforge.net/p/jett/tickets/10/
I assume this issue is not fixed, so the workaround is to write everything (test & styling) in a JEXL code block directly in the style="${your code goes here}"
Upvotes: 1