2020-01-31 10:52:53 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
wb = xlsx_package.workbook
|
|
|
|
wb.add_worksheet(name: "school_class") do |sheet|
|
|
|
|
row = []
|
|
|
|
title = sheet.styles.add_style(:bg_color => "FFFF00",:border=>{ :style => :thin, :color => "666666" },:alignment=>{ :horizontal => :center,:vertical => :center ,:wrap_text => true})
|
|
|
|
column = sheet.styles.add_style(:alignment=>{ :horizontal => :center,:vertical => :center ,:wrap_text => true},:border=>{ :style => :thin, :color => "666666" })
|
|
|
|
@fields = [ "school_code", "school_name" , "school_address" ,"class_number","enrollment_limited","school_contact_person_name","department_job_title","office_tel_number","fax","mobile_number","email","enrollment"]
|
|
|
|
@fields.each do |field|
|
|
|
|
row << t('olympiamanagement.'+field)
|
|
|
|
end
|
|
|
|
#export data start
|
|
|
|
export_data_rows = []
|
|
|
|
@OlympiaSchoolDataFields.each do |school_data_field|
|
|
|
|
temp_row = []
|
|
|
|
@fields.each do |field_key|
|
2020-02-18 13:37:10 +00:00
|
|
|
temp_row << (school_data_field[field_key].to_s rescue '')
|
2020-01-31 10:52:53 +00:00
|
|
|
end
|
|
|
|
export_data_rows << temp_row
|
|
|
|
end
|
|
|
|
|
|
|
|
#export data end
|
2020-02-18 13:37:10 +00:00
|
|
|
sheet.add_row row , :style=> title,:widths => row.map{|cell| (cell.length* 11/ 2).round} , :types => :string
|
2020-01-31 10:52:53 +00:00
|
|
|
export_data_rows.each do |infos_row|
|
2020-02-18 13:37:10 +00:00
|
|
|
sheet.add_row infos_row , :style=> column , :types => :string
|
2020-01-31 10:52:53 +00:00
|
|
|
end
|
|
|
|
end
|