问题
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 ?
回答1:
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)]
回答2:
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
回答3:
For JXLS example :jx:each(items="yourList", var="currentValue", lastCell="N7")
You can using ${yourList.indexOf(currentValue)}
to get index.
回答4:
use ROW()-ROW(HEADER_CELL) works,
来源:https://stackoverflow.com/questions/39485103/how-to-get-row-index-in-jxls-2-3-0