Status:
gem
called Roo
which should do the opening of the attachmentRoo::Excelx.open()
command Issue: 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
?
how about do this?
ModelName.excel.open do |file|
xlsx = Roo::Spreadsheet.open(file)
end
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: :-)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.