require 'win32ole'
excel = WIN32OLE.new("excel.application")
workbook = excel.Workbooks.Open('D:/test1.xls')
worksheet = workbook.Worksheets("test1")
worksheet.Select
row = worksheet.usedrange.rows.count
column = worksheet.usedrange.columns.count
worksheet.usedrange.each{|cell|
puts cell.value
}
for i in 1..row do
for j in 1..column do
puts worksheet.usedrange.cells(i,j).value
end
end
workbook.close
excel.Quit
网友评论