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 8588025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:42:53+00:00 2026-06-11T22:42:53+00:00

When I try to initialize a Workbook object I always get this error: The

  • 0

When I try to initialize a Workbook object I always get this error:

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)

But I followed the office sample to do this, following is my code:

File inputFile = new File(inputFileName); 
InputStream is = new FileInputStream(inputFile);
Workbook wb = new XSSFWorkbook(is);

Exception occurs at code line:

Workbook wb = new XSSFWorkbook(is);

Here is POI jar including:

poi-3.8-20120326.jar  
poi-ooxml-3.8-20120326.jar  
poi-ooxml-schemas-3.8-20120326.jar  
xmlbeans-2.3.0.jar  

Can any guys give me guidance? An example showing how to read a complete Excel 2007 document will be appreciated. Thanks in advance!

  • 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. Editorial Team
    Editorial Team
    2026-06-11T22:42:55+00:00Added an answer on June 11, 2026 at 10:42 pm

    I assume that you have recheck that your original file is indeed in Office 2007+XML format, right?

    Edit:

    Then, if you are sure the format is ok, and it works for you using the WorkbookFactory.create, you can find the answer in the code of such method:

       /**
         * Creates the appropriate HSSFWorkbook / XSSFWorkbook from
         *  the given InputStream.
         * Your input stream MUST either support mark/reset, or
         *  be wrapped as a {@link PushbackInputStream}!
         */
        public static Workbook create(InputStream inp) throws IOException, InvalidFormatException {
                // If clearly doesn't do mark/reset, wrap up
                if(! inp.markSupported()) {
                        inp = new PushbackInputStream(inp, 8);
                }
    
                if(POIFSFileSystem.hasPOIFSHeader(inp)) {
                        return new HSSFWorkbook(inp);
                }
                if(POIXMLDocument.hasOOXMLHeader(inp)) {
                        return new XSSFWorkbook(OPCPackage.open(inp));
                }
                throw new IllegalArgumentException("Your InputStream was neither an OLE2 stream, nor an OOXML stream");
        }
    

    This is the bit that you were missing: new XSSFWorkbook(OPCPackage.open(inp))

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to initialize an object using the Object Initializer, ReSharper always inserts
I try to initialize typed IDictionary object property with xml Spring.net declaration, but exception
I have a class which I try to initialize but get the error No
When ever I try to initialize a multidimensional array I get the following error:
I'm trying to initialize a session but i get this error: Warning: session_start() [function.session-start]:
Hello I'm getting this weird exception when I try to initialize HttpSolrServer from my
I get this Random Jni error, sometimes the codes works, sometimes it doesn't import
I am lost here. I try to initialize a UIImage object with the method.
I have this class in which i try to initialize array attributes with query
I keep on getting this error Exception in thread main org.hibernate.LazyInitializationException: could not initialize

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.