I create an excel with axslx. One row should be colored. But if I do so, I loose the date format for my dates.
Minimal example with some attempts I did:
require 'axlsx'
Axlsx::Package.new do |p|
p.workbook.add_worksheet(:name => "test") do |ws|
style1 = ws.styles.add_style(:bg_color => "EF0920", :fg_color => "FFFFFF")
ws.add_row [ Date.today, "No style defined --ok"]
ws.add_row [ Date.today, "Style with colors --The date is no date any longer"], :style => style1
ws.add_row [ Date.today, "Style with colors, except date -- ok, but not colored"], :style => [nil,style1]
ws.add_row [ Date.today, "Style with colors and types --The date is no date any longer"], :style => style1, :types => [:date,:string]
ws.add_row [ Date.today, "Style with colors and types --The date is no date any longer"], :style => [style1,style1], :types => [:date,:string]
ws.add_row [ Date.today, "No Style -- ok, but not colored"], :types => [:date,:string]
end
p.serialize('test.xlsx')
end
The result is:
How can I color a date cell without losing the data information?