Reputation: 31
I can use varStatus property in jxls 1.X to get the row index while using foreach to traverse a list, But jxls 2.3.0 does not support this, how can output the row index in EXCEL with jxls 2.3.0 ?
Upvotes: 3
Views: 4342
Reputation: 6734
Since JXLS 2.7.0, you can specify varIndex="foo"
in your jx:each
comment, then refer to it as ${foo}
Ref: https://bitbucket.org/leonate/jxls/issues/173/how-can-i-get-index-in-jx-each
Upvotes: 2
Reputation: 11
For JXLS example :jx:each(items="yourList", var="currentValue", lastCell="N7")
You can using ${yourList.indexOf(currentValue)}
to get index.
Upvotes: 1
Reputation: 327
As I understand in current version of JXLS rowStatus doesn't work.
You may use one of these options:
1) You can add row index in index-attribute in your data before place in to JXLS and print in row-template as ${row.index}
2) You can use excel formula like =ROW()-ROW(HEADER_CELL). So if your table-headers end on A4, so in template you need write $[ROW()-ROW(A4)]
Upvotes: 3