This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Apache POI  RSS feed

 
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?
 
Rancher
Posts: 42975
76
  • 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: 42975
76
  • 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.
 
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: 42975
76
  • 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.
 
Sheriff
Posts: 23714
50
Eclipse IDE Firefox Browser MySQL Database
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!