Results 1 to 3 of 3
  1. #1
    tg3
    tg3 is offline Member
    Join Date
    Nov 2016
    Posts
    2
    Rep Power
    0

    Default Can't import org.apache.poi.xssf.usermodel.XSSFWorkbook

    I'm trying out sample code on the web to read and write data to an Excel spreadsheet.

    Netbeans 8.1, Mac OS X.

    The following FAILS. "Package org.apache.poi.xssf.usermodel" does not exist.
    import org.apache.poi.xssf.usermodel.XSSFWorkbook;

    All my other org.apache.poi. imports work fine.
    import org.apache.poi.ss.usermodel.Cell;
    import org.apache.poi.ss.usermodel.Row;
    import org.apache.poi.ss.usermodel.Sheet;
    import org.apache.poi.ss.usermodel.Workbook;

    I tried redownloading the library, reverting to an older version, adding every .jar file in the distribution. Nothing worked.

    Any suggestions??

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Can't import org.apache.poi.xssf.usermodel.XSSFWorkbook

    Where have you put the poi-ooxml-xyz.jar file? (where xyz is the version number)
    That's the one that holds the xssf package.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    tg3
    tg3 is offline Member
    Join Date
    Nov 2016
    Posts
    2
    Rep Power
    0

    Default Re: Can't import org.apache.poi.xssf.usermodel.XSSFWorkbook

    SOLVED.

    In Netbeans, I had created a new library with all of the .jar files in the poi-2.15 folder, and linked that library to my new project.

    Quite astonishingly, this process CORRUPTED NETBEANS. Previous projects suddenly failed to compile because the compiler suddenly could not find how to link when a JPanel had an absolute layout. Yes, completely unrelated to anything I did with the poi .jar files.

    A simple reinstall of Netbeans 8.1 DID NOT fix the problem. I had to hunt down and delete EVERY hidden file on the Mac related to Netbeans. Then a reinstall fixed the problem. Until I recreated the poi library, and relinked to my project. So I recreated the error 3 times.

    SOLUTION.
    I created a LIBS collection (folder) in Netbeans for my project, and copied ALL the .jar files from poi-2.15 to the LIBS folder. Then I linked the .jar files in LIBS to my project via the project's Libraries property. No problem with the sample code, and the other project that needs to read/write Excel files.

    COMMENT.
    I would sure be nice if the Apache POI documentation listed which .jar files are needed for each method or class that is called.

Similar Threads

  1. Replies: 3
    Last Post: 11-18-2015, 10:48 AM
  2. create Theme in new XSSFWorkbook
    By Piotr in forum Apache POI
    Replies: 2
    Last Post: 08-03-2015, 09:40 AM
  3. Replies: 3
    Last Post: 06-28-2012, 12:33 PM
  4. Replies: 2
    Last Post: 05-21-2012, 11:00 AM
  5. How to copy cell styles in an XSSFWorkbook?
    By laredotornado in forum Apache POI
    Replies: 2
    Last Post: 04-03-2012, 05:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •