Class: Axlsx::NumFmt
- Inherits:
-
Object
- Object
- Axlsx::NumFmt
- Defined in:
- lib/axlsx/stylesheet/num_fmt.rb
Overview
The recommended way to manage styles is Styles#add_style
A NumFmt object defines an identifier and formatting code for data in cells.
Instance Attribute Summary collapse
-
#formatCode ⇒ String
The formatting to use for this number format.
-
#numFmtId ⇒ Integer
An unsinged integer referencing a standard or custom number format.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ NumFmt
constructor
A new instance of NumFmt.
-
#to_xml(xml) ⇒ Object
Creates a numFmt element applying the instance values of this object as attributes.
Constructor Details
#initialize(options = {}) ⇒ NumFmt
Returns a new instance of NumFmt.
45 46 47 48 49 50 51 |
# File 'lib/axlsx/stylesheet/num_fmt.rb', line 45 def initialize(={}) @numFmtId = 0 @formatCode = "" .each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? o[0] end end |
Instance Attribute Details
#formatCode ⇒ String
Returns The formatting to use for this number format.
44 45 46 |
# File 'lib/axlsx/stylesheet/num_fmt.rb', line 44 def formatCode @formatCode end |
#numFmtId ⇒ Integer
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
4 #,##0.00
5 $#,##0_);($#,##0)
6 $#,##0_);[Red]($#,##0)
7 $#,##0.00_);($#,##0.00)
8 $#,##0.00_);[Red]($#,##0.00)
9 0%
10 0.00%
11 0.00E+00
12 # ?/?
13 # ??/??
14 m/d/yyyy
15 d-mmm-yy
16 d-mmm
17 mmm-yy
18 h:mm AM/PM
19 h:mm:ss AM/PM
20 h:mm
21 h:mm:ss
22 m/d/yyyy h:mm
37 #,##0_);(#,##0)
38 #,##0_);[Red](#,##0)
39 #,##0.00_);(#,##0.00)
40 #,##0.00_);[Red](#,##0.00)
45 mm:ss
46 [h]:mm:ss
47 mm:ss.0
48 ##0.0E+0
49 @
Returns An unsinged integer referencing a standard or custom number format.
40 41 42 |
# File 'lib/axlsx/stylesheet/num_fmt.rb', line 40 def numFmtId @numFmtId end |
Instance Method Details
#to_xml(xml) ⇒ Object
Creates a numFmt element applying the instance values of this object as attributes.
60 |
# File 'lib/axlsx/stylesheet/num_fmt.rb', line 60 def to_xml(xml) xml.numFmt(self.instance_values) end |