summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/stylesheet/cell_protection.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2011-11-20 23:22:04 +0900
committerRandy Morgan <[email protected]>2011-11-20 23:22:04 +0900
commite53f04284618713b0a90b7a691425c380e829476 (patch)
tree801fea138160f9af426d62bf94ad5bf97123ece9 /lib/axlsx/stylesheet/cell_protection.rb
downloadcaxlsx-e53f04284618713b0a90b7a691425c380e829476.tar.gz
caxlsx-e53f04284618713b0a90b7a691425c380e829476.zip
first commit
Diffstat (limited to 'lib/axlsx/stylesheet/cell_protection.rb')
-rw-r--r--lib/axlsx/stylesheet/cell_protection.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/axlsx/stylesheet/cell_protection.rb b/lib/axlsx/stylesheet/cell_protection.rb
new file mode 100644
index 00000000..7f0f4db8
--- /dev/null
+++ b/lib/axlsx/stylesheet/cell_protection.rb
@@ -0,0 +1,33 @@
+module Axlsx
+ # CellProtection stores information about locking or hiding cells in spreadsheet.
+ # @note Using Styles#add_style is the recommended way to manage cell protection.
+ # @see Styles#add_style
+ class CellProtection
+
+ # specifies locking for cells that have the style containing this protection
+ # @return [Boolean]
+ attr_accessor :hidden
+
+ # specifies if the cells that have the style containing this protection
+ # @return [Boolean]
+ attr_accessor :locked
+
+ # Creates a new CellProtection
+ # @option options [Boolean] hidden value for hidden protection
+ # @option options [Boolean] locked value for locked protection
+ def initialize(options={})
+ options.each do |o|
+ self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
+ end
+ end
+ def hidden=(v) Axlsx::validate_boolean v; @hidden = v end
+ def locked=(v) Axlsx::validate_boolean v; @locked = v end
+
+ # Serializes the cell protection
+ # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
+ # @return [String]
+ def to_xml(xml)
+ xml.protection(self.instance_values)
+ end
+ end
+end