To_array.rb

This content was produced by an LLM and could include errors.

This script uses the roo gem to read data from an Excel file. It processes the “mysheet” and efficiently loads all row data into a two-dimensional Ruby array.

require 'roo'
#=> true

two_dimensional = []
#=> []
xlsx = Roo::Excelx.new('input/roo/book.xlsx')
#=> <#Roo::Excelx:2030 @tmpdir @shared @filename @sheet_files @sheet_names @sheets @...
sh1 = xlsx.sheet('mysheet')
#=> <#Roo::Excelx:2030 @tmpdir @shared @filename @sheet_files @sheet_names @sheets @...
sh1.each do |row|
  two_dimensional << row
end
#=> 1
two_dimensional
#=> [["key", "value"],
 [1.0, "a"],
 [2.0, "b"],
 [3.0, "c"],
 [4.0, "d"],
 [5.0, "e"],
 [6.0, "f"]]

Ruby 4.0.3