--- org/apache/poi/hssf/model/Sheet.java Sat Jun 21 13:51:18 2008 +++ org/apache/poi/hssf/model/Sheet.java Wed Jul 16 16:21:09 2008 @@ -827,16 +827,18 @@ // If the BOF record was just serialized then add the IndexRecord if (record.getSid() == BOFRecord.sid) { - // Add an optional UncalcedRecord - if (_isUncalced) { - UncalcedRecord rec = new UncalcedRecord(); - pos += rec.serialize(pos, data); - } - //Can there be more than one BOF for a sheet? If not then we can - //remove this guard. So be safe it is left here. - if (rows != null && !haveSerializedIndex) { + if (!haveSerializedIndex) { haveSerializedIndex = true; - pos += serializeIndexRecord(k, pos, data); + // Add an optional UncalcedRecord - for size calculation we have to be shure to add it only once (each diagrams have new BOFRecord) + if (_isUncalced) { + UncalcedRecord rec = new UncalcedRecord(); + pos += rec.serialize(pos, data); + } + //Can there be more than one BOF for a sheet? If not then we can + //remove this guard. So be safe it is left here. + if (rows != null) { + pos += serializeIndexRecord(k, pos, data); + } } } }