Excelutils gets the current index when iterating through the collection

Source: Internet
Author: User
Tags arithmetic operators

The official documents about Excelutils are here http://excelutils.sourceforge.net/ Userguide.html, it is a good way to export excel with POI and struts2, we do not need to generate Excel document through the POI API code, just need to create a new Excel document, and then through some syntax to take out the background pass over the value, this tool is really simple, easy to use.

However, today in the Excel export, you need to output the line number of each line, to get this problem, naturally want to go to the official website to find, but in the official website only find the index to remove the traversal (starting from 0), but I need to output serial number from 1, I whimsical with arithmetic operators plus 1 (that is, ${rowid+1}), Unfortunately Excelutils does not support this operation, if excelutils support this operation is good ( if who knows how to do this operation, but also trouble to tell me, the younger brother first here first thanks ).

For example, we wrote in Excel that:

#foreach row in ${userlist}${row.username} ${row.nickname} ${row.lastloginip} #end

If you want to remove the current index from the beginning of 0, you can write ${rowid}, to remove the index starting from 1, you can write ${rowindex}, note: The ID or the row before index is the identity name of the current object, that is #foreach row in ${ UserList} inside the row.


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Excelutils gets the current index when iterating through the collection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.