Cell.rb

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

このスクリプトは roo によるExcelセル読み取りです。Roo::Excelx.new で book.xlsx を開き、sheet('mysheet') で対象シートを選択します。cell(行, 列) は1始まり(A1 = cell(1,1))で個々のセルを参照でき、last_row / last_column でデータの末端位置も取得できます。

require 'roo'
#=> true

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.cell(1,1)
#=> "key"
sh1.cell(1,2)
#=> "value"
sh1.last_row
#=> 7
sh1.last_column
#=> 2

Ruby 4.0.6