class OoxmlParser::DataValidation

Class for ‘dataValidation` data

Attributes

allow_blank[R]

@return [Boolean] should blank entries be valid

error[R]

@return [String] Specifies the message text of the error alert

error_style[R]

@return [Symbol] Type of error

error_title[R]

@return [String] The text of the title bar of the error alert

formula1[R]

@return [DataValidationFormula] first formula of data validation

formula2[R]

@return [DataValidationFormula] second formula of data validation

ime_mode[R]

@return [Symbol] Input Method Editor (IME) mode

operator[R]

@return [Symbol] Relational operator used with this data validation

prompt[R]

@return [String] Message text of the input prompt

prompt_title[R]

@return [String] Text of the title bar of the input prompt

reference_sequence[R]

@return [String] Ranges to which data validation is applied

show_dropdown[R]

@return [Symbol] Specifies whether to display the drop-down combo box

show_error_message[R]

@return [Symbol] Specifies whether to display error alert message

show_input_message[R]

@return [Symbol] Specifies whether to display the input prompt

type[R]

@return [Symbol] Type of validation

uid[R]

@return [String] UID of validation

Public Instance Methods

parse(node) click to toggle source

Parse DataValidation data @param [Nokogiri::XML:Element] node with DataValidation data @return [DataValidation] value of DataValidation data

# File lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb, line 43
def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'allowBlank'
      @allow_blank = attribute_enabled?(value)
    when 'error'
      @error = value.value.to_s
    when 'errorStyle'
      @error_style = value.value.to_sym
    when 'errorTitle'
      @error_title = value.value.to_s
    when 'imeMode'
      @ime_mode = value.value.to_sym
    when 'operator'
      @operator = value.value.to_sym
    when 'type'
      @type = value.value.to_sym
    when 'prompt'
      @prompt = value.value.to_s
    when 'promptTitle'
      @prompt_title = value.value.to_s
    when 'showDropDown'
      @show_dropdown = attribute_enabled?(value)
    when 'showInputMessage'
      @show_input_message = attribute_enabled?(value)
    when 'showErrorMessage'
      @show_error_message = attribute_enabled?(value)
    when 'uid'
      @uid = value.value.to_s
    end
  end

  node.xpath('*').each do |node_child|
    case node_child.name
    when 'formula1'
      @formula1 = DataValidationFormula.new(parent: self).parse(node_child)
    when 'formula2'
      @formula2 = DataValidationFormula.new(parent: self).parse(node_child)
    when 'sqref'
      @reference_sequence = node_child.text
    end
  end
  self
end