Closed sechix closed 6 years ago
Since axlsx_rails is a slim wrapper over the Axlsx gem, there is no option to provide xls. When I have needed xls on older office machines, I have installed the free xlsx converter from Microsoft. It limits what you can do, and sometimes throws corruption errors, but you can usually provide a simple solution.
I do not know of any way to specify the download path. As it is, it is pretty hard to force a "Save as" window in all circumstances.
Finally I found a solution: Using these code you download .xls in the path that you choose: @filename = "C:/hermes/entrada/envios/#{@order.shipments.last.number}.xls" File.open(@filename, 'w') do |f| f.write render_to_string(handlers: [:axlsx], formats: [:xlsx], template: '/spree/admin/shipexcel/index.xlsx.axlsx', layout: false) end
I think you'll find that gave you the file extension, but the contents of the file are still in the xlsx format. Try opening it on an old version of Office to be sure.
If exporting xls is very important to you, you may have to create a separate export using something like this: https://github.com/zdavatz/spreadsheet
Are the options to download format in .xls not .xlsx. And to specify the path (directory) to save downloaded file?