Apache POI - 提取列中的所有不同值 [英] Apache POI - Extracting all different values in a column
问题描述
我有一个像这样的 excel 文件 -
I have an excel file that look like this -
Ticket # Status Person
1. Open John
2. Working Mark
3. Pending Betty
4. Working Mark
5. Open Mark
6. Open John
7. Pending Betty
8. Working John
9. Working Mark
10. Pending Betty
我想提取以下信息
所有不同人员的姓名(在第 3 列中,在本例中为 John、Mark 和 Betty).
Names of all the different people (in column 3, in this case - John, Mark and Betty).
一个人有多少票a.Open b.Working c.Pending.(例如 - 对于 John,有 2 个工单处于打开状态,1 个在工作中,0 个在等待中).
How many tickets for a person are a.Open b.Working c.Pending. (Eg - For John, 2 tickets are open, 1 is working and 0 is pending).
我正在使用 Apache POI,请建议我如何获取上述信息.
I am using Apache POI, please suggest, how I can get the above mentioned information.
推荐答案
如果你想要一个数据结构的所有唯一成员,你可以使用 TreeSet,完全用于此目的,即:
If you want all the unique members of a data structure, you use a TreeSet, which is wholly intended for that purpose, to wit:
A collection that contains no duplicate elements. The elements are ordered using their
natural ordering, or by a Comparator provided at set creation time, depending on
which constructor is used.
定义您的Comparator 和 hashCode 方法这在名称上有所不同 - 第 3 列,它会做你想做的事.
Define your Comparator and hashCode method that differentiates on name -- the 3rd column and it will do what you'd like.
这篇关于Apache POI - 提取列中的所有不同值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!