woahdae / simple_xlsx_reader

Ruby xlsx reader to parse cell values into plain ruby primitives and dates/times.
MIT License
182 stars 55 forks source link

Error when opening .xlsx files #50

Open rodrigomageste opened 1 year ago

rodrigomageste commented 1 year ago

I hope this message finds you well. Firstly, I'd like to express my gratitude for the efforts put into maintaining the SimpleXlsxReader gem – it's been a valuable tool for many.

I've come across an issue while utilizing the gem that I believe needs your attention. The problem arises when I attempt to run the following code snippet:

doc = SimpleXlsxReader.open("tmp/filename.xlsx")

This line of code triggers an error message: RuntimeError: Zip::ZipFile.open_buffer expects an argument of class String or IO. Found: File. After investigating the source of the issue, it seems that the root cause lies within the loader.rb file, precisely at this line.

My solution to this problem was to modify the line SimpleXlsxReader::Zip.open_buffer(string_or_io) to SimpleXlsxReader::Zip.open(string_or_io). This change effectively resolves the issue and allows the code to run smoothly.

I believe this small tweak could prevent similar errors for other users as well. I wanted to bring this to your attention so that it can be reviewed and addressed appropriately.

rodrigomageste commented 1 year ago

My Gemfile.lock:

simple_xlsx_reader (5.0.0)
  nokogiri
  rubyzip
rubyzip (1.0.0)
nokogiri (1.13.9)
marcelohenriq99 commented 1 year ago

I have same issue, i think this solution looks good!

gammons commented 3 weeks ago

This causes the tests to break and also causes breakages with real-world testing.