class Roo::Excelx::Styles
Public Instance Methods
definitions()
click to toggle source
# File lib/roo/excelx/styles.rb, line 13 def definitions @definitions ||= extract_definitions end
style_format(style)
click to toggle source
convert internal excelx attribute to a format
# File lib/roo/excelx/styles.rb, line 8 def style_format(style) id = num_fmt_ids[style.to_i] num_fmts[id] || Excelx::Format::STANDARD_FORMATS[id.to_i] end
Private Instance Methods
extract_definitions()
click to toggle source
# File lib/roo/excelx/styles.rb, line 31 def extract_definitions doc.xpath('//cellXfs').flat_map do |xfs| xfs.children.map do |xf| fonts[xf['fontId'].to_i] end end end
extract_fonts()
click to toggle source
# File lib/roo/excelx/styles.rb, line 39 def extract_fonts doc.xpath('//fonts/font').map do |font_el| Font.new.tap do |font| font.bold = !font_el.xpath('./b').empty? font.italic = !font_el.xpath('./i').empty? font.underline = !font_el.xpath('./u').empty? end end end
extract_num_fmt_ids()
click to toggle source
# File lib/roo/excelx/styles.rb, line 49 def extract_num_fmt_ids doc.xpath('//cellXfs').flat_map do |xfs| xfs.children.map do |xf| xf['numFmtId'] end end.compact end
extract_num_fmts()
click to toggle source
# File lib/roo/excelx/styles.rb, line 57 def extract_num_fmts doc.xpath('//numFmt').each_with_object({}) do |num_fmt, hash| hash[num_fmt['numFmtId']] = num_fmt['formatCode'] end end
fonts()
click to toggle source
# File lib/roo/excelx/styles.rb, line 27 def fonts @fonts ||= extract_fonts end
num_fmt_ids()
click to toggle source
# File lib/roo/excelx/styles.rb, line 19 def num_fmt_ids @num_fmt_ids ||= extract_num_fmt_ids end
num_fmts()
click to toggle source
# File lib/roo/excelx/styles.rb, line 23 def num_fmts @num_fmts ||= extract_num_fmts end