Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 142089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:52:52+00:00 2026-05-11T07:52:52+00:00

Whilst trying to parse MS Excel file using POI-HSSF v3.2 I am getting IndexOutOfBoundsException.

  • 0

Whilst trying to parse MS Excel file using POI-HSSF v3.2 I am getting IndexOutOfBoundsException. The spreadsheet I am trying to read isn’t empty it has been created using MS Excel 2003 and BiffViewer included with the POI package has no problem parsing it.

My code is as follows:

package src;  import java.io.*; import org.apache.poi.hssf.record.*; import org.apache.poi.hssf.eventusermodel.*;  class Excel implements HSSFListener {     public static void main (String[] args) throws Exception     {         FileInputStream stream = new FileInputStream('c:\\temp\\a.xls');           HSSFEventFactory f = new HSSFEventFactory();          HSSFRequest req = new HSSFRequest();          req.addListenerForAllRecords(new Excel());          f.processEvents(req,stream);          stream.close();     }      public void processRecord (Record r)     {         System.out.println(r);     } } 

And here is the stack trace I am getting:

Exception in thread ‘main’ java.lang.IndexOutOfBoundsException at java.io.FileInputStream.readBytes(Native Method) at java.io.FileInputStream.read(FileInputStream.java:199) at org.apache.poi.hssf.record.RecordInputStream.nextRecord(RecordInputStream.java:106) at org.apache.poi.hssf.eventusermodel.HSSFRecordStream.getNextRecord(HSSFRecordStream.java:128) at org.apache.poi.hssf.eventusermodel.HSSFRecordStream.nextRecord(HSSFRecordStream.java:93) at org.apache.poi.hssf.eventusermodel.HSSFEventFactory.genericProcessEvents(HSSFEventFactory.java:141) at org.apache.poi.hssf.eventusermodel.HSSFEventFactory.processEvents(HSSFEventFactory.java:98) at src.Excel.main(Excel.java:21)

Many thanks! I know, I am being plain lazy and could have looked at the POI source myself, but, hopefully, someone here will be able to point out swiftly whatever silly thing I’ve done within my code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:52:52+00:00Added an answer on May 11, 2026 at 7:52 am

    Mystery solved, the correct way of getting an input stream is as follows

    FileInputStream file   = new FileInputStream('c:\\temp\\a.xls'); POIFSFileSystem poifs  = new POIFSFileSystem(file); InputStream     stream = poifs.createDocumentInputStream('Workbook'); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting below error whilst trying to persist an object that has a
I'm getting an error whilst trying to install psycopg2 on ubuntu 9.10 64 bit.
I'm trying to read in an XML feed using an XSLT Macro in Umbraco
I'm getting an error whilst trying to add an event listener to a class
Whilst 'investigating' finalisation (read: trying stupid things) I stumbled across some unexpected behaviour (to
Gday All, I have a baffling problem whilst trying to insert some chinese characters
Whilst a few questions mention using Lua in conjunction with some other language, I
Whilst trying to update through the Android AVD Manager, I receive the message: No
I'm having problems trying to call a Javascript function from an enqueued javascript file
I'm trying to understand what the affect of AsEnumerable() has over my data when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.