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/polls/commit_result.xlsx.axlsx

40 lines
1.4 KiB

6 years ago
wb = xlsx_package.workbook
6 years ago
# wb.use_autowidth = false
6 years ago
wb.styles do |s|
6 years ago
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}
6 years ago
wb.add_worksheet(:name => "统计结果") do |sheet|
sheet.sheet_view.show_grid_lines = false
sub_commit = polls_user_commit[:sub_commit]
poll_user_info = polls_user_commit[:poll_users_info]
user_commit = polls_user_commit[:user_commit]
6 years ago
6 years ago
if sub_commit&.size > 0
sub_commit.each do |sub|
main_sub_title = sub[:sub_title]
main_sub_content = sub[:sub_user_votes]
sheet.add_row main_sub_title,:height =>15, :style => blue_cell
if main_sub_content.present?
main_sub_content.each do |con|
sheet.add_row con,:height =>15, :style => sz_all
end
6 years ago
end
sheet.add_row []
6 years ago
end
end
sheet.add_row poll_user_info, :height =>15, :style => blue_cell
6 years ago
if user_commit&.size > 0
user_commit.each do |com|
sheet.add_row com, :height =>15,:style => sz_all
6 years ago
end
end
sheet.column_widths *([25]*sheet.column_info.count)
sheet.column_info.first.width = 15
6 years ago
end #add_worksheet
end