diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/axlsx/stylesheet/styles.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/util/constants.rb | 3 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/cell.rb | 1 |
3 files changed, 6 insertions, 0 deletions
diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb index 6b64fb30..de5835dd 100644 --- a/lib/axlsx/stylesheet/styles.rb +++ b/lib/axlsx/stylesheet/styles.rb @@ -286,6 +286,8 @@ module Axlsx @cellXfs = SimpleTypedList.new Xf, "cellXfs" @cellXfs << Xf.new(:borderId=>0, :xfId=>0, :numFmtId=>0, :fontId=>0, :fillId=>0) @cellXfs << Xf.new(:borderId=>1, :xfId=>0, :numFmtId=>0, :fontId=>0, :fillId=>0) + # default date formatting + @cellXfs << Xf.new(:borderId=>0, :xfId=>0, :numFmtId=>14, :fontId=>0, :fillId=>0) @cellXfs.lock @dxfs = SimpleTypedList.new(Xf, "dxfs"); @dxfs.lock diff --git a/lib/axlsx/util/constants.rb b/lib/axlsx/util/constants.rb index 50dd6f27..4f1cb561 100644 --- a/lib/axlsx/util/constants.rb +++ b/lib/axlsx/util/constants.rb @@ -199,6 +199,9 @@ module Axlsx # cellXfs id for thin borders around the cell STYLE_THIN_BORDER = 1 + # cellXfs id for default date styling + STYLE_DATE = 2 + # error messages RestrictionValidor ERR_RESTRICTION = "Invalid Data: %s. %s must be one of %s." diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb index 1b1b60cc..a9b4a704 100644 --- a/lib/axlsx/workbook/worksheet/cell.rb +++ b/lib/axlsx/workbook/worksheet/cell.rb @@ -169,6 +169,7 @@ module Axlsx def cast_value(v) if (@type == :time && v.is_a?(Time)) || (@type == :time && v.respond_to?(:to_time)) v = v.respond_to?(:to_time) ? v.to_time : v + self.style = STYLE_DATE if self.style == 0 # Using hardcoded offsets here as some operating systems will not except a 'negative' offset from the ruby epoc. # (1970) epoc1900 = -2209021200 #Time.local(1900, 1, 1) |
