class Xlsxrb::Ooxml::Reader::SparklineGroupsListener
SAX2 listener for parsing <x14:sparklineGroups> and child <x14:sparklineGroup> elements.
Constants
- COLOR_TAG_MAP
Attributes
groups
[R]
Array[Hash[Symbol, untyped]]
@return [Array<Hash[Symbol, untyped]>]
sparkline_groups
[R]
Array[Hash[Symbol, untyped]]
@return [Array<Hash[Symbol, untyped]>]
Public Class Methods
() → void
Source
# File lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb, line 1994 def initialize @groups = [] @current_group = nil @current_sparkline = nil @inside_f = false @inside_sqref = false @text_buffer = +"" end
Public Instance Methods
(String text) → void
Source
# File lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb, line 2055 def characters(text) @text_buffer << text if @inside_f || @inside_sqref end
(untyped _uri, String? local_name, String? qname) → void
Source
# File lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb, line 2060 def end_element(_uri, local_name, qname) name = element_name(local_name, qname) case name when "f" if @current_sparkline && @inside_f val = @text_buffer.strip @current_sparkline[:data_ref] = val @current_sparkline[:formula] = val @inside_f = false end when "sqref" if @current_sparkline && @inside_sqref val = @text_buffer.strip @current_sparkline[:location_ref] = val @current_sparkline[:sqref] = val @inside_sqref = false end when "sparkline" if @current_group && @current_sparkline @current_group[:sparklines] << @current_sparkline @current_sparkline = nil end when "sparklineGroup" if @current_group @groups << @current_group @current_group = nil end end end
(untyped _uri, String? local_name, String? qname, Hash[String, String] attributes) → void
Source
# File lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb, line 2004 def start_element(_uri, local_name, qname, attributes) name = element_name(local_name, qname) case name when "sparklineGroup" disp = attributes["displayEmptyCellsAs"] max_attr = attributes["manualMax"] min_attr = attributes["manualMin"] lw_attr = attributes["lineWeight"] max = parse_numeric(max_attr) min = parse_numeric(min_attr) line_weight = parse_numeric(lw_attr) @current_group = { type: attributes["type"] || "line", display_empty: disp, display_empty_cells_as: disp, markers: %w[1 true].include?(attributes["markers"]), high: %w[1 true].include?(attributes["high"]), low: %w[1 true].include?(attributes["low"]), first: %w[1 true].include?(attributes["first"]), last: %w[1 true].include?(attributes["last"]), negative: %w[1 true].include?(attributes["negative"]), max: max, manual_max: max, min: min, manual_min: min, line_weight: line_weight, sparklines: [] } when "colorSeries", "colorNegative", "colorAxis", "colorMarkers", "colorFirst", "colorLast", "colorHigh", "colorLow" if @current_group color = parse_color(attributes) key = COLOR_TAG_MAP[name] @current_group[key] = color if color && key end when "sparkline" @current_sparkline = {} when "f" if @current_sparkline @inside_f = true @text_buffer = +"" end when "sqref" if @current_sparkline @inside_sqref = true @text_buffer = +"" end end end