def store_table   #:nodoc:
    return unless compatibility?

    # Offset from the DBCELL record back to the first ROW of the 32 row block.
    row_offset = 0

    # Track rows that have cell data or modified by set_row().
    written_rows = []


    # Write the ROW records with updated max/min col fields.
    #
    (0 .. @dimension.row_max-1).each do |row|
      # Skip unless there is cell data in row or the row has been modified.
      next unless @table[row] or @row_data[row]

      # Store the rows with data.
      written_rows.push(row)

      # Increase the row offset by the length of a ROW record;
      row_offset += 20

      # The max/min cols in the ROW records are the same as in DIMENSIONS.
      col_min = @dimension.col_min
      col_max = @dimension.col_max

      # Write a user specified ROW record (modified by set_row()).
      if @row_data[row]
        # Rewrite the min and max cols for user defined row record.
        packed_row = @row_data[row]
        packed_row[6..9] = [col_min, col_max].pack('vv')
        append(packed_row)
      else
        # Write a default Row record if there isn't a  user defined ROW.
        write_row_default(row, col_min, col_max)
      end

      # If 32 rows have been written or we are at the last row in the
      # worksheet then write the cell data and the DBCELL record.
      #
      if written_rows.size == 32 || row == @dimension.row_max - 1
        # Offsets to the first cell of each row.
        cell_offsets = []
        cell_offsets.push(row_offset - 20)

        # Write the cell data in each row and sum their lengths for the
        # cell offsets.
        #
        written_rows.each do |rw|
          cell_offset = 0

          if @table[rw]
            @table[rw].each do |clm|
              next unless clm
              append(clm)
              length = clm.bytesize
              row_offset  += length
              cell_offset += length
            end
          end
          cell_offsets.push(cell_offset)
        end

        # The last offset isn't required.
        cell_offsets.pop

        # Stores the DBCELL offset for use in the INDEX record.
        @db_indices.push(@datasize)

        # Write the DBCELL record.
        store_dbcell(row_offset, cell_offsets)

        # Clear the variable for the next block of rows.
        written_rows   = []
        cell_offsets   = []
        row_offset     = 0
      end
    end
  end
def store_table   #:nodoc:
    return unless compatibility?

    # Offset from the DBCELL record back to the first ROW of the 32 row block.
    row_offset = 0

    # Track rows that have cell data or modified by set_row().
    written_rows = []


    # Write the ROW records with updated max/min col fields.
    #
    (0 .. @dimension.row_max-1).each do |row|
      # Skip unless there is cell data in row or the row has been modified.
      next unless @table[row] or @row_data[row]

      # Store the rows with data.
      written_rows.push(row)

      # Increase the row offset by the length of a ROW record;
      row_offset += 20

      # The max/min cols in the ROW records are the same as in DIMENSIONS.
      col_min = @dimension.col_min
      col_max = @dimension.col_max

      # Write a user specified ROW record (modified by set_row()).
      if @row_data[row]
        # Rewrite the min and max cols for user defined row record.
        packed_row = @row_data[row]
        packed_row[6..9] = [col_min, col_max].pack('vv')
        append(packed_row)
      else
        # Write a default Row record if there isn't a  user defined ROW.
        write_row_default(row, col_min, col_max)
      end

      # If 32 rows have been written or we are at the last row in the
      # worksheet then write the cell data and the DBCELL record.
      #
      if written_rows.size == 32 || row == @dimension.row_max - 1
        # Offsets to the first cell of each row.
        cell_offsets = []
        cell_offsets.push(row_offset - 20)

        # Write the cell data in each row and sum their lengths for the
        # cell offsets.
        #
        written_rows.each do |rw|
          cell_offset = 0

          if @table[rw]
            @table[rw].each do |clm|
              next unless clm
              append(clm)
              length = clm.bytesize
              row_offset  += length
              cell_offset += length
            end
          end
          cell_offsets.push(cell_offset)
        end

        # The last offset isn't required.
        cell_offsets.pop

        # Stores the DBCELL offset for use in the INDEX record.
        @db_indices.push(@datasize)

        # Write the DBCELL record.
        store_dbcell(row_offset, cell_offsets)

        # Clear the variable for the next block of rows.
        written_rows   = []
        cell_offsets   = []
        row_offset     = 0
      end
    end
  end
Note about compatibility mode.

 Excel doesn't require every possible Biff record to be present in a file.
 In particular if the indexing records INDEX, ROW and DBCELL aren't present
 it just ignores the fact and reads the cells anyway. This is also true of
 the EXTSST record. Gnumeric and OOo also take this approach. This allows
 WriteExcel to ignore these records in order to minimise the amount of data
 stored in memory. However, other third party applications that read Excel
 files often expect these records to be present. In "compatibility mode"
 WriteExcel writes these records and tries to be as close to an Excel
 generated file as possible.

 This requires additional data to be stored in memory until the file is
 about to be written. This incurs a memory and speed penalty and may not be
 suitable for very large files.


 Write cell data stored in the worksheet row/col table.

 This is only used when compatibity_mode() is in operation.

 This method writes ROW data, then cell data (NUMBER, LABELSST, etc) and then
 DBCELL records in blocks of 32 rows. This is explained in detail (for a
 change) in the Excel SDK and in the OOo Excel file format doc.