change download school code file format from xlsx to ods using soffice.

This commit is contained in:
BOHUNG 2020-03-14 13:17:04 +08:00
parent 0ef80b8848
commit 18f2d1cd69
1 changed files with 2 additions and 2 deletions

View File

@ -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")