From 18f2d1cd69e8459224ce23330f9d047f3097417e Mon Sep 17 00:00:00 2001 From: BOHUNG Date: Sat, 14 Mar 2020 13:17:04 +0800 Subject: [PATCH] change download school code file format from xlsx to ods using soffice. --- app/controllers/olympiamanagements_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/olympiamanagements_controller.rb b/app/controllers/olympiamanagements_controller.rb index d4ef069..6b28e45 100644 --- a/app/controllers/olympiamanagements_controller.rb +++ b/app/controllers/olympiamanagements_controller.rb @@ -319,8 +319,8 @@ class OlympiamanagementsController < ApplicationController f.write render_to_string( :handlers=> [:axlsx], :formats=> [:xlsx] ,:partial=> 'school_code.xlsx',:locals=> {:@OlympiaSchoolDataFields=>@OlympiaSchoolDataFields} ) end end - tmp_filename_data = File.read(dir_path +@filename) - send_data(tmp_filename_data, type: 'application/xlsx', disposition: 'attachment', filename: "#{Time.now.year}#{Time.now.month}#{Time.now.day}_download_school_code.xlsx") + system("soffice --headless --convert-to ods #{dir_path +@filename} -outdir #{dir_path}") + send_file(dir_path +@filename[0..@filename.rindex('.')]+'ods') end def render_contents_in_index_page(contents=@breadcumb) doc = Nokogiri::HTML(render_final_page("page",Page.where(:layout=>"olympia_managements_index").first,true), nil, "UTF-8")