Class: OpenXml::Xlsx::Elements::Style
- Inherits:
-
Struct
- Object
- Struct
- OpenXml::Xlsx::Elements::Style
- Defined in:
- lib/openxml/xlsx/elements/style.rb
Instance Attribute Summary collapse
-
#alignment ⇒ Object
Returns the value of attribute alignment.
-
#border_id ⇒ Object
Returns the value of attribute border_id.
-
#fill_id ⇒ Object
Returns the value of attribute fill_id.
-
#font_id ⇒ Object
Returns the value of attribute font_id.
-
#format_id ⇒ Object
Returns the value of attribute format_id.
Instance Method Summary collapse
-
#initialize(format_id = 0, font_id = 0, fill_id = 0, border_id = 0, alignment = nil) ⇒ Style
constructor
A new instance of Style.
- #to_xml(xml) ⇒ Object
Constructor Details
#initialize(format_id = 0, font_id = 0, fill_id = 0, border_id = 0, alignment = nil) ⇒ Style
Returns a new instance of Style.
6 7 8 |
# File 'lib/openxml/xlsx/elements/style.rb', line 6 def initialize(format_id=0, font_id=0, fill_id=0, border_id=0, alignment=nil) super format_id || 0, font_id || 0, fill_id || 0, border_id || 0, alignment end |
Instance Attribute Details
#alignment ⇒ Object
Returns the value of attribute alignment
4 5 6 |
# File 'lib/openxml/xlsx/elements/style.rb', line 4 def alignment @alignment end |
#border_id ⇒ Object
Returns the value of attribute border_id
4 5 6 |
# File 'lib/openxml/xlsx/elements/style.rb', line 4 def border_id @border_id end |
#fill_id ⇒ Object
Returns the value of attribute fill_id
4 5 6 |
# File 'lib/openxml/xlsx/elements/style.rb', line 4 def fill_id @fill_id end |
#font_id ⇒ Object
Returns the value of attribute font_id
4 5 6 |
# File 'lib/openxml/xlsx/elements/style.rb', line 4 def font_id @font_id end |
#format_id ⇒ Object
Returns the value of attribute format_id
4 5 6 |
# File 'lib/openxml/xlsx/elements/style.rb', line 4 def format_id @format_id end |
Instance Method Details
#to_xml(xml) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/openxml/xlsx/elements/style.rb', line 10 def to_xml(xml) attributes = { numFmtId: format_id, fontId: font_id, fillId: fill_id, borderId: border_id } attributes.merge!(applyNumberFormat: 1) if format_id > 0 attributes.merge!(applyFont: 1) if font_id > 0 attributes.merge!(applyFill: 1) if fill_id > 0 attributes.merge!(applyBorder: 1) if border_id > 0 attributes.merge!(applyAlignment: 1) if alignment xml.xf(attributes) do alignment.to_xml(xml) if alignment end end |