How to read data from an excel file using ruby Spreadsheet gem file
Pre Requisite : make sure spreadsheet gem file is installed at your machine. if not then installed it using below command
gem install spreadsheet
Code to read an excel file :-
require 'rubygems'
require 'spreadsheet'
filename = '/Users/shashikantrai/Downloads/example.xls'
book = Spreadsheet.open(filename)
sheet1 = book.worksheet 0
sheet1.each 1 do |row|
puts "#{row[0]}"
puts "#{row[1]}"
puts "#{row[2]}"
end
book.io.close
On this page of the site you can watch the video online How to read data from an excel file using ruby with a duration of hours minute second in good quality, which was uploaded by the user Shashikant Rai 29 August 2022, share the link with friends and acquaintances, this video has already been watched 1,223 times on youtube and it was liked by 13 viewers. Enjoy your viewing!