<changes>
<release version="3.6-beta1" date="2009-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">48180 - be more forgiving of short chart records, which skip some unused fields</action>
<action dev="POI-DEVELOPERS" type="fix">48274 - fix erronious wrapping of byte colours in HSSFPalette.findSimilarColor</action>
<action dev="POI-DEVELOPERS" type="fix">48269 - fix fetching of error codes from XSSF formula cells</action>
<action dev="POI-DEVELOPERS" type="fix">48229 - fixed javadoc for HSSFSheet.setColumnWidth and XSSFSheet setColumnWidth </action>
private short wOffset;
private short at;
private short grbit;
- private short unused;
+ private Short unused;
public CatLabRecord(RecordInputStream in) {
rt = in.readShort();
wOffset = in.readShort();
at = in.readShort();
grbit = in.readShort();
- unused = in.readShort();
+
+ // Often, but not always has an unused short at the end
+ if(in.available() == 0) {
+ unused = null;
+ } else {
+ unused = in.readShort();
+ }
}
@Override
protected int getDataSize() {
- return 2 + 2 + 2 + 2 + 2 + 2;
+ return 2 + 2 + 2 + 2 + 2 + (unused==null? 0:2);
}
@Override
@Override
public void serialize(LittleEndianOutput out) {
-
out.writeShort(rt);
out.writeShort(grbitFrt);
out.writeShort(wOffset);
out.writeShort(at);
out.writeShort(grbit);
- out.writeShort(unused);
+ if(unused != null)
+ out.writeShort(unused);
}
@Override
grbitFrt = in.readShort();
iObjectKind = in.readShort();
- unused = new byte[6];
- in.readFully(unused);
+ // Often, but not always has 6 unused bytes at the end
+ if(in.available() == 0) {
+ unused = new byte[0];
+ } else {
+ unused = new byte[6];
+ in.readFully(unused);
+ }
}
@Override
protected int getDataSize() {
- return 2 + 2 + 2 + 6;
+ return 2 + 2 + 2 + unused.length;
}
@Override
assertEquals(32766, cell2.getStringCellValue().length());
}
+ /**
+ * Short records on certain sheets with charts in them
+ */
+ public void test48180() {
+ HSSFWorkbook wb = openSample("48180.xls");
+
+ HSSFSheet s = wb.getSheetAt(0);
+ HSSFCell cell1 = s.getRow(0).getCell(0);
+ assertEquals("test ", cell1.getStringCellValue().toString());
+
+ HSSFCell cell2 = s.getRow(0).getCell(1);
+ assertEquals(1.0, cell2.getNumericCellValue());
+ }
}