How to store current & last values from excel spreadsheet

167 views Asked by At

I have a working dashing setup (using roo) that reads an excel spreadsheet to display a customer satisfaction score.

I'd like to implement the percentage change plus and up or down arrow indicating which way we are going.

I have a test valuation/number widget working correctly whereby I can CURL dummy values. I'm not really sure where to start in order to incorporate the spreadsheet. Does the spreadsheet need to contain the last & current values or does coffeescript store the last value as it does its thing?

Any pointers would be great!

tx

sorry for the delay. With your code and simplifying my own to this, I receive the error 'undefined variable or method 'last' for main object'. Here is my code.

require 'roo'
current = 0
SCHEDULER.every '2s', :first_in => 0 do |job|
last_valuation = current
file_path = "#{Dir.pwd}/xls/newcasestest1.xls"
def fetch_spreadsheet_data(path)
s = Roo::Excel.new(path)
send_event('csatweek', {current: s.cell('H',199), last: last }) 
end
module Handler
def file_modified
fetch_spreadsheet_data(path)
end
end
fetch_spreadsheet_data(file_path)
end
1

There are 1 answers

0
tylermauthe On

In your Ruby job, you can store the last value and send it in the event.

From the sample dashboard:

current = 0

SCHEDULER.every '2s' do
  last_valuation = current
  current = getMyValueFromSpreadsheet()

  send_event('value', { current: current, last: last })
end

def getMyValueFromSpreadsheet
  # do stuff and return current value from spreadsheet
end