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

- (CellProtection) initialize(options = {})

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



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

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

Instance Attribute Details

- (Boolean) hidden

specifies locking for cells that have the style containing this protection

Returns:

  • (Boolean)


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

def 
  @hidden
end

- (Boolean) locked

specifies if the cells that have the style containing this protection

Returns:

  • (Boolean)


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

def locked
  @locked
end

Instance Method Details

- (String) to_xml(xml)

Serializes the cell protection

Parameters:

  • xml (Nokogiri::XML::Builder)

    The document builder instance this objects xml will be added to.

Returns:

  • (String)


29
30
31
# File 'lib/axlsx/stylesheet/cell_protection.rb', line 29

def to_xml(xml)
  xml.protection(self.instance_values)
end