Apache的POI - 提取列中的所有不同的值 [英] Apache POI - Extracting all different values in a column

查看:126
本文介绍了Apache的POI - 提取列中的所有不同的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个看起来像这样的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

我要提取以下信息

I want to extract following information


  1. 所有不同的人的名称(在第3列,在这种情况下 - 约翰,马克和贝蒂)

  1. Names of all the different people (in column 3, in this case - John, Mark and Betty).

几张票,一个人是如何a.Open b.Working c.Pending。 (EG - 约翰,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.

定义你的比较和散列$针对名称区分C $ C方法 - 第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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆