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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:48:28+00:00 2026-06-05T01:48:28+00:00

I am trying to use Apache POI to read in old (pre-2007 and XLS)

  • 0

I am trying to use Apache POI to read in old (pre-2007 and XLS) Excel files. My program goes to the end of the rows and iterates back up until it finds something that’s not either null or empty. Then it iterates back up a few times and grabs those cells. This program works just fine reading in XLSX and XLS files made in Office 2010.

I get the following error message:

Exception in thread "main" java.lang.NumberFormatException: empty String
    at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
    at java.lang.Double.parseDouble(Unknown Source)

at the line:

num = Double.parseDouble(str);

from the code:

str = cell.toString();

if (str != "" || str != null) {
    System.out.println("Cell is a string");
    num = Double.parseDouble(str);
} else {
    System.out.println("Cell is numeric.");
    num = cell.getNumericCellValue();
}

where the cell is the last cell in the document that’s not empty or null. When I try to print the first cell that’s not empty or null, it prints nothing, so I think I’m not accessing it correctly.

  • 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-05T01:48:29+00:00Added an answer on June 5, 2026 at 1:48 am

    It would be better to evaluate the cell type and then do what you need. I use this code to handle the cell data (check that I even handle blank cells):

    switch (cell.getCellType()) {
        case Cell.CELL_TYPE_STRING:
            str = cell.toString().trim();
            break;
        case Cell.CELL_TYPE_NUMERIC:
            if (DateUtil.isCellDateFormatted(cell)) {
                //you should change this to your application date format
                objSimpleDateFormat = new SimpleDateFormat("dd/MM/yyyy");
                str = objSimpleDateFormat.format(cell.getDateCellValue());
            } else {
                num = cell.getNumericCellValue();
                str = String.valueOf(cell.getNumericCellValue());
            }
            break;
        case Cell.CELL_TYPE_BLANK:
            str = "";
            break;
        case Cell.CELL_TYPE_ERROR:
            str = "";
            break;
        case Cell.CELL_TYPE_BOOLEAN:
            str = String.valueOf(cell.getBooleanCellValue());
        break;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to use Apache POI (Version 3.6) to parse Excel .xls file,
I'm trying to use Apache Commons Net for FTP file transfers. Problem is files
I'm trying to create some xlsx files using the Apache POI library for Java
Trying to use Apache POI in a Eclipse JSP project. The POI jar is
I am trying to use Apache POI to extract embedded equation and text from
I'm trying to use SlideShow to create presentation... http://poi.apache.org/apidocs/org/apache/poi/hslf/usermodel/SlideShow.html and I see some uses
I have a program that is trying to use the org.apache.commons.io.FileUtils static method readFileToString()
I am trying to use Apache mod_rewrite to achieve the following: In the document
I'm trying to use Apache Lucene for tokenizing, and I am baffled at the
I'm trying to use Apache XMLRPC to manage posts at a small weblog service.

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.