class Array def to_xls(options = {}) output = '' if self.any? attributes = self.first.attributes.keys.map { |c| c.to_sym } if options[:only] # the "& attributes" get rid of invalid columns columns = options[:only].to_a & attributes else columns = attributes - options[:except].to_a end columns += options[:methods].to_a if columns.any? unless options[:headers] == false output << "" columns.each { |column| output << "#{self.class.human_attribute_name(column)}" } output << "" end self.each do |item| output << "" columns.each { |column| output << "#{item.send(column)}" } output << "" end end end output << '
' end end