Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to read .XLSX files using org.apache.poi.ss.usermodel.* classes

807580Jun 1 2010 — edited Jun 11 2010
Hello,

I want to read in excel files to a JTable. I was able to read in .xls files, but have problems reading .xlsx files. Maybe there is something i need to add to the following code:
FileInputStream iStream = new FileInputStream(newFile);
POIFSFileSystem fs = new POIFSFileSystem(iStream);
Workbook wb1 = WorkbookFactory.create(fs);
Sheet sheet = wb1.getSheetAt(0);       // get the first sheet data

 // Iterate over each row in the sheet
  Iterator rows = sheet.rowIterator();

   while(rows.hasNext()) {
      Row row = (Row) rows.next();
      .............
The compiler is complaining about the 3rd line: Workbook wb1 = WorkbookFactory.create(fs);

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 9 2010
Added on Jun 1 2010
4 comments
1,520 views