-
Notifications
You must be signed in to change notification settings - Fork 503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using StringIO with Roo and XLSX fails. #360
Comments
Don't know how relevant it is to this issue but ran into a similar issue using roo, will mention it anyways I was using I fixed it by forcing |
typical uscase - in testing responses:
|
@stevendaniels @paneq Thanks |
@paneq What is a good workaround for this exact usecase? |
To answer my own question for a workaround (using
|
@momolog file = Tempfile.new(['excel', '.xlsx'])
file.write response.body
file.close
Roo::Excelx.new(file.path) 2.6.3 :021 > Roo::Excelx.new(file.path) It warns my gem file gem 'roo', '~> 2.7.0'
gem 'roo-xls', '~> 1.2.0'
gem 'spreadsheet', '~> 1.2.4' |
I think you need to pass your file to file = Tempfile.new(['excel', '.xlsx'])
file.write response.body
file.rewind
excel = Roo::Excelx.new(file.path)
# Do what you want with the excel file
# Close and unlink the file
file.close
file.unlink |
I was able to address this issue by using Roo::Spreadsheet(string_io, extension: :xlsx) My scenario is a bit different though, I'm using a gem for downloading an S3 objects from Amazon that come through as StringIO. However this solution will like help others who end up here. |
I discovered this issue in current versions of Roo while looking into #264.
When a
StringIO
is used, Roo fails to open the file properly. This failure stems from the fact thatRoo::Excelx::Extractor
(and its child classes) do not properly handle streams.Based on the
CHANGELOG.md
, this behavior has been broken since at least Roo2.2.0
.The text was updated successfully, but these errors were encountered: