0

I have an excel sheet which has a non-finite amount of sheets. How do I use JXLS to go through each sheet and map each sheet's values to a bean?

I can do it for the first sheet, but I can't seem to find documentation on how to iterate through sheets?

Thanks in advance.

EDIT: Here's my XML config

<?xml version="1.0" encoding="ISO-8859-1"?>
<workbook>
    <worksheet idx="0">
        <section startRow="0" endRow="0">
        </section>
        <loop startRow="1" endRow="1" items="items" var="item" varType="package.itemBean">
            <section startRow="1" endRow="1">
                <mapping row="1" col="2">item.title</mapping>
                <mapping row="1" col="3">item.description</mapping>
                <mapping row="1" col="4">item.cost</mapping>
                <mapping row="1" col="5">item.price</mapping>
            </section>
            <loopbreakcondition>
                <rowcheck offset="0">
                    <cellcheck offset="0"/>
                </rowcheck>
            </loopbreakcondition>
        </loop>
    </worksheet>
</workbook>

I have the mapping section down for a single sheet, however I can not find a way at all to create a mapping for every sheet.

I was thinking of using the <loop> tag, but I don't know how I would use the required startRow and endRow tags.

I did a bit of searching the object and have found that XLSReader has a function setSheetReader which allows me to pass a map of sheet readers, but I have yet to find out a way to create a sheet reader to be able to pass it into the object.

It seems to me that creating a loop in the XML seems more 'proper' to do, but no idea how.

Hoping you guys can help!

4

0 回答 0