1

I have a excel sheet(.xlsx) format which has only text data,I want to count the no of rows as well read the text data from the excel sheet in ruby using win32ole gem only.I have gone through many of the post in stackoverflow which represent these type of question but with the latest gem(spreadsheet,roo,etc).As I use ruby of version 1.8.7 and I want to read the data with win32ole gem.

Ruby Version 1.8.7
windows 7
shaik
  • 143
  • 11

1 Answers1

0
require 'win32ole'

begin
 excel = WIN32OLE.new('Excel.Application')


 workbook = excel.Workbooks.Open('path_to_file')


 w = workbook.Worksheets(1)
 p w.Cells(1,1).Value
 p w.UsedRange.Rows.Count
ensure
 workbook.close
end

hope this helps.

you can loop through cells by changing the indices

Ali Akbar
  • 370
  • 3
  • 9