class TableSetting::Style
Attributes
background[R]
bold[R]
color[R]
size[R]
Public Class Methods
new(cell, options = {})
click to toggle source
# File lib/table_setting/style.rb, line 3 def initialize(cell, options = {}) @bold = options[:bold] || cell.row.bold? @size = options[:size] || cell.row.size @background = options[:background] || cell.row.background @color = options[:color] || cell.row.color end
Public Instance Methods
bold?()
click to toggle source
# File lib/table_setting/style.rb, line 27 def bold? bold end
name()
click to toggle source
# File lib/table_setting/style.rb, line 17 def name settings = { bold: bold?, background: background, size: size, color: color } "style-#{Digest::MD5.hexdigest(settings.to_s)[0..7]}" end
to_css()
click to toggle source
# File lib/table_setting/style.rb, line 31 def to_css signature = '' if bold? signature += "font-weight: bold;" end if size signature += "font-size: #{size};" end if background signature += "background-color: #{background};" end if color signature += "color: #{color};" end signature end
to_xls_xml()
click to toggle source
# File lib/table_setting/style.rb, line 48 def to_xls_xml signature = '' font_specs = {} if bold? font_specs["ss:Bold"] = 1 end if size end if background signature += %Q{<Interior ss:Color="#{background}" ss:Pattern="Solid"/>} end if color font_specs["ss:Color"] = color end unless font_specs.empty? spec_string = '' font_specs.each do |key, value| spec_string += %Q{#{key}="#{value}" } end signature += "<ss:Font #{spec_string} />" end signature end
update(options)
click to toggle source
# File lib/table_setting/style.rb, line 10 def update(options) @bold = options[:bold] if options[:bold] @background = options[:background] if options[:background] @color = options[:color] if options[:color] @size = options[:size] if options[:size] end