How do I supress/hide a row in jxls2?

醉酒当歌 提交于 2021-01-28 12:05:00

问题


I'm trying to hide (not generate) a row, if a condition is false. By now I'm always getting an empty row:

A1: Value: EMPTY

A1: Comment: jx:area(lastCell="B4")

A2: Value: SOME PRINT OUT

A2: Comment: jx:each(items="myList",var="myItem",lastCell="B3")

A3: Value: SOME CONDITIONAL PRINT OUT

A3: Comment:
jx:if(condition="myItem.hasSubItems == true", lastCell="B3", areas=["A3:B3"])
jx:each(items="myItem.subItems", var="subItem", lastCell="B3")

I don't want row3 to be generated, if myItem has no subItems

How can I achieve this?


回答1:


Actually jx:each should not generate a row if the underlying collection is empty.

So in your case it should work even without jx:if tag.

But in a case when you need to apply some other condition your jx:if tag may look like this

jx:if(condition="YOUR CONDITION" lastCell="B3" areas=["A3:B3"])



回答2:


try this code to hide rows :

CellView cellView = new CellView(); cellView.setHidden(true); //set hidden

sheet.setRowView(0, cellView);
sheet.setRowView(2, cellView);
sheet.setRowView(4, cellView);


来源:https://stackoverflow.com/questions/33995039/how-do-i-supress-hide-a-row-in-jxls2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!