Module: AxlsxEnhanced::Helpers::Injections::Worksheet
- Included in:
- Axlsx::Worksheet
- Defined in:
- lib/axlsx_enhanced/helpers/injections/worksheet.rb
Instance Method Summary collapse
- #smart_add_row(array, args = {}) ⇒ Object
- #smart_add_separator ⇒ Object
- #smart_styles ⇒ Object
- #smart_styles=(value) ⇒ Object
Instance Method Details
#smart_add_row(array, args = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/axlsx_enhanced/helpers/injections/worksheet.rb', line 17 def smart_add_row(array, args = {}) unless args[:style].blank? if args[:style].is_a?(Array) # Look for all smart styles and parse them into base styles base_styles = [] args[:style].each do |item| style_hash = {} # Parse the item into an array item_array = item.is_a?(Array) ? item : [item] item_array.each do |style| next if style.nil? # Get smart style object smart_style = self.smart_styles.find(style) # Merge the smart style properties into the style hash style_hash.deep_merge!(smart_style.properties) end # Extract heigh property if any args[:height] ||= style_hash[:height] if style_hash[:height].present? # Push a parsed base style into the array base_styles.push self.styles.add_style(style_hash) end else style_hash = {} # Get smart style object smart_style = self.smart_styles.find args[:style] # Merge the smart style properties into the style hash style_hash.deep_merge!(smart_style.properties) # Extract heigh property if any args[:height] ||= style_hash[:height] if style_hash[:height].present? # Set a base style as a single Integer number base_styles = self.styles.add_style(smart_style.properties) end # Re-write style args setting the base styles args[:style] = base_styles end # Call original row creation method return self.add_row(array, args) end |
#smart_add_separator ⇒ Object
13 14 15 |
# File 'lib/axlsx_enhanced/helpers/injections/worksheet.rb', line 13 def smart_add_separator return self.add_row [nil] end |
#smart_styles ⇒ Object
9 10 11 |
# File 'lib/axlsx_enhanced/helpers/injections/worksheet.rb', line 9 def smart_styles return @smart_styles end |
#smart_styles=(value) ⇒ Object
5 6 7 |
# File 'lib/axlsx_enhanced/helpers/injections/worksheet.rb', line 5 def smart_styles=(value) @smart_styles = AxlsxEnhanced::Helpers::Styles::StyleCollection.new(self, value || []) end |