实训反馈导出excel

dev_haigong
daiao 6 years ago
parent 44bd6bfd8a
commit 03ff875279

@ -4065,23 +4065,25 @@ end
sheet1.row(0).default_format = blue sheet1.row(0).default_format = blue
count_row = 1 count_row = 1
shixuns = Shixun.where(:id => shixun_ids).includes(discusses: [:user]) shixuns = Shixun.where(:id => shixun_ids).includes(discusses: [:user])
sheet1.row(0).concat(["序号", "实训ID", "实训名称","评论数", "评论内容", "关卡", "评论者", "评论者职业", sheet1.row(0).concat(["序号", "实训ID", "实训名称", "实训作者", "作者单位", "评论数", "评论内容", "关卡", "评论者", "评论者职业",
"评论者单位", "评论时间", "社区导师是否已回复"]) "评论者单位", "评论时间", "社区导师是否已回复"])
shixuns.each_with_index do |shixun, i| shixuns.each_with_index do |shixun, i|
discusses = shixun.discusses.where("user_id != ?", 1) discusses = shixun.discusses.where("user_id != ?", 1)
sheet1[count_row, 0] = i + 1 sheet1[count_row, 0] = i + 1
sheet1[count_row, 1] = shixun.identifier sheet1[count_row, 1] = shixun.identifier
sheet1[count_row, 2] = shixun.name sheet1[count_row, 2] = shixun.name
sheet1[count_row, 3] = discusses.count sheet1[count_row, 3] = shixun.owner.show_real_name
sheet1[count_row, 4] = shixun.owner.school_name
sheet1[count_row, 5] = discusses.count
discusses.each_with_index do |discuss, j| discusses.each_with_index do |discuss, j|
user = discuss.user user = discuss.user
sheet1[count_row, 4] = discuss.content.gsub(/<img.*\/>/, "【图片评论】").gsub(/!\[\].+\)/, "【图片评论】") sheet1[count_row, 6] = discuss.content.gsub(/<img.*\/>/, "【图片评论】").gsub(/!\[\].+\)/, "【图片评论】")
sheet1[count_row, 5] = "#{discuss.position}" sheet1[count_row, 7] = "#{discuss.position}"
sheet1[count_row, 6] = user.show_real_name sheet1[count_row, 8] = user.show_real_name
sheet1[count_row, 7] = user.identity sheet1[count_row, 9] = user.identity
sheet1[count_row, 8] = user.school_name sheet1[count_row, 10] = user.school_name
sheet1[count_row, 9] = format_time discuss.created_at sheet1[count_row, 11] = format_time discuss.created_at
sheet1[count_row, 10] = discuss.children.pluck(:user_id).include?(1) ? "" : "" sheet1[count_row, 12] = discuss.children.pluck(:user_id).include?(1) ? "" : ""
count_row += 1 count_row += 1
end end
#count_row += 1 #count_row += 1

Loading…
Cancel
Save