# You can get data from http://spreadsheets.google.com/pub?key=p7dQJMn9Y4pU59GOICSvNTA oo = Openoffice.new("simple_spreadsheet.ods") oo.default_sheet = oo.sheets.first 4.upto(oo.last_row) 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
#-- create a new spreadsheet within your google-spreadsheets and paste #-- the 'key' parameter in the spreadsheet URL
#-- See http://spreadsheets.google.com/pub?key=p7dQJMn9Y4pVz5Q1n2n_sPQ key="p7dQJMn9Y4pVz5Q1n2n_sPQ"
MAXTRIES = 10 print "what's your name? " my_name = gets.chomp print "where do you live? " my_location = gets.chomp print "your message? (if left blank, only your name and location will be inserted) " my_message = gets.chomp
success = false MAXTRIES.times do col = rand(10)+1 row = rand(10)+1 # if spreadsheet.empty?(row,col) if my_message.empty? text = Time.now.to_s+" "+"Greetings from #{my_name} (#{my_location})" else text = Time.now.to_s+" "+"#{my_message} from #{my_name} (#{my_location})" end spreadsheet.set_value(row,col,text) puts "message written to row #{row}, column #{col}" success = true break # end puts "Row #{row}, column #{col} already occupied, trying again..." end puts "no empty cell found within #{MAXTRIES} tries" if !success
最近のコメント