class Xlsxrb::Ooxml::Reader::PivotCacheDefinitionListener
SAX2 listener for parsing pivotCacheDefinition XML.
Attributes
Public Class Methods
Source
# File lib/xlsxrb/ooxml/reader.rb, line 7888 def initialize @cache_definition = {} @fields = [] @current_field = nil @current_shared_items = nil end
Public Instance Methods
Source
# File lib/xlsxrb/ooxml/reader.rb, line 7950 def end_document @cache_definition[:fields] = @fields unless @fields.empty? end
# File lib/xlsxrb/ooxml/reader.rb, line 7934 def end_element(_uri, local_name, qname) name = element_name(local_name, qname) case name when "sharedItems" @current_field[:shared_items] = @current_shared_items if @current_field && @current_shared_items && !@current_shared_items.empty? @current_shared_items = nil when "cacheField" if @current_field @fields << @current_field @current_field = nil end end end
# File lib/xlsxrb/ooxml/reader.rb, line 7895 def start_element(_uri, local_name, qname, attributes) name = element_name(local_name, qname) case name when "pivotCacheDefinition" sd = attributes["saveData"] @cache_definition[:save_data] = sd != "0" unless sd.nil? er = attributes["enableRefresh"] @cache_definition[:enable_refresh] = er != "0" unless er.nil? @cache_definition[:refreshed_by] = attributes["refreshedBy"] if attributes["refreshedBy"] @cache_definition[:refreshed_version] = attributes["refreshedVersion"]&.to_i if attributes["refreshedVersion"] @cache_definition[:created_version] = attributes["createdVersion"]&.to_i if attributes["createdVersion"] @cache_definition[:record_count] = attributes["recordCount"]&.to_i if attributes["recordCount"] om = attributes["optimizeMemory"] @cache_definition[:optimize_memory] = om == "1" unless om.nil? when "cacheSource" @cache_definition[:source_type] = attributes["type"] if attributes["type"] when "worksheetSource" @cache_definition[:source_ref] = attributes["ref"] if attributes["ref"] @cache_definition[:source_sheet] = attributes["sheet"] if attributes["sheet"] @cache_definition[:source_name] = attributes["name"] if attributes["name"] when "cacheField" @current_field = {} @current_field[:name] = attributes["name"] if attributes["name"] @current_field[:num_fmt_id] = attributes["numFmtId"]&.to_i if attributes["numFmtId"] @current_field[:caption] = attributes["caption"] if attributes["caption"] @current_field[:formula] = xml_unescape(attributes["formula"]) if attributes["formula"] when "sharedItems" @current_shared_items = [] if @current_field when "s", "d", "e" @current_shared_items << attributes["v"] if @current_shared_items && attributes["v"] when "n" @current_shared_items << attributes["v"]&.to_f if @current_shared_items && attributes["v"] when "b" @current_shared_items << (attributes["v"] == "1") if @current_shared_items when "m" @current_shared_items << nil if @current_shared_items end end