forked from spen/seminar
Add style to export xlsx file.
This commit is contained in:
parent
452e0e0705
commit
eefb9f92f6
|
@ -33,15 +33,20 @@ wb.add_worksheet(name: (@seminar.title.to_s[0..27]+'...')) do |sheet|
|
|||
row << rf.title
|
||||
end
|
||||
end
|
||||
|
||||
sheet.add_row row
|
||||
|
||||
@seminar_signups.each do |signup|
|
||||
types = {}
|
||||
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|
|
||||
row2 = []
|
||||
|
||||
row2 << "#{signup.created_at} "
|
||||
types[1] = :string
|
||||
row2 << signup.created_at
|
||||
row2 << "#{signup.display_serial_number}"
|
||||
row2 << "#{signup[:name]} "
|
||||
row2 << "#{signup.unit} "
|
||||
|
@ -51,7 +56,6 @@ wb.add_worksheet(name: (@seminar.title.to_s[0..27]+'...')) do |sheet|
|
|||
row2 << "#{signup.address} "
|
||||
row2 << "#{signup[:email]} "
|
||||
row2 << "#{signup.note} "
|
||||
|
||||
@seminar.seminar_signup_fields.asc(:_id).each do |rf|
|
||||
if rf.can_muti_lang_input?
|
||||
@site_in_use_locales.each do |l|
|
||||
|
@ -61,10 +65,14 @@ wb.add_worksheet(name: (@seminar.title.to_s[0..27]+'...')) do |sheet|
|
|||
row2 << (@seminar.get_attribute_value(rf,signup.id).get_value_by_locale(I18n.locale) rescue '')
|
||||
end
|
||||
end
|
||||
types = (0...row2.count).map{|i| types[i]}
|
||||
sheet.add_row row2 , :types => types
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue