How to get row index in JXLS 2.3.0

旧巷老猫 提交于 2020-12-31 05:57:08

问题


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

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