Excel Date to java.Uitl.Date using jXLS Reader

2.6k views Asked by At

I am trying to read excel files using jXLS library with Spring 3.x. The problem is I have a couple of date columns in excel file with mm/dd/yyyy format but when I am reading them back into java bean, they are turning up as NULL.

I tried the conversion mechanism mentioned in jXLS Reader

Am I missing any configuration or implementing jXLS configuration wrongly? TIA.

1

There are 1 answers

4
Leonid Vysochyn On

You can check XLSReader example in https://bitbucket.org/leonate/jxls-demo project. It reads Employee birth dates into java.util.Date birthDate property and prints them. The XML configuration for this part looks like this

        <section startRow="7" endRow="7">
            <mapping row="7" col="0">employee.name</mapping>
            <mapping row="7" col="1">employee.age</mapping>
            <mapping row="7" col="2">employee.birthDate</mapping>
            <mapping row="7" col="3">employee.payment</mapping>
            <mapping row="7" col="4">employee.bonus</mapping>
        </section>

In the input Excel file you should have properly formatted Date cells like 8/18/1978.