From a8fb8c32f3688efe360d748d3af6769aef7971c0 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 26 Jun 2019 16:43:06 +0800 Subject: [PATCH 1/3] fix bug --- app/views/polls/commit_result.xlsx.axlsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/polls/commit_result.xlsx.axlsx b/app/views/polls/commit_result.xlsx.axlsx index be27d73c5..f949af10a 100644 --- a/app/views/polls/commit_result.xlsx.axlsx +++ b/app/views/polls/commit_result.xlsx.axlsx @@ -30,19 +30,19 @@ 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 =>20,:style => blue_cell + sheet.add_row sheet_answer_row, :height =>20, :style => sz_all + sheet.add_row sheet_answer_percent, :height =>20, :style => sz_all + sheet.add_row sheet_answer_useful, :height =>20, :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 =>20, :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 =>20, :style => sz_all end sheet.add_row [], :style => sz_all end @@ -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 =>20,:style => sz_all end sheet.column_widths *([25]*sheet.column_info.count) sheet.column_info.first.width = 10 From 7b51084c374cc83188ee4de02cfa9f496f72df22 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 26 Jun 2019 16:49:00 +0800 Subject: [PATCH 2/3] fix bug --- app/views/polls/commit_result.xlsx.axlsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/polls/commit_result.xlsx.axlsx b/app/views/polls/commit_result.xlsx.axlsx index f949af10a..9c91b63a0 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 From 6b66be9e60b26ff522dd79307060f40bc2649ffd Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 26 Jun 2019 16:52:05 +0800 Subject: [PATCH 3/3] fix bug --- app/views/polls/commit_result.xlsx.axlsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/polls/commit_result.xlsx.axlsx b/app/views/polls/commit_result.xlsx.axlsx index 9c91b63a0..3ea0571cb 100644 --- a/app/views/polls/commit_result.xlsx.axlsx +++ b/app/views/polls/commit_result.xlsx.axlsx @@ -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, :height =>20,:style => blue_cell - sheet.add_row sheet_answer_row, :height =>20, :style => sz_all - sheet.add_row sheet_answer_percent, :height =>20, :style => sz_all - sheet.add_row sheet_answer_useful, :height =>20, :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,:height =>20, :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 : "--"],:height =>20, :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, :height =>20,: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