diff options
| author | Randy Morgan <[email protected]> | 2012-04-01 11:58:09 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-04-01 11:58:09 +0900 |
| commit | 1529fce32449a8454208fded20d83c9ceca810e0 (patch) | |
| tree | 02f722182fea58a51b8c0a5433221b3a677e80e4 /lib/axlsx/stylesheet/num_fmt.rb | |
| parent | 22a341841f191a5aa00e87b1f166b4f25cc67f0a (diff) | |
| download | caxlsx-1529fce32449a8454208fded20d83c9ceca810e0.tar.gz caxlsx-1529fce32449a8454208fded20d83c9ceca810e0.zip | |
rebuild all serialization to use string concatenation instead of nokogiri.
Diffstat (limited to 'lib/axlsx/stylesheet/num_fmt.rb')
| -rw-r--r-- | lib/axlsx/stylesheet/num_fmt.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/axlsx/stylesheet/num_fmt.rb b/lib/axlsx/stylesheet/num_fmt.rb index 261d5bb3..8c74382f 100644 --- a/lib/axlsx/stylesheet/num_fmt.rb +++ b/lib/axlsx/stylesheet/num_fmt.rb @@ -1,11 +1,11 @@ # encoding: UTF-8 module Axlsx - # A NumFmt object defines an identifier and formatting code for data in cells. + # A NumFmt object defines an identifier and formatting code for data in cells. # @note The recommended way to manage styles is Styles#add_style class NumFmt # @return [Integer] An unsinged integer referencing a standard or custom number format. # @note - # These are the known formats I can dig up. The constant NUM_FMT_PERCENT is 9, and uses the default % formatting. Axlsx also defines a few formats for date and time that are commonly used in asia as NUM_FMT_YYYYMMDD and NUM_FRM_YYYYMMDDHHMMSS. + # These are the known formats I can dig up. The constant NUM_FMT_PERCENT is 9, and uses the default % formatting. Axlsx also defines a few formats for date and time that are commonly used in asia as NUM_FMT_YYYYMMDD and NUM_FRM_YYYYMMDDHHMMSS. # 1 0 # 2 0.00 # 3 #,##0 @@ -40,7 +40,7 @@ module Axlsx # @see Axlsx attr_reader :numFmtId - # @return [String] The formatting to use for this number format. + # @return [String] The formatting to use for this number format. # @see http://support.microsoft.com/kb/264372 attr_reader :formatCode def initialize(options={}) @@ -56,9 +56,15 @@ module Axlsx # @see formatCode def formatCode=(v) Axlsx::validate_string v; @formatCode = v end + def to_xml_string(str = '') + str << '<numFmt ' + str << instance_values.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ') + str << '/>' + end + # Creates a numFmt element applying the instance values of this object as attributes. # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. - def to_xml(xml) xml.numFmt(self.instance_values) end + def to_xml(xml) xml.numFmt(self.instance_values) end end end |
