class Roo::Excelx::Cell
Attributes
coordinate[R]
excelx_type[R]
excelx_value[R]
formula[R]
hyperlink[R]
style[R]
type[R]
value[RW]
Public Class Methods
new(value, type, formula, excelx_type, excelx_value, style, hyperlink, base_date, coordinate)
click to toggle source
# File lib/roo/excelx.rb, line 83 def initialize(value, type, formula, excelx_type, excelx_value, style, hyperlink, base_date, coordinate) @type = type @formula = formula @base_date = base_date if [:date, :datetime].include?(@type) @excelx_type = excelx_type @excelx_value = excelx_value @style = style @value = type_cast_value(value) @value = Roo::Link.new(hyperlink, @value.to_s) if hyperlink @coordinate = coordinate end
Private Instance Methods
create_datetime_from(datetime_string)
click to toggle source
# File lib/roo/excelx.rb, line 133 def create_datetime_from(datetime_string) date_part,time_part = round_time_from(datetime_string).split(' ') yyyy,mm,dd = date_part.split('-') hh,mi,ss = time_part.split(':') DateTime.civil(yyyy.to_i,mm.to_i,dd.to_i,hh.to_i,mi.to_i,ss.to_i) end
round_time_from(datetime_string)
click to toggle source
# File lib/roo/excelx.rb, line 140 def round_time_from(datetime_string) date_part,time_part = datetime_string.split(' ') yyyy,mm,dd = date_part.split('-') hh,mi,ss = time_part.split(':') Time.new(yyyy.to_i, mm.to_i, dd.to_i, hh.to_i, mi.to_i, ss.to_r).round(0).strftime("%Y-%m-%d %H:%M:%S") end
type_cast_value(value)
click to toggle source
# File lib/roo/excelx.rb, line 115 def type_cast_value(value) case @type when :float, :percentage value.to_f when :date yyyy,mm,dd = (@base_date+value.to_i).strftime("%Y-%m-%d").split('-') Date.new(yyyy.to_i,mm.to_i,dd.to_i) when :datetime create_datetime_from((@base_date+value.to_f.round(6)).strftime("%Y-%m-%d %H:%M:%S.%N")) when :time value.to_f*(24*60*60) when :string value else value end end