Ruby Spreadsheet not opening remote file

ruby, ruby-on-rails, spreadsheet

Solution

You're not using `open-uri`, which will fetch the URL and expose it as a `StringIO` object (which works like an `IO` object in most cases). The `Spreadsheet` class may work if you do this instead:

book = Spreadsheet.open(open(url))

The second `open` is from `OpenURI` which will send the `StringIO` object to `Spreadsheet.open`.

Problem

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.

Original source