weshatheleopard / rubyXL

Ruby lib for reading/writing/modifying .xlsx and .xlsm files
MIT License
1.28k stars 255 forks source link

Time can't be used as a Cell value #376

Closed timon closed 4 years ago

timon commented 4 years ago

Hi there,

I have stumbled upon an issue when rubyXL doesn't write the Time values:

require 'rubyXL'
workbook = RubyXL::Workbook.new
worksheet = workbook[0]
# observe the value being nil:
worksheet.add_cell(0, 0, Time.now) # =>  #<RubyXL::Cell(0,0): nil, datatype=nil, style_index=0>
# this works:
worksheet.add_cell(0, 1, DateTime.now) # => #<RubyXL::Cell(0,0): 44029.61175965089, datatype=nil, style_index=0>
workbook.write("out.xlsx")

The resulting file consists of one empty cell and one cell with value