问题
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