seminar2_old/app/views/admin/seminars/export.xlsx.axlsx

81 lines
2.4 KiB
Plaintext
Raw Normal View History

2016-06-29 06:57:45 +00:00
# encoding: utf-8
wb = xlsx_package.workbook
2020-05-05 13:58:59 +00:00
wb.add_worksheet(name: (@seminar.title.to_s[0..27]+'...')) do |sheet|
2016-06-29 06:57:45 +00:00
row = [t('seminar_signup.signup_time')]
2021-03-29 14:27:08 +00:00
row << t('seminar_signup.serial_number')
2016-06-29 06:57:45 +00:00
row << t('seminar_signup.name')
row << t('seminar_signup.unit')
row << t('seminar_signup.tel')
row << t('seminar_signup.phone')
row << t('seminar_signup.fax')
row << t('seminar_signup.address')
row << t(:email)
row << t('seminar_signup.note')
2023-04-12 03:33:32 +00:00
seminar_signup_fields = @seminar.seminar_signup_fields.where(:disabled=>false).asc(:sort_number, :_id).to_a
seminar_signup_fields.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
2016-06-29 06:57:45 +00:00
end
2022-11-04 04:38:55 +00:00
highlight_style = wb.styles.add_style(
:bg_color => 'ffeb3b',
:b => true,
:border => { :style => :thick, :color => "000000", :edges => [:top, :left, :bottom, :right] },
:alignment => {:horizontal => :center, :vertical => :center, :wrap_text => true}
)
sheet.add_row row, :style => (0...row.count).collect{ highlight_style }
date_time_style = wb.styles.add_style({:format_code => 'yyyy/mm/dd hh:mm', :alignment => {:horizontal => :center, :vertical => :center, :wrap_text => true}})
wrap_text_style = wb.styles.add_style({:alignment => {:horizontal => :center, :vertical => :center, :wrap_text => true}})
types = [:time]
styles = [date_time_style]
@seminar_signups.each_with_index do |signup, i|
2016-06-29 06:57:45 +00:00
row2 = []
2022-11-04 04:38:55 +00:00
row2 << signup.created_at
2021-03-29 14:27:08 +00:00
row2 << "#{signup.display_serial_number}"
2016-06-29 06:57:45 +00:00
row2 << "#{signup[:name]} "
row2 << "#{signup.unit} "
row2 << "#{signup[:tel]} "
row2 << "#{signup[:phone]} "
row2 << "#{signup[:fax]} "
row2 << "#{signup.address} "
row2 << "#{signup[:email]} "
row2 << "#{signup.note} "
2023-04-12 03:33:32 +00:00
seminar_signup_fields.each do |rf|
if rf.can_muti_lang_input?
@site_in_use_locales.each do |l|
2022-11-04 04:38:27 +00:00
row2 << (@seminar.get_attribute_value(rf,signup.id).get_value_by_locale(l) rescue '')
end
else
2022-11-04 04:38:27 +00:00
row2 << (@seminar.get_attribute_value(rf,signup.id).get_value_by_locale(I18n.locale) rescue '')
end
2016-06-29 06:57:45 +00:00
end
2022-11-04 04:38:55 +00:00
if i == 0
(0...(row2.count - 1)).each do |i|
types << :string
styles << wrap_text_style
end
end
sheet.add_row row2 , :types => types, :style => styles
2016-06-29 06:57:45 +00:00
end
end