active/app/views/admin/actives/export.xlsx.axlsx

67 lines
2.1 KiB
Plaintext

# encoding: utf-8
wb = xlsx_package.workbook
wb.add_worksheet(name: t('module_name.active')) do |sheet|
row = []
row << t('act_signup.name') if !@act.enabled_name.blank?
row << t('act_signup.idno') if !@act.enabled_idno.blank?
row << t('act_signup.sex') if !@act.enabled_sex.blank?
row << t('act_signup.birthday') if !@act.enabled_birthday.blank?
row << t('act_signup.tel') if !@act.enabled_tel.blank?
row << t('act_signup.phone') if !@act.enabled_phone.blank?
row << t('act_signup.fax') if !@act.enabled_fax.blank?
row << t(:email) if !@act.enabled_email.blank?
row << t("act_signup.organization") if !@act.enabled_organization.blank?
row << t("act_signup.title") if !@act.enabled_title.blank?
row << t("act_signup.address") if !@act.enabled_address.blank?
row << t("act_signup.emergency_contact_number") if !@act.enabled_emergency_contact_number.blank?
row << t("act_signup.emergency_contact_person") if !@act.enabled_emergency_contact_person.blank?
row << t("act_signup.vegetarian") if !@act.enabled_vegetarian.blank?
row << t('act.note') if !@act.enabled_note.blank?
sheet.add_row row
@act.act_signups.each do |signup|
row2 = []
row2 << signup.name if !@act.enabled_name.blank?
row2 << signup.idno if !@act.enabled_idno.blank?
row2 << signup.sex if !@act.enabled_sex.blank?
row2 << (signup.birthday.strftime("%Y-%m-%d") rescue "") if !@act.enabled_birthday.blank?
row2 << signup.tel if !@act.enabled_tel.blank?
row2 << signup.phone if !@act.enabled_phone.blank?
row2 << signup.fax if !@act.enabled_fax.blank?
row2 << signup.email if !@act.enabled_email.blank?
row2 << signup.note if !@act.enabled_note.blank?
row2 << signup.organization if !@act.enabled_organization.blank?
row2 << signup.title if !@act.enabled_title.blank?
row2 << signup.address if !@act.enabled_address.blank?
row2 << signup.emergency_contact_number if !@act.enabled_emergency_contact_number.blank?
row2 << signup.emergency_contact_person if !@act.enabled_emergency_contact_person.blank?
row2 << signup.vegetarian if !@act.enabled_vegetarian.blank?
sheet.add_row row2
end
end