4 Replies Latest reply on Jan 18, 2017 6:10 PM by cfang

    Import from xlsx file

    mistrz_7

      Hello,

       

       

      I build jbatch process that should import data from xlsx file to databases. It's my jbatch file:

       

       

      <job id="main" version="1.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee">  

            <step id="pobierzDane">

                  <properties>

                  <property name="javax.transaction.global.timeout" value="1800" />

              </properties>            

                  <chunk>

                        <reader ref="excelUserModelItemReader">

                      <properties>

                          <property name="resource" value="#{jobParameters['sciezka']}#{jobParameters['nazwaPliku']}"/>

                          <property name="beanType" value="java.util.List"/>

                          <property name="sheetName" value="FCT"/>

                          <property name="start" value="1"/>

                          <property name="headerRow" value="0"/>

                          <property name="mapperFeatures" value="AUTO_DETECT_FIELDS=false"></property>

       

                          <!-- need to ignore unknown properties as some additional properties in data -->

                          <property name="deserializationFeatures" value="FAIL_ON_UNKNOWN_PROPERTIES=false"/>

                      </properties>

                  </reader>

                        <processor ref="myItemProcessor">

                              <properties>

                                    <property name="nazwaPliku" value="#{jobParameters['nazwaPliku']}" />

                              </properties>

                        </processor>

                        <writer ref="jdbcItemWriter">

                      <properties>

                          <property name="dataSourceLookup" value="java:/fmsFms" />

                      <property name="sql" value="insert into schema.t_my_tab(name, data, number, id) values(?, ?, ?, '1')" />

                          <property name="beanType" value="java.util.List" />

                      </properties>

                  </writer>

                  </chunk>

            </step>

      </job>

       

       

      The problem is, becouse third column in excel sheet contain big numbers like 567894354. This values are imported to jbatch in format like 5.67894+e008. I see this values in processor and datas in this format are loaded to database. How to solve this problem, how to receive in jbatch program "clear" numer value?

       

        • 1. Re: Import from xlsx file
          cfang

          I think the number is still  the number, and its value should still be the same, whether in scientific notation or not.  Since the number is big, your database may still use scientific notation to store it (e.g., for efficiency reason), regardless how it is stored in excel.  Do you see any specific errors related to this number format?

          • 2. Re: Import from xlsx file
            mistrz_7

            No, there is no error while execute this process.

            I think it should be mapped on reader becouse processor "see" this values in scientific format.

            • 3. Re: Import from xlsx file
              mistrz_7

              Solution was switch  bean type to POJO class, where required field is integer type. Now jbatch receive this column correctly.

               

              Regards

              sw

              • 4. Re: Import from xlsx file
                cfang

                Good to know that, and thanks for the update!