martijn / xsv

High performance, lightweight .xlsx parser for Ruby that provides nothing a CSV parser wouldn't
https://storck.io/posts/announcing-xsv-1-0-0/
MIT License
194 stars 20 forks source link

NoMethodError: undefined method `[]' for nil:NilClass #40

Closed fsanggang closed 2 years ago

fsanggang commented 2 years ago

I'm using xsv v1.1.0, and trying to open this file.

The error I get is:

Xsv::Workbook.open(path_to_file)
NoMethodError: undefined method `[]' for nil:NilClass
from /Users/fionasanggang/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/xsv-1.1.0/lib/xsv/sheet.rb:36:in `initialize'

I believe this document was generated using the Open XML SDK 2.5 for Office, due to the<x:worksheet>, <x:sheetData> elements in the sheet.xml file.

Do you have any hints or suggestions?

martijn commented 2 years ago

Thanks for sharing an example! I've identified two issues with this file so far:

Even after resolving those two, there are still no contents returned for the sheet. I assume this also because of XML namespaces. The XML parser is not aware of namespaces because so far every file I've encountered uses the same as standard Office. I will fix this as soon as I can find the time.

martijn commented 2 years ago

@fsanggang I fixed the case for this test file in https://github.com/martijn/xsv/pull/41, could you see if the issue-40 branch resolves all your issues before I merge and release that?

fsanggang commented 2 years ago

Thank you for the quick response @martijn, much appreciated! I will check issue-40 and get back to you asap.

fsanggang commented 2 years ago

@martijn I can confirm your changes in https://github.com/martijn/xsv/pull/41 works and resolves all my issues. Once again - many thanks!

martijn commented 2 years ago

You're welcome! Released Xsv 1.1.1 with the fix.