You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/views/graduation_topics/export.xlsx.axlsx

36 lines
2.1 KiB

6 years ago
wb = xlsx_package.workbook
5 years ago
# wb.use_autowidth = false
6 years ago
wb.use_shared_strings = true
wb.styles do |s|
sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
bg_db = s.add_style :bg_color=> "DBEEF4",:border => { :style => :thick, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
bg_d2 = s.add_style :bg_color=> "CCC1DA",:border => { :style => :thick, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
bg_cc = s.add_style :bg_color=> "CCC1DA",:border => { :style => :thick, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
bg_ff = s.add_style :bg_color=> "FFC000",:border => { :style => :thick, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
bg_bb = s.add_style :bg_color=> "9BBB59",:border => { :style => :thick, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
5 years ago
bg_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
6 years ago
wb.add_worksheet(:name => "毕设选题情况汇总") do |sheet|
sheet.sheet_view.show_grid_lines = false
sheet_title = table_columns
sheet_title_c = sheet_title.count
5 years ago
sheet.add_row sheet_title,:height => 30, :style => bg_cell
6 years ago
sheet["J1:L1"].each { |c| c.style = bg_db }
sheet["M1:O1"].each { |c| c.style = bg_cc }
sheet["P1:Q1"].each { |c| c.style = bg_d2 }
sheet["R1:T1"].each { |c| c.style = bg_ff }
sheet["U1:W1"].each { |c| c.style = bg_bb }
if topic_users.count > 0
topic_users.each do |user|
5 years ago
sheet.add_row user,:height => 18, :style => sz_all
6 years ago
end #each_widh_index
else
5 years ago
sheet.add_row ["--"]*sheet_title_c,:height => 18
6 years ago
end
sheet.column_widths *([15]*sheet.column_info.count)
sheet.column_info.first.width = 8
end #add_worksheet
end