Bug 54743 - getrow() returns null even though there's data in the file.
Summary: getrow() returns null even though there's data in the file.
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.9-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-22 17:29 UTC by dajasin
Modified: 2013-03-22 18:15 UTC (History)
0 users



Attachments
Test File (8.99 KB, application/octet-stream)
2013-03-22 17:32 UTC, dajasin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dajasin 2013-03-22 17:29:41 UTC
Here's the code:

SXSSFWorkbook wb;
Sheet sheet;
Row r;
Cell cell;
InputStream inp;
        
try {
           
inp = new FileInputStream(sFileName);
        
            wb = new SXSSFWorkbook(new XSSFWorkbook(inp));
            
            cell = wb.getSheetAt(0).getRow(0).getCell(0);
            
            if(cell != null) {
                sOutput = cell.getStringCellValue();
                sOutput = sOutput + " in here!";
            } else {
                sOutput = "Nothing";
            }
            
            System.out.println(sOutput);
    
            inp.close();
          
        }
        catch(FileNotFoundException ex) {
            System.out.println(ex.getMessage());
        }
        catch(IOException | NullPointerException ex) {
            System.out.println(ex.getMessage());
        }
Comment 1 dajasin 2013-03-22 17:32:15 UTC
Created attachment 30096 [details]
Test File
Comment 2 dajasin 2013-03-22 17:34:17 UTC
Everything prior to getRow() works ok. I debugged and was able to see that the workbook and sheet were returned ok. Just couldn't get the row. Always returned null.
Comment 3 Nick Burch 2013-03-22 17:44:10 UTC
SXSSFWorkbook is write/append only. It does not support reading

To read a .xlsx file, you need to use the regular XSSFWorkbook (or low level event/SAX processing)
Comment 4 dajasin 2013-03-22 18:15:40 UTC
Thanks!