summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2013-06-23 10:11:47 +0100
committerRandy Morgan <[email protected]>2013-06-23 10:11:47 +0100
commit0bf44ef6494837b9c718cdde78f18b31f1929252 (patch)
treeb5b5222d6228b57deee4c6d82f93d162c17db49b /lib
parent86180711acbb7f9c6a04688fc9e6ffbf27bacf19 (diff)
parent21fce3b99e639abe757716750a2a7f9970e572ab (diff)
downloadcaxlsx-0bf44ef6494837b9c718cdde78f18b31f1929252.tar.gz
caxlsx-0bf44ef6494837b9c718cdde78f18b31f1929252.zip
Merge branch 'master' of https://github.com/randym/axlsx
Diffstat (limited to 'lib')
-rw-r--r--lib/axlsx/doc_props/core.rb7
-rw-r--r--lib/axlsx/package.rb2
-rw-r--r--lib/axlsx/stylesheet/styles.rb6
3 files changed, 12 insertions, 3 deletions
diff --git a/lib/axlsx/doc_props/core.rb b/lib/axlsx/doc_props/core.rb
index d71300e0..a74031f2 100644
--- a/lib/axlsx/doc_props/core.rb
+++ b/lib/axlsx/doc_props/core.rb
@@ -8,14 +8,19 @@ module Axlsx
# Creates a new Core object.
# @option options [String] creator
+ # @option options [Time] created
def initialize(options={})
@creator = options[:creator] || 'axlsx'
+ @created = options[:created]
end
# The author of the document. By default this is 'axlsx'
# @return [String]
attr_accessor :creator
+ # Creation time of the document. If nil, the current time will be used.
+ attr_accessor :created
+
# serializes the core.xml document
# @return [String]
def to_xml_string(str = '')
@@ -24,7 +29,7 @@ module Axlsx
str << 'xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" '
str << 'xmlns:xsi="' << CORE_NS_XSI << '">'
str << '<dc:creator>' << self.creator << '</dc:creator>'
- str << '<dcterms:created xsi:type="dcterms:W3CDTF">' << Time.now.strftime('%Y-%m-%dT%H:%M:%S') << 'Z</dcterms:created>'
+ str << '<dcterms:created xsi:type="dcterms:W3CDTF">' << (created || Time.now).strftime('%Y-%m-%dT%H:%M:%S') << 'Z</dcterms:created>'
str << '<cp:revision>0</cp:revision>'
str << '</cp:coreProperties>'
end
diff --git a/lib/axlsx/package.rb b/lib/axlsx/package.rb
index 13a3bd13..37620b48 100644
--- a/lib/axlsx/package.rb
+++ b/lib/axlsx/package.rb
@@ -17,12 +17,14 @@ module Axlsx
#
# @param [Hash] options A hash that you can use to specify the author and workbook for this package.
# @option options [String] :author The author of the document
+ # @option options [Time] :created_at Timestamp in the document properties (defaults to current time).
# @option options [Boolean] :use_shared_strings This is passed to the workbook to specify that shared strings should be used when serializing the package.
# @example Package.new :author => 'you!', :workbook => Workbook.new
def initialize(options={})
@workbook = nil
@core, @app = Core.new, App.new
@core.creator = options[:author] || @core.creator
+ @core.created = options[:created_at]
parse_options options
yield self if block_given?
end
diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb
index 8cd2275c..44ccb752 100644
--- a/lib/axlsx/stylesheet/styles.rb
+++ b/lib/axlsx/stylesheet/styles.rb
@@ -296,9 +296,11 @@ module Axlsx
def parse_fill_options(options={})
return unless options[:bg_color]
color = Color.new(:rgb=>options[:bg_color])
- pattern = PatternFill.new(:patternType =>:solid, :fgColor=>color)
+ dxf = options[:type] == :dxf
+ color_key = dxf ? :bgColor : :fgColor
+ pattern = PatternFill.new(:patternType =>:solid, color_key=>color)
fill = Fill.new(pattern)
- options[:type] == :dxf ? fill : fills << fill
+ dxf ? fill : fills << fill
end
# parses Style#add_style options for borders.