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.



261
262
263
# File 'lib/ooxml_excel/sheet.rb', line 261

def allow_blank
  @allow_blank
end

#formulaObject

Returns the value of attribute formula.



261
262
263
# File 'lib/ooxml_excel/sheet.rb', line 261

def formula
  @formula
end

#promptObject

Returns the value of attribute prompt.



261
262
263
# File 'lib/ooxml_excel/sheet.rb', line 261

def prompt
  @prompt
end

#sqrefObject

Returns the value of attribute sqref.



261
262
263
# File 'lib/ooxml_excel/sheet.rb', line 261

def sqref
  @sqref
end

#typeObject

Returns the value of attribute type.



261
262
263
# File 'lib/ooxml_excel/sheet.rb', line 261

def type
  @type
end

Class Method Details

.load_from_node(data_validation_node) ⇒ Object



271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/ooxml_excel/sheet.rb', line 271

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

#in_sqref_range?(cell_id) ⇒ Boolean

Returns:

  • (Boolean)


263
264
265
266
267
268
269
# File 'lib/ooxml_excel/sheet.rb', line 263

def in_sqref_range?(cell_id)
  return if cell_id.blank?
  cell_letter = cell_id.gsub(/[\d]/, '')
  index = cell_id.gsub(/[^\d]/, '').to_i
  range = sqref_range.find { |single_cell_letter_or_range, row_range| single_cell_letter_or_range.is_a?(Range) ? single_cell_letter_or_range.cover?(cell_letter) : single_cell_letter_or_range == cell_letter}
  range.last.include?(index) if range.present?
end