class Xlsxrb::Ooxml::Reader::ScenariosListener
SAX2 listener for parsing <scenarios> element.
Attributes
Public Class Methods
Source
# File lib/xlsxrb/ooxml/reader.rb, line 3464 def initialize @result = nil @current_scenario = nil end
Public Instance Methods
# File lib/xlsxrb/ooxml/reader.rb, line 3497 def end_element(_uri, local_name, qname) name = element_name(local_name, qname) return unless name == "scenario" && @current_scenario && @result @result[:scenarios] << @current_scenario @current_scenario = nil end
# File lib/xlsxrb/ooxml/reader.rb, line 3469 def start_element(_uri, local_name, qname, attributes) name = element_name(local_name, qname) case name when "scenarios" @result = { scenarios: [] } @result[:current] = attributes["current"].to_i if attributes["current"] @result[:show] = attributes["show"].to_i if attributes["show"] @result[:sqref] = attributes["sqref"] if attributes["sqref"] when "scenario" if @result sc = { name: attributes["name"], input_cells: [] } sc[:locked] = true if %w[1 true].include?(attributes["locked"]) sc[:hidden] = true if %w[1 true].include?(attributes["hidden"]) sc[:user] = attributes["user"] if attributes["user"] sc[:comment] = attributes["comment"] if attributes["comment"] @current_scenario = sc end when "inputCells" if @current_scenario ic = { r: attributes["r"], val: attributes["val"] } ic[:deleted] = true if %w[1 true].include?(attributes["deleted"]) ic[:undone] = true if %w[1 true].include?(attributes["undone"]) ic[:num_fmt_id] = attributes["numFmtId"].to_i if attributes["numFmtId"] @current_scenario[:input_cells] << ic end end end