I need some help using the jxls-reader(http://jxls.sourceforge.net/reference/reader.html).
I am comfortable with looping a sheet where one row represents a particular java object, but in the case of nested loops I am stumped.
I need to map the above excel sheet to the following pojo:
class Student {
private String name;
private String dob;
private List<Class> class;
//getters & setters
}
class Class {
private String name;
private String link;
//getters & setters
}
My problem is defining the lookbreakcondition to read the inner object. Notice that the loopbreakcondition for the Class object requires something along the following lines:
- The first cell of the next row is non-empty OR
- The first cell of the next row is empty AND the next cell of the current column is empty (for breaking the last row)
How do I express the above boolean condition in the loopbreakcondition. I have the following but I know it is wrong:
<workbook>
<worksheet name="Students">
<section startRow="0" endRow="0">
<!--Empty Header Section-->
</section>
<loop startRow="1" endRow="1" items="students" var="student" varType="com.test.Student">
<section startRow="1" endRow="1">
<mapping row="1" col="0">student.name</mapping>
<mapping row="1" col="1">student.dob</mapping>
</section>
<loopbreakcondition>
<rowcheck offset="0">
<cellcheck offset="0"> <!--Breaks on next empty cell--></cellcheck>
</rowcheck>
</loopbreakcondition>
<loop startRow="1" endRow="1" items="student.class" var="class" varType="com.test.Class">
<section startRow="1" endRow="1">
<mapping row="1" col="2">class.name</mapping>
<mapping row="1" col="3">class.link</mapping>
</section>
<loopbreakcondition>
<rowcheck offset="0">
<cellcheck offset="0"> </cellcheck>
</rowcheck>
</loopbreakcondition>
</loop>
</loop>
</worksheet>
</workbook>
Is this even possible? Are there any other libraries that will help me achieve this? Or am I better off writing my own parser using apache-poi?
Thank You.