• Post Reply Bookmark Topic Watch Topic
  • New Topic

Apache POI  RSS feed

 
Nandita Tiwari
Ranch Hand
Posts: 77
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to read my Excel file in console.

these are the libraries i imported..

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

But the problem is it does not accept .xlsx file, it accepts only .xls. What do I need to do, to rectify this?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The *.hssf.* classes only work with XLS files. You need to use the *.ss.* classes, then your code will work with both XLS and XLSX files. This is covered in detail by the POI online documentation.
 
Nandita Tiwari
Ranch Hand
Posts: 77
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which library am I supposed to use for that?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
POI ships in several jar files, not sure which one you need, but if you miss an important one you'll notice pretty quickly.
 
Praveen Kumar M K
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Noopur Kore wrote:I'm trying to read my Excel file in console.

these are the libraries i imported..

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

But the problem is it does not accept .xlsx file, it accepts only .xls. What do I need to do, to rectify this?


You can try the XSSF version of these classes.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Praveen Kumar M K wrote:You can try the XSSF version of these classes.

Don't. The XSSF classes handle only XLSX, whereas the HSSF classes handle only XLS. Much better to use the *.ss.* classes that I mentioned - they can handle both file formats.
 
Paul Clapham
Sheriff
Posts: 22834
43
Eclipse IDE Firefox Browser MySQL Database
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!