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 @@ - - - - - - - - + + + + + + + + - - - Finish HDF - - - Finish Charts - - - Add Formulas. - + + + Finish HDF + + + Finish Charts + + + Add Formulas. + - + - - - Expose functionality in low level records in higher level API - - - Implement more record types (for other things ... not sure - what this will mean yet). - - - Implement more record types (for other things ... not sure - what this will mean yet). - - - Add more dummy checks (for when API user's do things they - "can't" do) - - - Add support for embedded graphics and stuff like that. - - - Create new adapter object for handling MulBlank, MulRk, Rk - records. - - - Add a way to copy sheets. - - + + + Expose functionality in low level records in higher level API + + + Implement more record types (for other things ... not sure + what this will mean yet). + + + Implement more record types (for other things ... not sure + what this will mean yet). + + + Add more dummy checks (for when API user's do things they + "can't" do) + + + Add support for embedded graphics and stuff like that. + + + Create new adapter object for handling MulBlank, MulRk, Rk + records. + + + Add a way to copy sheets. + + diff --git a/src/java/org/apache/poi/hssf/model/Sheet.java b/src/java/org/apache/poi/hssf/model/Sheet.java index c274da546..a247e4745 100644 --- a/src/java/org/apache/poi/hssf/model/Sheet.java +++ b/src/java/org/apache/poi/hssf/model/Sheet.java @@ -55,21 +55,17 @@ package org.apache.poi.hssf.model; -import java.io.OutputStream; - import java.util.List; import java.util.ArrayList; import java.util.Iterator; import org.apache.poi.util.POILogFactory; -import org.apache.poi.hssf - .record.*; // normally I don't do this, buy we literally mean ALL +import org.apache.poi.hssf.record.*; // normally I don't do this, buy we literally mean ALL import org.apache.poi.hssf.record.formula.FormulaUtil; import org.apache.poi.hssf.record.formula.Ptg; import org.apache.poi.util.IntList; import org.apache.poi.util.POILogger; -import org.apache.poi.hssf.record - .aggregates.*; // normally I don't do this, buy we literally mean ALL +import org.apache.poi.hssf.record.aggregates.*; // normally I don't do this, buy we literally mean ALL /** * Low level model implementation of a Sheet (one workbook contains many sheets) @@ -116,7 +112,7 @@ public class Sheet /** * Creates new Sheet with no intialization --useless at this point - * @see #createSheet(List,int,int) + * @see #createSheet(List,int) */ public Sheet() @@ -132,7 +128,6 @@ public class Sheet * is normally called via Workbook. * * @param recs array containing those records in the sheet in sequence (normally obtained from RecordFactory) - * @param sheetnum integer specifying the sheet's number (0,1 or 2 in this release) * @param offset of the sheet's BOF record * * @return Sheet object with all values set to those read from the file @@ -140,7 +135,7 @@ public class Sheet * @see org.apache.poi.hssf.model.Workbook * @see org.apache.poi.hssf.record.Record */ - public static Sheet createSheet(List recs, int sheetnum, int offset) + public static Sheet createSheet(List recs, int offset) { log.logFormatted(log.DEBUG, "Sheet createSheet (existing file) with %", @@ -240,15 +235,14 @@ public class Sheet * only the record offset is assumed to be 0. * * @param records array containing those records in the sheet in sequence (normally obtained from RecordFactory) - * @param sheetnum integer specifying the sheet's number (0,1 or 2 in this release) * @return Sheet object */ - public static Sheet createSheet(List records, int sheetnum) + public static Sheet createSheet(List records) { log.log(log.DEBUG, "Sheet createSheet (exisiting file) assumed offset 0"); - return createSheet(records, sheetnum, 0); + return createSheet(records); } /** diff --git a/src/java/org/apache/poi/hssf/record/RecordFactory.java b/src/java/org/apache/poi/hssf/record/RecordFactory.java index 6beca36d2..480c9fbfa 100644 --- a/src/java/org/apache/poi/hssf/record/RecordFactory.java +++ b/src/java/org/apache/poi/hssf/record/RecordFactory.java @@ -63,7 +63,6 @@ import java.util.*; import java.lang.reflect.Constructor; import org.apache.poi.util.LittleEndian; -import org.apache.poi.util.HexDump; /** * Title: Record Factory

@@ -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()); + + + } }