poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig Milhiser <cmilh...@us.ibm.com>
Subject Reading the value of cells from a template in an SXSSF model
Date Thu, 13 Feb 2014 17:48:01 GMT
I am using POI 3.10-FINAL.

I am trying to add data to a template workbook.  This workbook and the 
additional data is large so I am using the SXSSF model. 

I want to check the version of the template which is stored in the 
workbook to ensure it matches the program.  However I cannot get any rows 
from the existing sheet.

Here is the reproduction:

            OPCPackage pkg = OPCPackage.open(new File("template.xlsx"));
            XSSFWorkbook temp = new XSSFWorkbook(pkg);

            SXSSFWorkbook wb = new SXSSFWorkbook(temp, 

            Sheet sheet = wb.getSheet("Version");

            Row row = sheet.getRow(0);
            Cell cell = row.getCell(0);
In the Version sheet in the workbook, there are text values in cells A1, 
A2, B1 and B2.  However the row variable above is null.  The sheet 
variable is populated.

By adding these lines after the sheet assignment, j is always 0.
            int j = sheet.getFirstRowNum();
            j = sheet.getLastRowNum();
            j = sheet.getPhysicalNumberOfRows();
Looking in the debugger at the sheet variable after the assignment, the 
_rows TreeMap has size 0.  However the sheet._sh._rows TreeMap has the 
rows and cell values.  The cell values are in the data structures, I just 
am doing something wrong to access them.

How can I get the value of existing cells from a template in an SXSSF 

Thank you.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message