# File lib/spreadsheet/excel/writer/workbook.rb, line 51
  def collect_formats workbook, opts={}
    # The default cell format is always present in an Excel file, described by
    # the XF record with the fixed index 15 (0-based). By default, it uses the
    # worksheet/workbook default cell style, described by the very first XF
    # record (index 0).
    formats = []
    unless opts[:existing_document]
      15.times do
        formats.push Format.new(self, workbook, workbook.default_format,
                                :type => :style)
      end
      formats.push Format.new(self, workbook)
    end
    workbook.formats.each do |fmt|
      formats.push Format.new(self, workbook, fmt)
    end
    @formats[workbook] = {
      :writers => [],
      :xf_indexes => {}
    }
    formats.each_with_index do |fmt, idx|
      @formats[workbook][:writers] << fmt
      @formats[workbook][:xf_indexes][fmt.format] ||= idx
    end
  end