Je suis en train de générer un fichier Excel en arrière-plan en utilisant axlsx et enregistrez-le (Rails4.2). Dans la page GitHub de axlsx, il est dit As of Rails 4.1 you must use render_to_string to render a mail attachment
. Cependant, il me renvoie une erreur NoMethodError: undefined method 'render_to_string' for #<CreateExcelSheetWorker:0x007fbccf51db30>
Enregistrer fichier XLSX sur le disque dans Sidekiq en arrière-plan
Ma classe ouvrière:
class CreateExcelSheetWorker
include Sidekiq::Worker
include Sidetiq::Schedulable
recurrence { daily }
def perform()
model = SomeModel.where(wanted: true).order(started_at: :desc)
xlsx = render_to_string handlers: [:axlsx], formats: [:xlsx], template: "template/file", locals: {model: model}
path = "/tmp/a.xlsx"
File.open(path, "w+") do |f|
f.write(xlsx)
end
end
end
Je ne peux pas comprendre comment résoudre ce problème, toute aide appréciée.
La page Liées est pour 'axlsx_rails', pas 'axlsx', ce sont des gemmes différentes –