I am trying to open a spreadsheet stored remotely using the Ruby Spreadsheet gem. My code is as follows
require 'spreadsheet'
require 'open-uri'
book = Spreadsheet.open(url)
It is returning me an error of Errno::ENOENT: No such file or directory
By putting the url into the browser, it downloads fine, so I know the url is fine. I have some very similar code using FasterCSV which works absolutely fine, so wandering if this is an issue with Spreadsheet, or I’m doing something wrong.
You’re not using
open-uri, which will fetch the URL and expose it as aStringIOobject (which works like anIOobject in most cases). TheSpreadsheetclass may work if you do this instead:The second
openis fromOpenURIwhich will send theStringIOobject toSpreadsheet.open.