kameeoze/jruby-poi — Issue #3: jruby-as corrupt file
Author: rodrigovirgilio
Created: 2011-10-25 14:10:54+00:00
State: open

Error opening file in Microsoft Office (Windows) file corrupted message.
The following changes using the gem 'jruby-poi'.

- controller. rb
def relatorio_candidatos
if params [: candidate]
respond_to do | format |
{format.xls send_data Class.file_name (params [: class] [: object])
: filename => "file_name.xls"
: type => "application / xls"}
end
end
end

- model. rb
require 'poi'

self.method def (object)
candidates Candidato.includes = ([{: person => {: cidade_nascimento =>: state}}: polo: titles,: primeira_opcao,: processo_seletivo]).
where ("= can.id?", object).
all

workbook = POI: Workbook.Open ("# {Rails.root} / lib / file_name.xls")
workbook.worksheets sheet = ["Sheets"]
rows = sheet.rows

...