class Xsv::StylesHandler
StylesHandler
interprets the relevant parts of styles.xml This is used internally when opening a sheet.
Public Class Methods
get_styles(io)
click to toggle source
# File lib/xsv/styles_handler.rb, line 7 def self.get_styles(io) handler = new(Xsv::Helpers::BUILT_IN_NUMBER_FORMATS.dup) do |xfs, numFmts| @xfs = xfs @numFmts = numFmts end handler.parse(io) [@xfs, @numFmts] end
new(numFmts, &block)
click to toggle source
# File lib/xsv/styles_handler.rb, line 18 def initialize(numFmts, &block) @block = block @state = nil @xfs = [] @numFmts = numFmts end
Public Instance Methods
end_element(name)
click to toggle source
# File lib/xsv/styles_handler.rb, line 36 def end_element(name) case name when 'styleSheet' @block.call(@xfs, @numFmts) when 'cellXfs' @state = nil end end
start_element(name, attrs)
click to toggle source
# File lib/xsv/styles_handler.rb, line 25 def start_element(name, attrs) case name when 'cellXfs' @state = 'cellXfs' when 'xf' @xfs << attrs if @state == 'cellXfs' when 'numFmt' @numFmts[attrs[:numFmtId].to_i] = attrs[:formatCode] end end