使用RubyXL,我想知道迭代的行号。
workbook = RubyXL::Parser.parse("./file.xlsx")
worksheet = workbook[0]
worksheet.each do |row|
test0 = row[0].value
line = ????
puts "Line number #{line} - Value = #{test0}"
end
您可以#each_with_index
像这样使用和编写它:
workbook = RubyXL::Parser.parse("./file.xlsx")
workbook.first.each_with_index do |row, index|
puts "Line number #{index} - Value = #{row[0].value}"
end
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句