public override void VisitContainedRecords(RecordVisitor rv) { PositionTrackingVisitor stv = new PositionTrackingVisitor(rv, 0); //DBCells are serialized before row records. int blockCount = this.RowBlockCount; for (int blockIndex = 0; blockIndex < blockCount; blockIndex++) { // Serialize a block of rows. // Hold onto the position of the first row in the block int pos = 0; // Hold onto the size of this block that was serialized int rowBlockSize = VisitRowRecordsForBlock(blockIndex, rv); pos += rowBlockSize; // Serialize a block of cells for those rows int startRowNumber = GetStartRowNumberForBlock(blockIndex); int endRowNumber = GetEndRowNumberForBlock(blockIndex); DBCellRecord cellRecord = new DBCellRecord(); // Note: Cell references start from the second row... int cellRefOffset = (rowBlockSize - RowRecord.ENCODED_SIZE); for (int row = startRowNumber; row <= endRowNumber; row++) { if (_valuesAgg.RowHasCells(row)) { stv.Position = 0; _valuesAgg.VisitCellsForRow(row, stv); int rowCellSize = stv.Position; pos += rowCellSize; // Add the offset to the first cell for the row into the // DBCellRecord. cellRecord.AddCellOffset((short)cellRefOffset); cellRefOffset = rowCellSize; } } // Calculate Offset from the start of a DBCellRecord to the first Row cellRecord.RowOffset = (pos); rv.VisitRecord(cellRecord); } foreach (Record _hyperlinkRecord in _hyperlinkRecordRecords) { rv.VisitRecord(_hyperlinkRecord); } foreach (Record _unknownRecord in _unknownRecords) { // Potentially breaking the file here since we don't know exactly where to write these records rv.VisitRecord(_unknownRecord); } }