zdavatz / spreadsheet

The Ruby Spreadsheet by ywesee GmbH
http://spreadsheet.ch
GNU General Public License v3.0
1.13k stars 240 forks source link

`worksheet[0]` and `worksheet.first` behave differently #152

Closed dunn closed 7 years ago

dunn commented 8 years ago

Given this rows.rb:

require "spreadsheet"

book = (Spreadsheet.open "#{ENV["HOME"]}/test/spreadsheet/test.xls")

book.worksheets.each do |sheet|
  sheet.each do |row|
    row.each_with_index do |cell, i|
      next if cell.nil?
      puts "#{sheet[0, i]}: #{cell.inspect}"
      puts "#{sheet.first[i]}: #{cell.inspect}"
    end
  end
end

And the following test.xls screen shot 2015-11-02 at 12 30 11 pm

The expected output of bundle exec ruby rows.rb is

header: "header"
header: "header"
header: "celldata"
header: "celldata"

But the actual output is

: "header"
header: "header"
: "celldata"
header: "celldata"
zdavatz commented 8 years ago

What Ruby Version and what OS are you using? With what are you viewing the XLS file? Which software created the test.xls?

dunn commented 8 years ago

Ah, sorry.

zdavatz commented 8 years ago

Ok. Please try this with LibreOffice 5.0.x on Mac. Excel on Mac is not really supported.

dunn commented 8 years ago

Afraid to say I get the same result with LibreOffice 5.0.2.2.

zdavatz commented 8 years ago

Do you have a recommendation what there is to do as a solution?

dunn commented 7 years ago

Do you have a recommendation what there is to do as a solution?

I just assumed the solution would be to make them behave the same.

zdavatz commented 7 years ago

You mean Excel for Mac and Windows?

dunn commented 7 years ago

I mean for worksheet[0] and worksheet.first to do the same thing.

zdavatz commented 7 years ago

you want a new method for that?

zdavatz commented 7 years ago

I will send you an invite to Slack so we can continue our discussion there.

dunn commented 7 years ago

I'm not using this gem regularly anymore, so I'm not sure how much help I'll be.

zdavatz commented 7 years ago

ok!