lib/exporters/excel_exporter.rb in datashift-0.8.0 vs lib/exporters/excel_exporter.rb in datashift-0.9.0

- old
+ new

@@ -25,23 +25,28 @@ end # Create an Excel file from list of ActiveRecord objects def export(records, options = {}) + + raise ArgumentError.new('Please supply array of records to export') unless records.is_a? Array excel = JExcelFile.new() if(options[:sheet_name] ) excel.create_sheet( options[:sheet_name] ) else excel.create_sheet( records.first.class.name ) end - + excel.ar_to_headers(records) excel.ar_to_xls(records) + + # => :methods => List of methods to additionally export on each record + excel.save( filename() ) end # Create an Excel file from list of ActiveRecord objects # Specify which associations to export via :with or :exclude @@ -88,10 +93,9 @@ end excel.set_headers( headers ) - row_index = 1 items.each do |datum| excel.create_row(row_index += 1) excel.ar_to_xls_row(1, datum) \ No newline at end of file