Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_forum
cxt 5 years ago
commit 46f21ceacc

@ -2,8 +2,8 @@
wb = xlsx_package.workbook wb = xlsx_package.workbook
# wb.use_autowidth = false # wb.use_autowidth = false
wb.styles do |s| wb.styles do |s|
sz_all = s.add_style :sz => 10,:border => { :style => :thin, :color =>"000000"},:alignment => {:horizontal => :left} sz_all = s.add_style :sz => 10,:border => { :style => :thin, :color =>"000000"},:alignment => {wrap_text: true,:horizontal => :left}
blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :left} blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :left}
wb.add_worksheet(:name => "统计结果") do |sheet| wb.add_worksheet(:name => "统计结果") do |sheet|
sheet.sheet_view.show_grid_lines = false sheet.sheet_view.show_grid_lines = false
@ -30,25 +30,25 @@ wb.styles do |s|
sheet_answer_row.push(answer_users_count) sheet_answer_row.push(answer_users_count)
sheet_answer_percent.push(answer_percent.to_s) sheet_answer_percent.push(answer_percent.to_s)
end end
sheet.add_row sheet_row, :style => blue_cell sheet.add_row sheet_row, :height =>15,:style => blue_cell
sheet.add_row sheet_answer_row, :style => sz_all sheet.add_row sheet_answer_row, :height =>15, :style => sz_all
sheet.add_row sheet_answer_percent, :style => sz_all sheet.add_row sheet_answer_percent, :height =>15, :style => sz_all
sheet.add_row sheet_answer_useful, :style => sz_all sheet.add_row sheet_answer_useful, :height =>15, :style => sz_all
#合并单元格但无法填充style #合并单元格但无法填充style
# sheet.merge_cells (Axlsx::cell_r(1,sheet.rows.last.row_index) + ':' + Axlsx::cell_r(sheet_row.count-1,sheet.rows.last.row_index)) # sheet.merge_cells (Axlsx::cell_r(1,sheet.rows.last.row_index) + ':' + Axlsx::cell_r(sheet_row.count-1,sheet.rows.last.row_index))
# sheet.rows[sheet.rows.last.row_index].style = sz_all # sheet.rows[sheet.rows.last.row_index].style = sz_all
sheet.add_row [] sheet.add_row []
else #主观题答案 else #主观题答案
main_show_row = ["第#{q.question_number}题",q.question_title] main_show_row = ["第#{q.question_number}题",q.question_title]
sheet.add_row main_show_row, :style => blue_cell sheet.add_row main_show_row,:height =>15, :style => blue_cell
q.poll_votes.each do |v| #主观题的答案 q.poll_votes.each do |v| #主观题的答案
sheet.add_row ["",v.vote_text.present? ? v.vote_text : "--"], :style => sz_all sheet.add_row ["",v.vote_text.present? ? v.vote_text : "--"],:height =>15, :style => sz_all
end end
sheet.add_row [], :style => sz_all sheet.add_row [], :style => sz_all
end end
end #each_with_index end #each_with_index
sheet.add_row poll_users_info, :style => blue_cell sheet.add_row poll_users_info, :height =>15, :style => blue_cell
@poll.poll_users.each_with_index do |u,index| @poll.poll_users.each_with_index do |u,index|
u_user = u.user u_user = u.user
user_answer_array = [] user_answer_array = []
@ -86,7 +86,7 @@ wb.styles do |s|
user_cell += [user_login,user_name, u_user.mail, user_student_id] user_cell += [user_login,user_name, u_user.mail, user_student_id]
end end
all_user_cell = user_cell + user_answer_array all_user_cell = user_cell + user_answer_array
sheet.add_row all_user_cell, :style => sz_all sheet.add_row all_user_cell, :height =>15,:style => sz_all
end end
sheet.column_widths *([25]*sheet.column_info.count) sheet.column_widths *([25]*sheet.column_info.count)
sheet.column_info.first.width = 10 sheet.column_info.first.width = 10

Loading…
Cancel
Save