0

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

Mirecc41
  • 21
  • 4
  • 2
    I don't know Jett, but you should [edit] the question to show your attempt to "_put another IF statement after first one_"... it _may_ be possible, but you had a mistake in what you tried. – TripeHound Sep 18 '19 at 10:50

2 Answers2

1

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}"

Etienne C
  • 376
  • 4
  • 9
  • Pretty arrogant of them to close it as won't-fix without investigating it properly. I don't understand what it is they think is missing. – user207421 Sep 20 '19 at 04:21
  • I assume that JETT author was very busy at the time and didn't want to rebuild the right spreadsheet that can reproduce the problem. Note that in the ticket description, there's no mention of enclosing tag, and no sample template to reproduce the problem with. JETT is the work of a single author (so far), and he's done a great job. Note that it's very likely that the workaround he provided in the ticket solved the user's problem since they didn't followed-up with more info. It's not arrogant to expect people opening tickets to provide enough info to easily reproduce the problem. – Etienne C Sep 20 '19 at 07:14
  • If it has to do with the `
    ` tag it's not the same problem then, because there isn't one in this question. Make up your mind. If there's something missing fromnthenproblemmrepirt it escapes me. I've been doing product supoort for 43 years, solo and otherwise, and this strikes me as a poor closure.
    – user207421 Sep 21 '19 at 00:50
0

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>
Etienne C
  • 376
  • 4
  • 9