public IndexRecord CreateIndexRecord(int indexRecordOffset, int sizeOfInitialSheetRecords, int offsetDefaultColWidth) { IndexRecord result = new IndexRecord(); result.FirstRow = firstrow; result.LastRowAdd1 = lastrow + 1; result.PosOfDefColWidthRecord = offsetDefaultColWidth; // Calculate the size of the records from the end of the BOF // and up to the RowRecordsAggregate... // Add the references to the DBCells in the IndexRecord (one for each block) // Note: The offsets are relative to the Workbook BOF. Assume that this is // 0 for now..... int blockCount = RowBlockCount; // Calculate the size of this IndexRecord int indexRecSize = IndexRecord.GetRecordSizeForBlockCount(blockCount); int currentOffset = indexRecordOffset + indexRecSize + sizeOfInitialSheetRecords; for (int block = 0; block < blockCount; block++) { // each row-block has a DBCELL record. // The offset of each DBCELL record needs to be updated in the INDEX record // account for row records in this row-block currentOffset += GetRowBlockSize(block); // account for cell value records after those currentOffset += _valuesAgg.GetRowCellBlockSize( GetStartRowNumberForBlock(block), GetEndRowNumberForBlock(block)); // currentOffset is now the location of the DBCELL record for this row-block result.AddDbcell(currentOffset); // Add space required to write the DBCELL record (whose reference was just added). currentOffset += (8 + (GetRowCountForBlock(block) * 2)); } return(result); }