0

I'm trying to work with excel files(xlsx) in ruby using rubyXl. I have no problem writing but can't get to output the content of a cell.

require 'rubyXL'
workbook = RubyXL::Workbook.new
workbook.worksheets[0].add_cell(5,5,"test")
workbook.write("file3.xlsx")
getcell = RubyXL::Parser.parse("file3.xlsx")
print getcell[0][5][5]

When I run it in cmd I just get this and it changes every time I run the code.

D:\KEA\1.semester\Exams\IT exam>ruby test.rb
#<RubyXL::Cell:0x2e4a600>

SOLUTION:

After reading a few more times I found the answer in

http://rubydoc.info/gems/rubyXL/1.1.12/RubyXL/Cell

It should have been

print getcell[0][5][5].value
jvvpc
  • 3
  • 1
  • 5
  • Everything is correct: you want to print the instance of `Cell` and you get it printed. Try to take a look at the documentation on `Cell` class within `rubyXL`, it should’ve a method for retrieving a value itself. – Aleksei Matiushkin Nov 26 '13 at 10:57
  • After I looked for the 5th time I found it. Had to add .value cheers – jvvpc Nov 26 '13 at 11:24

1 Answers1

0

After reading a few more times I found the answer in

http://rubydoc.info/gems/rubyXL/1.1.12/RubyXL/Cell

It should have been

print getcell[0][5][5].value
jvvpc
  • 3
  • 1
  • 5