I am using spreadsheet (1.0.3) and I am trying to read the date from a cell that has a =TODAY()
formula in it. This is what I've tried so far:
require 'spreadsheet'
require 'date'
Spreadsheet.client_encoding = 'UTF-8'
book = Spreadsheet.open 'document.xls', 'rb'
sheet1 = book.worksheet 0
puts sheet1.row(0)[0].value # => 42167.0
I get 42167.0
when the date returned value for the =TODAY()
formula in the spreadsheet is 2015-06-12
, for 2015-06-13
I get 42168.0
. The thing is that I am not seing a way to convert this number to a Date object.
Any DATETIME in excel is stored as DAY.Hour format (with 0.0 being 00 Jan 1900).
See: https://stackoverflow.com/a/14597674/91830