0

I recently attempted to rename my project in Eclipse using refactoring, and when I did I ran into many errors. I think I resolved all of them, but now my program is getting stuck while reading in a .xlsx file.

File file = new File("C://Users/user1/ExcelFile.xlsx");

if(!file.getName().endsWith("xlsx")) {
        JOptionPane.showMessageDialog(null, 
        "Please select an Excel file (.xlsx)",
                    "Error", JOptionPane.ERROR_MESSAGE);
} else {

    XSSFWorkbook workbook = null;
    try {
        // Find the workbook instance for XLSX file
        workbook = new XSSFWorkbook(file);
    } catch (IOException e) {
        Logger.getLogger(
                XLSXHandler.class.
                getName()).log(Level.SEVERE, null, e);;
    }
    // Return first sheet from the XLSX workbook
    XSSFSheet mySheet = workbook.getSheetAt(0);

    // reading sheet into taskList
    tasks = readInTasks(mySheet);
}

The problem area seeems to be in the "workbook = new XSSFWorkbook(file);" line because in the debugger, workbook is filled with null values. In my build path, I have included the following .jar files:

  • poi-3.15-beta1.jar
  • poi-ooxml-3.15-beta1.jar
  • poi-ooxml-schemas-3.15-beta1.jar
  • xmlbeans-2.6.0.jar
  • commons-codec-1.10.jar
  • jxl.jar
  • stax-api-1.0.1.jar

Any ideas?

tgordon18
  • 1,562
  • 1
  • 19
  • 31
  • No, there are no exceptions – tgordon18 Jul 07 '16 at 12:58
  • File exists? Can you read it? Can you open it in Excel? – user1516873 Jul 07 '16 at 13:28
  • Yes, I can confirm that the file exists, can be opened in Excel, and can even be read in by the program. It falters when trying to make it a workbook – tgordon18 Jul 07 '16 at 13:31
  • 2
    If you do a thread dump, where does it show the Workbook thread hanging? – Gagravarr Jul 07 '16 at 13:55
  • Is it a large .xlsx file you are trying to open? Do check also that your java process has a reasonable heap size allocated, and that it's not stuck performing full garbage collections close together due to an insufficient heap (you need to have garbage collection logging enabled for this). Use jstack to do a thread dump as suggested by @Gagravarr also and consider using jmap to do some live heap analysis. – Finbarr O'B Jul 07 '16 at 21:10

0 Answers0