diff --git a/app/views/polls/commit_result.xlsx.axlsx b/app/views/polls/commit_result.xlsx.axlsx index be27d73c5..3ea0571cb 100644 --- a/app/views/polls/commit_result.xlsx.axlsx +++ b/app/views/polls/commit_result.xlsx.axlsx @@ -2,8 +2,8 @@ wb = xlsx_package.workbook # wb.use_autowidth = false wb.styles do |s| - sz_all = s.add_style :sz => 10,: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 => {: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 => {wrap_text: true,:horizontal => :left} wb.add_worksheet(:name => "统计结果") do |sheet| sheet.sheet_view.show_grid_lines = false @@ -30,25 +30,25 @@ wb.styles do |s| sheet_answer_row.push(answer_users_count) sheet_answer_percent.push(answer_percent.to_s) end - sheet.add_row sheet_row, :style => blue_cell - sheet.add_row sheet_answer_row, :style => sz_all - sheet.add_row sheet_answer_percent, :style => sz_all - sheet.add_row sheet_answer_useful, :style => sz_all + sheet.add_row sheet_row, :height =>15,:style => blue_cell + sheet.add_row sheet_answer_row, :height =>15, :style => sz_all + sheet.add_row sheet_answer_percent, :height =>15, :style => sz_all + sheet.add_row sheet_answer_useful, :height =>15, :style => sz_all #合并单元格,但无法填充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.rows[sheet.rows.last.row_index].style = sz_all sheet.add_row [] else #主观题答案 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| #主观题的答案 - 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 sheet.add_row [], :style => sz_all end 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| u_user = u.user user_answer_array = [] @@ -86,7 +86,7 @@ wb.styles do |s| user_cell += [user_login,user_name, u_user.mail, user_student_id] end 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 sheet.column_widths *([25]*sheet.column_info.count) sheet.column_info.first.width = 10