Class: Axlsx::CellProtection

Inherits:
Object
  • Object
show all
Defined in:
lib/axlsx/stylesheet/cell_protection.rb

Overview

Note:

Using Styles#add_style is the recommended way to manage cell protection.

CellProtection stores information about locking or hiding cells in spreadsheet.

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CellProtection

Creates a new CellProtection

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • hidden (Boolean)

    value for hidden protection

  • locked (Boolean)

    value for locked protection



19
20
21
22
23
# File 'lib/axlsx/stylesheet/cell_protection.rb', line 19

def initialize(options={})
  options.each do |o|
    self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
  end
end

Instance Attribute Details

#hiddenBoolean

specifies locking for cells that have the style containing this protection

Returns:

  • (Boolean)


10
11
12
# File 'lib/axlsx/stylesheet/cell_protection.rb', line 10

def hidden
  @hidden
end

#lockedBoolean

specifies if the cells that have the style containing this protection

Returns:

  • (Boolean)


14
15
16
# File 'lib/axlsx/stylesheet/cell_protection.rb', line 14

def locked
  @locked
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

  • str (String) (defaults to: '')

Returns:

  • (String)


33
34
35
36
37
# File 'lib/axlsx/stylesheet/cell_protection.rb', line 33

def to_xml_string(str = '')
  str << '<protection '
  str << instance_values.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ')
  str << '/>'
end