Class: OOXML::Excel::Sheet::DataValidation

Inherits:
Object
  • Object
show all
Defined in:
lib/ooxml_excel/sheet.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#allow_blankObject

Returns the value of attribute allow_blank.



194
195
196
# File 'lib/ooxml_excel/sheet.rb', line 194

def allow_blank
  @allow_blank
end

#formulaObject

Returns the value of attribute formula.



194
195
196
# File 'lib/ooxml_excel/sheet.rb', line 194

def formula
  @formula
end

#promptObject

Returns the value of attribute prompt.



194
195
196
# File 'lib/ooxml_excel/sheet.rb', line 194

def prompt
  @prompt
end

#sqrefObject

Returns the value of attribute sqref.



194
195
196
# File 'lib/ooxml_excel/sheet.rb', line 194

def sqref
  @sqref
end

#typeObject

Returns the value of attribute type.



194
195
196
# File 'lib/ooxml_excel/sheet.rb', line 194

def type
  @type
end

Class Method Details

.load_from_node(data_validation_node) ⇒ Object



213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/ooxml_excel/sheet.rb', line 213

def self.load_from_node(data_validation_node)
  allow_blank = data_validation_node.attribute('allowBlank').try(:value)
  prompt = data_validation_node.attribute('prompt').try(:value)
  type = data_validation_node.attribute('type').try(:value)
  sqref = data_validation_node.attribute('sqref').try(:value)
  formula = data_validation_node.at('formula1').try(:content)

  self.new(allow_blank: allow_blank,
           prompt: prompt,
           type: type,
           sqref: sqref,
           formula: formula)
end

Instance Method Details

#sqref_rangeObject



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/ooxml_excel/sheet.rb', line 196

def sqref_range
  @sqref_range ||= begin
    # "BH5:BH271 BI5:BI271"
    sqref.split( ' ').map do |splitted_by_space_sqref|
      # ["BH5:BH271, "BI5:BI271"]
      if splitted_by_space_sqref.is_a?(Array)
        splitted_by_space_sqref.map do |sqref|
          split_sqref(sqref)
        end
      else
        # "BH5:BH271"
        split_sqref(splitted_by_space_sqref)
      end
    end.flatten.uniq
  end
end