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>




Comments

Popular posts from this blog

Struts 2 : Warning :No configuration found for the specified action: 'Login.action' in namespace: '/'

Upload csv file at Google Cloud Storage using java

Read Images from a xlsx file using Apache POI