def cells(options = {}, &block)
      cell_regex = /^cell_([0-9]+)_/

      options ||= { }

      result = block_given? ? yield : (options[:values] || [''])

      cell_options = result.map { {} }
      common_options = {}

      options.each do |k,v|
        # if the option starts with 'cell_#_' then apply it accordingly.
        if (m = cell_regex.match(k.to_s))
          k = k.to_s[m[0].length..-1].to_sym
          cell_options[m[1].to_i - 1][k] = v

        # the 'column' option applies only to the first cell.
        elsif k == :column
          cell_options[0][k] = v

        # everything else applies to all cells, unless overridden explicitly.
        elsif k != :values
          common_options[k] = v
        end
      end

      cell_options.each_with_index do |opt,idx|
        cell common_options.merge(opt).merge( { value: result[idx] } )
      end
    end
def cells(options = {}, &block)
      cell_regex = /^cell_([0-9]+)_/

      options ||= { }

      result = block_given? ? yield : (options[:values] || [''])

      cell_options = result.map { {} }
      common_options = {}

      options.each do |k,v|
        # if the option starts with 'cell_#_' then apply it accordingly.
        if (m = cell_regex.match(k.to_s))
          k = k.to_s[m[0].length..-1].to_sym
          cell_options[m[1].to_i - 1][k] = v

        # the 'column' option applies only to the first cell.
        elsif k == :column
          cell_options[0][k] = v

        # everything else applies to all cells, unless overridden explicitly.
        elsif k != :values
          common_options[k] = v
        end
      end

      cell_options.each_with_index do |opt,idx|
        cell common_options.merge(opt).merge( { value: result[idx] } )
      end
    end
Creates multiple cells.

 Individual cells can be given options by prefixing the keys with 'cell_#' where # is the cell number (starting at 1).

 See #cell for valid options.