Skip to content
This repository was archived by the owner on Nov 23, 2021. It is now read-only.

Selecting the sheet to work with

Ernesto García edited this page Feb 23, 2014 · 2 revisions

Spreadsheet files often have more than one sheet of data, so it is desirable to select which sheet to use when importing. You can provide an importer with the name or index of the sheet to use. By default an importer will read from the first sheet in the spreadsheet.

class EmployeeImporter < ActiveImporter::Base
  imports Employee

  sheet "Employees"

  # ...
end

The importer defined above specifies that data should be read from a sheet named "Employees".

As stated above, sheets can also be specified by name or by index, starting by 1, which is the first sheet. For instance, the following importer will read data from the third sheet, no matter what's its name.

class EmployeeImporter < ActiveImporter::Base
  imports Employee

  sheet 3

  # ...
end
Clone this wiki locally