Read Excel using Apache POI - Exception in thread "main" org.apache.poi.poifs.filesystem.OfficeXmlFileException:


Read Excel using Apache POI - Challenges
------------------------------------------------
1) Exception in thread "main" org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)


Add following maven dependency
-- Use poi-ooxml from xlsx files while poi for xls
<!-- POI : Excel library -->  
<dependency>  
<groupId>org.apache.poi</groupId> 
<artifactId>poi</artifactId>  
<version>${poi.version}</version> 
</dependency>  
<dependency>
       < groupId>org.apache.poi</groupId> 
        <artifactId>poi-ooxml</artifactId> 
      <version>${poi.version}</version>
  </dependency

2)Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException
-- Reading excel using apache POI – Add library xmlbeans-x.x.x.jar from maven

3) Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections4/ListValuedMap
-- add library from common collections (from maven)
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
</dependency>




Popular posts from this blog

Android: where to run keytool command in android

Can not connect to git using ssh (Permissions 0644 for '/root/.ssh/id_rsa' are too open.

Upload file on Google cloud storage using Java servlet on google app engine