class Xlsxrb::Ooxml::Reader::DataValidationsListener
SAX2 listener for parsing <dataValidations> elements.
Attributes
Public Class Methods
Source
# File lib/xlsxrb/ooxml/reader.rb, line 3706 def initialize @validations = [] @container_options = {} @current_dv = nil @inside_formula1 = false @inside_formula2 = false @text_buffer = +"" end
Public Instance Methods
Source
# File lib/xlsxrb/ooxml/reader.rb, line 3748 def characters(text) @text_buffer << text if @inside_formula1 || @inside_formula2 end
# File lib/xlsxrb/ooxml/reader.rb, line 3752 def end_element(_uri, local_name, qname) name = element_name(local_name, qname) case name when "formula1" @current_dv[:formula1] = @text_buffer.dup if @current_dv @inside_formula1 = false when "formula2" @current_dv[:formula2] = @text_buffer.dup if @current_dv @inside_formula2 = false when "dataValidation" @validations << @current_dv if @current_dv @current_dv = nil end end
# File lib/xlsxrb/ooxml/reader.rb, line 3715 def start_element(_uri, local_name, qname, attributes) name = element_name(local_name, qname) case name when "dataValidations" dp = attributes["disablePrompts"] @container_options[:disable_prompts] = true if %w[1 true].include?(dp) xw = attributes["xWindow"] @container_options[:x_window] = xw.to_i if xw yw = attributes["yWindow"] @container_options[:y_window] = yw.to_i if yw when "dataValidation" @current_dv = { sqref: attributes["sqref"] } @current_dv[:type] = attributes["type"] if attributes["type"] @current_dv[:operator] = attributes["operator"] if attributes["operator"] @current_dv[:error_style] = attributes["errorStyle"] if attributes["errorStyle"] @current_dv[:allow_blank] = true if attributes["allowBlank"] == "1" @current_dv[:show_input_message] = true if attributes["showInputMessage"] == "1" @current_dv[:show_error_message] = true if attributes["showErrorMessage"] == "1" @current_dv[:error_title] = xml_unescape(attributes["errorTitle"]) if attributes["errorTitle"] @current_dv[:error] = xml_unescape(attributes["error"]) if attributes["error"] @current_dv[:prompt_title] = xml_unescape(attributes["promptTitle"]) if attributes["promptTitle"] @current_dv[:prompt] = xml_unescape(attributes["prompt"]) if attributes["prompt"] @current_dv[:show_drop_down] = true if attributes["showDropDown"] == "1" @current_dv[:ime_mode] = attributes["imeMode"] if attributes["imeMode"] when "formula1" @inside_formula1 = true @text_buffer = +"" when "formula2" @inside_formula2 = true @text_buffer = +"" end end