2013-03-25 3 views
1

루이, 스프레드 시트 등과 같은 보석을 사용하여 레일의 루비에서 스프레드 시트 셀의 위치 (좌표)를 얻을 수있는 방법이 있습니까?레일에서 루비의 스프레드 시트에서 셀 위치를 가져 오는 방법은 무엇입니까?

C 열 및 두 번째 행에 "TOTAL"값이 있다고 가정합니다. 루비를 레일로 사용하여이 위치를 얻는 방법?

힌트가 있습니까? 여기

+0

당신이 지금까지 작성한 코드를 게시 할 수 도움이 될 희망 루 공식 자습서 http://roo.rubyforge.org/ 에서 예이다 ?? – Salil

답변

0

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 
1
#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 
관련 문제