venue_management/app/views/admin/venue_managements/export.xlsx.axlsx

67 lines
1.6 KiB
Plaintext
Raw Normal View History

2020-05-07 15:26:34 +00:00
# encoding: utf-8
wb = xlsx_package.workbook
wb.add_worksheet(name: (@venue_management.title.to_s[0..27]+'...')) do |sheet|
row = [t('venue_management_signup.signup_time')]
row << t('venue_management_signup.name')
row << t('venue_management_signup.unit')
row << t('venue_management_signup.tel')
row << t('venue_management_signup.phone')
row << t('venue_management_signup.fax')
row << t('venue_management_signup.address')
row << t(:email)
row << t('venue_management_signup.note')
@venue_management.venue_management_signup_fields.asc(:_id).each do |rf|
if rf.can_muti_lang_input?
@site_in_use_locales.each do |l|
row << rf.title + " (#{t(l.to_s)})"
end
else
row << rf.title
end
end
sheet.add_row row
@venue_management.venue_management_signups.each do |signup|
row2 = []
row2 << "#{signup.created_at} "
row2 << "#{signup[:name]} "
row2 << "#{signup.unit} "
row2 << "#{signup[:tel]} "
row2 << "#{signup[:phone]} "
row2 << "#{signup[:fax]} "
row2 << "#{signup.address} "
row2 << "#{signup[:email]} "
row2 << "#{signup.note} "
@venue_management.venue_management_signup_fields.asc(:_id).each do |rf|
if rf.can_muti_lang_input?
@site_in_use_locales.each do |l|
row2 << nl2br(show_attribute_value(@venue_management.get_attribute_value(rf,signup.id).get_value_by_locale(l))) rescue ' '
end
else
row2 << nl2br(show_attribute_value(@venue_management.get_attribute_value(rf,signup.id).get_value_by_locale(I18n.locale))) rescue ' '
end
end
sheet.add_row row2
end
end