Reputation: 27
Status:
gem
called Roo
which should do the opening of the attachmentRoo::Excelx.open()
commandIssue:
Roo::Excel.open()
doesnt work for:
Roo::Excel.open(excel)
Roo::Excel.open(excel.attachment)
What is the correct command to execute to open the ActiveRecord::Attachment
?
Upvotes: 0
Views: 878
Reputation: 27
Actually I got an answer outside of Stackoverflow which was this:
Roo::Spreadsheet.open(ActiveStorage::Blob.service.path_for(excel.key), extension: 'xlsx')
I loaded one row from the Excel so must change code but opening it seemed to have worked! :-)
Upvotes: 1
Reputation: 625
how about do this?
ModelName.excel.open do |file|
xlsx = Roo::Spreadsheet.open(file)
end
Upvotes: 1