Excel数据在Dashing仪表板上的表格?

我一直在试图转换一个叫做spreadsheetDemo的Dashing小部件,以便使用Roo GEM来简化它,并且允许它支持本地和Google Doc Excel文件(就像Roo一样)我开始通过查看其他小部件和源代码(类似于这只是一个表,而不是图)已经使用Roo,我试图重用他们的代码的文件来源代替原来的,导致我的代码如下。 我正在尝试使用Roo访问本地电子表格,获取6列和行的标题和数据,然后将它们推送到表中。 我相信我的问题可能在于正确访问电子表格。 一切都在第一个工作簿上,并从单元格A1开始。

我使用的来源:https:// github.com/Shopify/dashing/issues/78#issuecomment-14940695

http:// stackoverflow.com/questions/29400811/use-with-excel-data-to-display-on-dashing-dashboard/29421179?newreg=5c8c7db27d104f5ab3b855c8ea729bc8

require 'roo' #Tried using roo-xls as it started throwing errors saying I needed too. #require 'roo-xls' EM.kqueue = EM.kqueue? file_path = "#{Dir.pwd}/spreadsheet.xls" def fetch_spreadsheet_data(path) s = Roo::Excel.new(path) ws = workbook.sheets[0] # create an array to hold the lines rows = Array.new header = Array.new # other variables up = ws.updated.localtime up = up.strftime "%d.%m.%Y %H:%M" #workbook.default_sheet = workbook.sheets[0] # fill lines for row in 1..ws.num_rows if row == 1 header.push({ :c1 => ws[row, 1], :c2 => ws[row, 2], :c3 => ws[row, 3], :c4 => ws[row, 4], :c5 => ws[row, 5], :c6 => ws[row, 6]}) else rows.push({ :c1 => ws[row, 1], :c2 => ws[row, 2], :c3 => ws[row, 3], :c4 => ws[row, 4], :c5 => ws[row, 5], :c6 => ws[row, 6]}) end end send_event('spread', :modified => up, :header => header, :rows => rows) rescue => err #puts "Exception: #{err}" end module Handler def file_modified fetch_spreadsheet_data(path) end end fetch_spreadsheet_data(file_path) end