diff --git a/src/documentation/xdocs/todo.xml b/src/documentation/xdocs/todo.xml
index ed5307fc9..35ef984a9 100644
--- a/src/documentation/xdocs/todo.xml
+++ b/src/documentation/xdocs/todo.xml
@@ -4,54 +4,54 @@
@@ -103,7 +102,7 @@ public class RecordFactory WindowTwoRecord.class, SelectionRecord.class, ContinueRecord.class, LabelRecord.class, BlankRecord.class, ColumnInfoRecord.class, MulRKRecord.class, MulBlankRecord.class, MergeCellsRecord.class, - FormulaRecord.class + FormulaRecord.class, BoolErrRecord.class }; private static Map recordsMap = recordsToMap(records); @@ -221,8 +220,9 @@ public class RecordFactory } catch (Exception introspectionException) { + introspectionException.printStackTrace(); throw new RecordFormatException( - "Unable to construct record instance"); + "Unable to construct record instance, the following exception occured: " + introspectionException.getMessage()); } if (retval instanceof RKRecord) { diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java index 221f16aed..a851a1c42 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java @@ -142,11 +142,10 @@ public class HSSFWorkbook workbook = Workbook.createWorkbook(records); setPropertiesFromWorkbook(workbook); int numRecords = workbook.getNumRecords(); - int sheetnum = 0; while (numRecords < records.size()) { - Sheet sheet = Sheet.createSheet(records, sheetnum, numRecords); + Sheet sheet = Sheet.createSheet(records); numRecords += sheet.getNumRecords(); sheet.convertLabelRecords( diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java index 195a33fdd..51901a10b 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java @@ -1,4 +1,3 @@ - /* ==================================================================== * The Apache Software License, Version 1.1 * @@ -56,14 +55,13 @@ package org.apache.poi.hssf.usermodel; import junit.framework.TestCase; - -import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.Sheet; import org.apache.poi.hssf.record.VCenterRecord; import org.apache.poi.hssf.record.WSBoolRecord; +import java.io.File; +import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.FileWriter; /** * Tests HSSFSheet. This test case is very incomplete at the moment. @@ -74,7 +72,7 @@ import java.io.FileWriter; */ public class TestHSSFSheet - extends TestCase + extends TestCase { public TestHSSFSheet(String s) { @@ -86,11 +84,11 @@ public class TestHSSFSheet */ public void testBackupRecord() - throws Exception + throws Exception { - HSSFWorkbook wb = new HSSFWorkbook(); - HSSFSheet s = wb.createSheet(); - Sheet sheet = s.getSheet(); + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet s = wb.createSheet(); + Sheet sheet = s.getSheet(); assertEquals(true, sheet.getGridsetRecord().getGridset()); s.setGridsPrinted(true); @@ -102,13 +100,13 @@ public class TestHSSFSheet */ public void testVerticallyCenter() - throws Exception + throws Exception { - HSSFWorkbook wb = new HSSFWorkbook(); - HSSFSheet s = wb.createSheet(); - Sheet sheet = s.getSheet(); + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet s = wb.createSheet(); + Sheet sheet = s.getSheet(); VCenterRecord record = - ( VCenterRecord ) sheet.findFirstRecordBySid(VCenterRecord.sid); + (VCenterRecord) sheet.findFirstRecordBySid(VCenterRecord.sid); assertEquals(false, record.getVCenter()); s.setVerticallyCenter(true); @@ -123,11 +121,11 @@ public class TestHSSFSheet public void testWSBool() { - HSSFWorkbook wb = new HSSFWorkbook(); - HSSFSheet s = wb.createSheet(); - Sheet sheet = s.getSheet(); + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet s = wb.createSheet(); + Sheet sheet = s.getSheet(); WSBoolRecord record = - ( WSBoolRecord ) sheet.findFirstRecordBySid(WSBoolRecord.sid); + (WSBoolRecord) sheet.findFirstRecordBySid(WSBoolRecord.sid); // Check defaults assertEquals(true, record.getAlternateExpression()); @@ -167,4 +165,30 @@ public class TestHSSFSheet assertEquals(true, s.getRowSumsBelow()); assertEquals(true, s.getRowSumsRight()); } + + 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()); + + + } }