3

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 ?

Duo
  • 31
  • 1
  • 4

4 Answers4

3

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)]

inem88
  • 327
  • 3
  • 15
1

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

seanf
  • 6,504
  • 3
  • 42
  • 52
0

For JXLS example :jx:each(items="yourList", var="currentValue", lastCell="N7") You can using ${yourList.indexOf(currentValue)} to get index.

0

use ROW()-ROW(HEADER_CELL) works,