简体   繁体   English

apache poi-将Pojo列表转换为HSSFSheet的任何方法?

[英]apache poi - any way to convert a list of Pojo to HSSFSheet?

Would be a pretty awesome feature in apache POI HSSFBeanHelper.toHssfSheet(HSSFWorkbook workbook, List<Object> obj) that would create a HSSFSheet from a list of Pojo. apache POI HSSFBeanHelper.toHssfSheet(HSSFWorkbook workbook, List<Object> obj)中的一个很棒的功能,它将根据Pojo列表创建一个HSSFSheet。

Does it exist? 是否存在?

There are two API's that both sit on top of POI that provide kind-of the functionality you suggest: 在POI之上都有两个API,它们提供您建议的某种功能:

Both libraries are extremely similar, on the JETT website there's even a handy comparison table 这两个库非常相似,在JETT网站上甚至有一个方便的比较表

Both take an Excel file as a template and will fill it up with variables you provide (and these variables can include one or more lists of objects). 两者都将Excel文件作为模板,并将用您提供的变量填充该文件(这些变量可以包含一个或多个对象列表)。 So, creating a spreadsheet from a list of POJO's is very simple, but it's equally easy to provide Excel formulas that will be executed using the filled in data, and even charts and for me that's the real power of these libraries. 因此,从POJO列表中创建电子表格非常简单,但是提供将使用填充数据甚至图表执行的Excel公式也同样容易,对我来说,这就是这些库的真正功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM