From 685aa0ce6c7362ae695a08bd08663589c191830f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Thu, 21 Mar 2024 22:47:13 +0800 Subject: [PATCH] Fix bug. --- app/controllers/admin/coloncancerpredict1s_controller.rb | 4 ++-- .../_export_cancer_tool_record.xlsx.axlsx | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/coloncancerpredict1s_controller.rb b/app/controllers/admin/coloncancerpredict1s_controller.rb index 1fc8730..e34891b 100644 --- a/app/controllers/admin/coloncancerpredict1s_controller.rb +++ b/app/controllers/admin/coloncancerpredict1s_controller.rb @@ -623,14 +623,14 @@ class Admin::Coloncancerpredict1sController < OrbitAdminController @pagination = create_pagination(@page_num.to_i) end def export_cancer_tool_record - @cancer_records = Coloncancerpredictrecord1.where("title"=>@app_title).desc(:id) + cancer_records = Coloncancerpredictrecord1.where("title"=>@app_title).desc(:id) dir_path = 'tmp/cancer_tool/' #FileUtils.rm_r(dir_path, :force => true) if Dir.exist?(dir_path) FileUtils.mkdir dir_path if !Dir.exist?(dir_path) #create dir for storing tmp_file if dir doesn't exist @filename = ("#{Time.now.year}_%02s_%02s_export_cancer_tool_record.xlsx"%[Time.now.month,Time.now.day]).gsub(" ","0") Dir.chdir(dir_path) do File.open(@filename, 'w') do |f| - f.write render_to_string( :handlers=> [:axlsx], :formats=> [:xlsx] ,:partial=> 'export_cancer_tool_record.xlsx',:locals=> {:@results=>@cancer_records} ) + f.write render_to_string( :handlers=> [:axlsx], :formats=> [:xlsx] ,:partial=> 'export_cancer_tool_record.xlsx',:locals=> {:results=>cancer_records} ) end end tmp_filename_data = File.read(dir_path +@filename) diff --git a/app/views/admin/coloncancerpredict1s/_export_cancer_tool_record.xlsx.axlsx b/app/views/admin/coloncancerpredict1s/_export_cancer_tool_record.xlsx.axlsx index 2194236..5b87313 100644 --- a/app/views/admin/coloncancerpredict1s/_export_cancer_tool_record.xlsx.axlsx +++ b/app/views/admin/coloncancerpredict1s/_export_cancer_tool_record.xlsx.axlsx @@ -2,18 +2,18 @@ wb = xlsx_package.workbook wb.add_worksheet(name: "cancer_tool") do |sheet| - if !@results[0].nil? + if !results[0].nil? row = [] title = sheet.styles.add_style(:bg_color => "FFFF00",:border=>{ :style => :thin, :color => "666666" },:alignment=>{ :horizontal => :center,:vertical => :center ,:wrap_text => true}) column = sheet.styles.add_style(:alignment=>{ :horizontal => :center,:vertical => :center ,:wrap_text => true},:border=>{ :style => :thin, :color => "666666" }) row << ((I18n.locale=="en") ? 'submit time' : '提亀時間') - @fields = @results.first.names.keys + @fields = results.first.names.keys @fields.each do |field_name| - row << @results.first.names[field_name][I18n.locale.to_s].split('
')[0] + row << results.first.names[field_name][I18n.locale.to_s].split('
')[0] end #export data start export_data_rows = [] - @results.each do |result| + results.each do |result| temp_row = [] temp_row << result.created_at.to_s result.result.each do |key,value|