app/views/admin/university/organizations/index.xlsx.axlsx
wb = xlsx_package.workbook
wb.add_worksheet(name: "index") do |sheet|
options = [
University::Organization::Localization.human_attribute_name('name'),
University::Organization::Localization.human_attribute_name('address_name'),
University::Organization.human_attribute_name('address'),
University::Organization::Localization.human_attribute_name('address_additional'),
University::Organization.human_attribute_name('zipcode'),
University::Organization.human_attribute_name('city'),
University::Organization.human_attribute_name('country'),
University::Organization.human_attribute_name('kind'),
University::Organization.human_attribute_name('siren'),
University::Organization.human_attribute_name('phone'),
University::Organization::Localization.human_attribute_name('url'),
University::Organization.human_attribute_name('email'),
University::Organization::Localization.human_attribute_name('linkedin'),
University::Organization::Localization.human_attribute_name('twitter'),
University::Organization.human_attribute_name('categories')
]
types = [
:string,
:string,
:string,
:string,
:string,
:string,
:string,
:string,
:string,
:string,
:string,
:string,
:string,
:string,
:string,
:string
]
sheet.add_row options, types: Array.new(types.length) { |_| :string }
@organizations.each do |organization|
l10n = organization.best_localization_for(current_language)
infos = [
l10n.name,
l10n.address_name,
organization.address,
l10n.address_additional,
organization.zipcode,
organization.city,
organization.country_name,
organization.kind_i18n,
organization.siren,
organization.phone,
l10n.url,
organization.email,
l10n.linkedin,
l10n.twitter.present? ? "@#{l10n.twitter}" : '',
organization.categories.map { |category| category.to_s_in(current_language) }.join(', ')
]
sheet.add_row infos, types: types
end
end