1
有沒有什麼辦法用ruby,電子表格等寶石獲得ruby中電子表格單元格的位置(座標)?如何在電子表格中的紅寶石軌道上獲取單元格位置?
假設我在第C列和第2行的值爲「TOTAL」。如何使用紅寶石在軌道上獲得這個位置?
任何提示?
有沒有什麼辦法用ruby,電子表格等寶石獲得ruby中電子表格單元格的位置(座標)?如何在電子表格中的紅寶石軌道上獲取單元格位置?
假設我在第C列和第2行的值爲「TOTAL」。如何使用紅寶石在軌道上獲得這個位置?
任何提示?
這裏是袋鼠官方教程http://roo.rubyforge.org/ 一個例子希望這將有助於
HOURLY_RATE = 123.45
oo = Openoffice.new("simple_spreadsheet.ods")
oo.default_sheet = oo.sheets.first
4.upto(12) do |line|
date = oo.cell(line,'A')
start_time = oo.cell(line,'B')
end_time = oo.cell(line,'C')
pause = oo.cell(line,'D')
sum = (end_time - start_time) - pause
comment = oo.cell(line,'F')
amount = sum * HOURLY_RATE
if date
puts "#{date}\t#{sum}\t#{amount}\t#{comment}"
end
end
#http://spreadsheet.rubyforge.org/GUIDE_txt.html
require 'spreadsheet'
book = Spreadsheet.open 'sample.xls'
sheet1 = book.worksheet 0
sheet1.each_with_index do |row, index|
for column in 0..(row.length-1)
puts "Row:- #{index}, Column: #{column}, Value: #{row[column]}"
end
end
你可以發佈你寫到目前爲止代碼? – Salil 2013-03-26 08:09:26