[英]How to find a specific string in 1 or 2 sheets of a excel file using Apache POI?
I need to find an specific string (id, name for example) in 1 sheet of excel. 我需要在1张Excel中找到特定的字符串(例如ID,名称)。 this is a basic need.
这是基本需求。
Later on we need to find a user on several excel sheets and copy the whole record identified with that code and send it to a JTable
in the frame. 稍后,我们需要在几个excel工作表上找到一个用户,然后复制用该代码标识的整个记录,并将其发送到框架中的
JTable
。
Are you looking for a high-level search function or something? 您是否正在寻找高级搜索功能? I don't think that exists.
我认为那不存在。
As you load the sheets, you might consider just adding the interesting columns to a HashMap if you can use exact matches, otherwise just iterate over the sheets/columns/rows and search manually. 加载工作表时,如果可以使用完全匹配项,则可以考虑仅将有趣的列添加到HashMap中,否则只需遍历工作表/列/行并手动搜索即可。
You could create some mid-level tooling to do this. 您可以创建一些中级工具来执行此操作。 A "Sheet Indexer" perhaps, that takes a sheet and a list of columns then lets you do lookups.
也许是一个“ Sheet Indexer”,它需要一张工作表和一列列,然后您才能进行查找。 Even if you have to write code to iterate over everything manually you shouldn't worry too much about speed--the number of sheets/rows are very unlikely to get large enough to effect performance or anything.
即使您必须编写代码来手动遍历所有内容,也不必担心速度-纸页/行的数量不太可能太大而影响性能或其他任何方面。
We actually have a lot of tooling built around poi including a ORM layer that lets us load from spreadsheets using annotations just like hibernate. 实际上,我们有很多围绕poi构建的工具,包括一个ORM层,该层使我们可以像休眠一样使用注释从电子表格加载。 We called it "son of poi" aka "poison".
我们称其为“ poi之子”,又称“毒药”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.