diff --git a/app/controllers/admin/cancerpredicts_controller.rb b/app/controllers/admin/cancerpredicts_controller.rb
index 6c086d9..dba1238 100644
--- a/app/controllers/admin/cancerpredicts_controller.rb
+++ b/app/controllers/admin/cancerpredicts_controller.rb
@@ -623,14 +623,14 @@ class Admin::CancerpredictsController < OrbitAdminController
@pagination = create_pagination(@page_num.to_i)
end
def export_cancer_tool_record
- @cancer_records = Cancerpredictrecord.where("title"=>@app_title).desc(:id)
+ cancer_records = Cancerpredictrecord.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/cancerpredicts/_export_cancer_tool_record.xlsx.axlsx b/app/views/admin/cancerpredicts/_export_cancer_tool_record.xlsx.axlsx
index 2194236..5b87313 100644
--- a/app/views/admin/cancerpredicts/_export_cancer_tool_record.xlsx.axlsx
+++ b/app/views/admin/cancerpredicts/_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|