From 118d27c649cbc0642247d3b1638c4c5a27ec2cff Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 5 Jul 2019 15:45:15 +0800 Subject: [PATCH] fix bug --- app/controllers/homework_commons_controller.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 794ccb228..1318f3b04 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -204,15 +204,17 @@ class HomeworkCommonsController < ApplicationController normal_status(-1,"暂无用户提交!") else respond_to do |format| + format.json{normal_status(0,"000000")} format.xlsx{ student_work_to_xlsx(@work_excel,@homework) exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S') - - render xlsx: "#{exercise_export_name.encode(Encoding.default_external,"UTF-8", :invalid => :replace, :undef => :replace, :replace => " ").strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals: + response.headers['Content-Disposition'] = "attachment; filename=\"#{exercise_export_name.strip.first(30)}\"" + render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals: {table_columns: @work_head_cells,task_users: @work_cells_column} } + # send_data data, :type => 'text/csv', :disposition => 'attachment; filename=my_file_name.csv' - # .encode(Encoding.default_external, 'gb2312') + # .encode(Encoding.default_external, 'gb2312') end end elsif params[:format] == "zip"