1

I'm trying to create a XSSFWorkbook to iterate over it later but every time it gets to this lines of code the program gets blocked, specifically at the second line.

    FileInputStream fis = new FileInputStream(location);  
    XSSFWorkbook workbook = new XSSFWorkbook(fis);  
    XSSFSheet ws = workbook.getSheetAt(0);

I don't know what the problem can be and I've tried different ways of loading the input file. The program throws no exception, it just gets stuck there. I've had no problem reading .xls files, loading them like this:

    InputStream input = new BufferedInputStream(new FileInputStream(location));
    POIFSFileSystem fs = new POIFSFileSystem( input );
    HSSFWorkbook wb = new HSSFWorkbook(fs);
    HSSFSheet sheet = wb.getSheetAt(0);

Thank you

Aitor
  • 53
  • 8
  • possible duplicate of [Apache POI XSSF reading in excel files](http://stackoverflow.com/questions/5985318/apache-poi-xssf-reading-in-excel-files) – Seb Jul 29 '14 at 11:27
  • I've already tried every solution in there and I still have the same problem. – Aitor Jul 29 '14 at 11:43
  • So when you tried using the WorkbookFactory did it freeze on WorkbookFactory.create()? Sanity check: is there anything weird or wrong with the filepath you're sending in or the file it's pointing to? – Romojr50 Jul 29 '14 at 12:53
  • Did you try stepping through in a debugger? You should be able to see where within `getSheetAt` it's getting stuck. – James Kingsbery Jul 29 '14 at 14:30
  • The problem is the creation of the workbood not the third line (maybe I shouldn't have put that line since is irrelevant). Yes, it freezes on WorkBookFactory.create(). The filepath is correct. I'm starting to think that the problem may be with some kind of failure saving my .xlsx projects due to excel or something like that. But I have no problem with .xls files, and I've tried creating different new files or using existing ones to see where the problem can be with the same result, always gets stuck there – Aitor Jul 29 '14 at 14:41

0 Answers0