It is possible to use the axlsx_rails
template renderer to create a string and save it to file:
def basic_report_post
@config = params[:config]
@data = params[:data]
@filename = "#{Rails.root}/public/test.xlsx"
File.open(@filename, 'w') do |f|
f.write render_to_string(handlers: [:axlsx], formats: [:xlsx], template: 'path/to/template')
end
render json: {name: @filename}
end
Then you can use the template to serve the file directly if need be.