Class: Axlsx::DataValidations

Inherits:
SimpleTypedList
  • Object
show all
Defined in:
lib/axlsx/workbook/worksheet/data_validations.rb

Overview

A simple, self serializing class for storing conditional formattings

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(worksheet) ⇒ DataValidations

creates a new Tables object

Raises:

  • (ArgumentError)


5
6
7
8
9
10
# File 'lib/axlsx/workbook/worksheet/data_validations.rb', line 5

def initialize(worksheet)
  raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)

  super DataValidation
  @worksheet = worksheet
end

Instance Attribute Details

#worksheetWorksheet (readonly)

The worksheet that owns this collection of tables

Returns:



14
15
16
# File 'lib/axlsx/workbook/worksheet/data_validations.rb', line 14

def worksheet
  @worksheet
end

Instance Method Details

#to_xml_string(str = "") ⇒ Object

serialize the conditional formattings



17
18
19
20
21
22
23
# File 'lib/axlsx/workbook/worksheet/data_validations.rb', line 17

def to_xml_string(str = "")
  return if empty?

  str << "<dataValidations count='#{size}'>"
  each { |item| item.to_xml_string(str) }
  str << '</dataValidations>'
end