6 Replies Latest reply on Sep 30, 2019 10:10 AM by cfang

    excelUserModelItemReader with xlsx having spaces in the header row

    richardmoore

      How do I read an xlsx on a tab which the headers have spaces in them?

       

      I have a xlsx spreadsheet that I need to convert to json. The tab is "Business Information" and the column headers are as follows -

      • Filing State
      • Name
      • Address
      • City
      • State
      • Zipcode
      • First Name
      • Last Name
      • Title
      • Phone
      • Email Address

      I am stuck at this point, an object (BusinessInformation.java) is being created but all of the fields are null. Below is the jsl as of my last attempt.

       

      <reader ref="excelUserModelItemReader">

      <properties>

      <property name="resource" value="iControl Spread Sheet.xlsx" />

      <property name="beanType" value="com.awginc.tax.cigarette.excel.BusinessInformation" />

      <property name="sheetName" value="Business Information" />

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

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

      <property name="header" value="filingState, name, address, city, state, zipcode, firstName, lastName, title, phone, emailAddress" />

      </properties>

      </reader>

       

       

       

      package com.awginc.tax.cigarette.excel;

      /*

      * Business Information tab of the user supplied Excel spreadsheet

      * contains the following columns in the order given -

      * Filing State

      * Name

      * Address

      * City

      * State

      * Zipcode

      * First Name

      * Last Name

      * Title

      * Phone

      * Email Address

      */

      public class BusinessInformation {

       

       

      public String getFilingState() {

      return filingState;

      }

       

       

      public void setFilingState(String filingState) {

      this.filingState = filingState;

      }

       

       

      public String getName() {

      return name;

      }

       

       

      public void setName(String name) {

      this.name = name;

      }

       

       

      public String getAddress() {

      return address;

      }

       

       

      public void setAddress(String address) {

      this.address = address;

      }

       

       

      public String getCity() {

      return city;

      }

       

       

      public void setCity(String city) {

      this.city = city;

      }

       

       

      public String getState() {

      return state;

      }

       

       

      public void setState(String state) {

      this.state = state;

      }

       

       

      public String getZipcode() {

      return zipcode;

      }

       

       

      public void setZipcode(String zipcode) {

      this.zipcode = zipcode;

      }

       

       

      public String getFirstName() {

      return firstName;

      }

       

       

      public void setFirstName(String firstName) {

      this.firstName = firstName;

      }

       

       

      public String getLastName() {

      return lastName;

      }

       

       

      public void setLastName(String lastName) {

      this.lastName = lastName;

      }

       

       

      public String getTitle() {

      return title;

      }

       

       

      public void setTitle(String title) {

      this.title = title;

      }

       

       

      public String getPhone() {

      return phone;

      }

       

       

      public void setPhone(String phone) {

      this.phone = phone;

      }

       

       

      public String getEmailAddress() {

      return emailAddress;

      }

       

       

      public void setEmailAddress(String emailAddress) {

      this.emailAddress = emailAddress;

      }

       

       

      public String toString() {

      StringBuffer sb = new StringBuffer();

       

       

      sb.append("Name: " + this.getFirstName() + " " + this.getLastName());

      sb.append(System.getProperty("line.separator") + "Email: " + this.getEmailAddress());

       

       

      return sb.toString();

      }

       

       

      private String filingState;

      private String name;

      private String address;

      private String city;

      private String state;

      private String zipcode;

      private String firstName;

      private String lastName;

      private String title;

      private String phone;

      private String emailAddress;

      }