I have an Excel 2000 file with 10 columns, 2 of which are boolean. For the particular row in question, HSSFRow.getPhysicalNumberOfCells() reports 8 cells. The boolean cells are returned as <code>null</code> from HSSFRow.getCell ().
Here's a test case that confirms the bug. A comment in the code indicates that this bug may be a known issue. public void testReadBooleans() throws Exception { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Test boolean"); HSSFRow row = sheet.createRow((short)2); HSSFCell cell = row.createCell((short)9); cell.setCellValue(true); cell = row.createCell((short)11); cell.setCellValue(true); File tempFile = File.createTempFile("bool", "test.xls"); FileOutputStream stream = new FileOutputStream(tempFile); workbook.write(stream); stream.close(); FileInputStream readStream = new FileInputStream(tempFile); workbook = new HSSFWorkbook(readStream); sheet = workbook.getSheetAt(0); row = sheet.getRow(2); stream.close(); tempFile.delete(); assertEquals(2, row.getPhysicalNumberOfCells()); }
Nope, not a known issue... I think it may have been my fault. BoolErr record was missing from the RecordGenerator class. I will be submitting a fix as soon as CVS finishes updating (which could take a while over my 33.6k modem.
Fixed. Will be available on upcoming 1.5 release.