Class: OoxmlParser::DataValidation

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb

Overview

Class for ‘dataValidation` data

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #initialize, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#allow_blankBoolean (readonly)

Returns should blank entries be valid.

Returns:

  • (Boolean)

    should blank entries be valid



8
9
10
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb', line 8

def allow_blank
  @allow_blank
end

#errorString (readonly)

Returns Specifies the message text of the error alert.

Returns:

  • (String)

    Specifies the message text of the error alert



10
11
12
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb', line 10

def error
  @error
end

#error_styleSymbol (readonly)

Returns Type of error.

Returns:

  • (Symbol)

    Type of error



12
13
14
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb', line 12

def error_style
  @error_style
end

#error_titleString (readonly)

Returns The text of the title bar of the error alert.

Returns:

  • (String)

    The text of the title bar of the error alert



14
15
16
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb', line 14

def error_title
  @error_title
end

#formula1DataValidationFormula (readonly)

Returns first formula of data validation.

Returns:



16
17
18
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb', line 16

def formula1
  @formula1
end

#formula2DataValidationFormula (readonly)

Returns second formula of data validation.

Returns:



18
19
20
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb', line 18

def formula2
  @formula2
end

#ime_modeSymbol (readonly)

Returns Input Method Editor (IME) mode.

Returns:

  • (Symbol)

    Input Method Editor (IME) mode



20
21
22
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb', line 20

def ime_mode
  @ime_mode
end

#operatorSymbol (readonly)

Returns Relational operator used with this data validation.

Returns:

  • (Symbol)

    Relational operator used with this data validation



22
23
24
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb', line 22

def operator
  @operator
end

#promptString (readonly)

Returns Message text of the input prompt.

Returns:

  • (String)

    Message text of the input prompt



24
25
26
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb', line 24

def prompt
  @prompt
end

#prompt_titleString (readonly)

Returns Text of the title bar of the input prompt.

Returns:

  • (String)

    Text of the title bar of the input prompt



26
27
28
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb', line 26

def prompt_title
  @prompt_title
end

#reference_sequenceString (readonly)

Returns Ranges to which data validation is applied.

Returns:

  • (String)

    Ranges to which data validation is applied



28
29
30
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb', line 28

def reference_sequence
  @reference_sequence
end

#show_dropdownSymbol (readonly)

Returns Specifies whether to display the drop-down combo box.

Returns:

  • (Symbol)

    Specifies whether to display the drop-down combo box



30
31
32
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb', line 30

def show_dropdown
  @show_dropdown
end

#show_error_messageSymbol (readonly)

Returns Specifies whether to display error alert message.

Returns:

  • (Symbol)

    Specifies whether to display error alert message



34
35
36
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb', line 34

def show_error_message
  @show_error_message
end

#show_input_messageSymbol (readonly)

Returns Specifies whether to display the input prompt.

Returns:

  • (Symbol)

    Specifies whether to display the input prompt



32
33
34
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb', line 32

def show_input_message
  @show_input_message
end

#typeSymbol (readonly)

Returns Type of validation.

Returns:

  • (Symbol)

    Type of validation



36
37
38
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb', line 36

def type
  @type
end

#uidString (readonly)

Returns UID of validation.

Returns:

  • (String)

    UID of validation



38
39
40
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/data_validations/data_validation.rb', line 38

def uid
  @uid
end

Instance Method Details

#parse(node) ⇒ DataValidation

Parse DataValidation data

Parameters:

  • node (Nokogiri::XML:Element)

    with DataValidation data

Returns:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# 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