roo-rb / roo

Roo provides an interface to spreadsheets of several sorts.
MIT License
2.78k stars 503 forks source link

Cannot get real row number when looping data with each_row_streaming #519

Open GoktugOzturk opened 4 years ago

GoktugOzturk commented 4 years ago

Thanks for filing an issue. Following these instructions will help us solve your problem sooner.

Steps to reproduce

  1. Create an excel file that has empty rows between filled rows.
  2. Read the data with each_row_streaming function

Issue

I need to show an error for the filled line which comes after the blank line. The error should specify the row number like this -> "The value on row #[row-number] is invalid." Since the library access Nokogiri::XML::Reader with Nokogiri::XML::ParseOptions::NOBLANKS parameter on each_element utility, empty lines are skipped. Which causes indices to be wrong. Problematic line: https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/utils.rb#L106

Also, the original row number is stored in "r" attribute for each row on the XML file. But since you only return the root data of the row there is no way to access this attribute either.

Possible solutions;

System configuration

Roo version: 2.8.2 Ruby version: 2.6.5