I'm wondering if there is any tool/library that would fill Java objects with data from Excel spreadsheet.
My idea is like you have an Excel spreadsheet that has first line that contains column names with mirroring names of field in target Java object. All other lines are data, so the library would take the class used for instantiation of objects and fill the list with as many instances as there are lines in Excel file.
Is there something like this around?
You will have to code your own utility for doing this task. There are helpful libraries out there:
- Apache POI - http://poi.apache.org/spreadsheet/index.html
- JExcel API - http://www.andykhan.com/jexcelapi/tutorial.html
Apache POI can be used to extract data from an Excel sheet and Apache Commons Beanutils helps you writing this values into Java Objects.
I have used both
And found jexcel is better. jexcel will provide you some fine control over reading/writing to excel which is not available through poi.
If you don't want to write your own solution, or you need to load more comlicated data than a simple table, you may want to use Data tables from OpenL Tablets from [http://openl-tablets.sourceforge.net/][1] . It is based on Apache POI and works with both .xls and .xlsx files.
I found these libraries that do what you ask:
- Chicken Excel
- Excel Pojo
- Excel2Objects
We make use of Poiji to map excel rows to Java objects