我正在使用JETT来转换一些Excel表格文档。我需要在里面应用条件格式。
这是我在电子表格文档单元格中的代码:
<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>这做得很好,循环Ttered值并将值/formatting插入到每5个单元格中。然而,我需要格式化,例如,每10个单元格的其他方式。所以基本上是另一个IF语句。但是,当我尝试将另一个IF语句放在第一个语句之后时,没有插入/格式化任何内容。这是我尝试过的:
<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>有没有办法在一个jt:forEach循环中使用多个IF语句,或者使用ELSE-IF?
谢谢
发布于 2019-09-20 09:51:12
这很可能是这里已经描述的问题:
https://sourceforge.net/p/jett/tickets/10/
我假设这个问题没有得到解决,所以解决方法是将所有内容(测试和样式)直接写入style="${your code goes here}"中的JEXL代码块中
发布于 2019-09-23 09:23:26
因此,由于上面的工单中提供的解决方法可能会令人困惑,因为它使用了一个无体的脚本标记,下面是一些使用jt:style标记中的逻辑的代码:
<jt:forEach items="${items}" var="item" indexVar="index">
<jt:style style="font-color: ${index % 2 == 0 ? 'red' : 'blue'}">
${item} / ${index}
</jt:style>
</jt:forEach>https://stackoverflow.com/questions/57990860
复制相似问题