Class: Axlsx::SheetProtection
- Inherits:
-
Object
- Object
- Axlsx::SheetProtection
- Defined in:
- lib/axlsx/workbook/worksheet/sheet_protection.rb
Overview
The SheetProtection object manages worksheet protection options per sheet.
Instance Attribute Summary collapse
-
#auto_filter ⇒ Boolean
readonly
If 1 or true then AutoFilters should not be allowed to operate when the sheet is protected.
-
#delete_columns ⇒ Boolean
readonly
If 1 or true then deleting columns should not be allowed when the sheet is protected.
-
#delete_rows ⇒ Boolean
readonly
If 1 or true then deleting rows should not be allowed when the sheet is protected.
-
#format_cells ⇒ Boolean
readonly
If 1 or true then formatting cells should not be allowed when the sheet is protected.
-
#format_columns ⇒ Boolean
readonly
If 1 or true then formatting columns should not be allowed when the sheet is protected.
-
#format_rows ⇒ Boolean
readonly
If 1 or true then formatting rows should not be allowed when the sheet is protected.
-
#insert_columns ⇒ Boolean
readonly
If 1 or true then inserting columns should not be allowed when the sheet is protected.
-
#insert_hyperlinks ⇒ Boolean
readonly
If 1 or true then inserting hyperlinks should not be allowed when the sheet is protected.
-
#insert_rows ⇒ Boolean
readonly
If 1 or true then inserting rows should not be allowed when the sheet is protected.
-
#objects ⇒ Boolean
readonly
If 1 or true then editing of objects should not be allowed when the sheet is protected.
-
#password ⇒ String
Password hash default nil.
-
#pivot_tables ⇒ Boolean
readonly
If 1 or true then PivotTables should not be allowed to operate when the sheet is protected.
-
#salt_value ⇒ String
readonly
Specifies the salt which was prepended to the user-supplied password before it was hashed using the hashing algorithm.
-
#scenarios ⇒ Boolean
readonly
If 1 or true then Scenarios should not be edited when the sheet is protected.
-
#select_locked_cells ⇒ Boolean
readonly
If 1 or true then selection of locked cells should not be allowed when the sheet is protected.
-
#select_unlocked_cells ⇒ Boolean
readonly
If 1 or true then selection of unlocked cells should not be allowed when the sheet is protected.
-
#sheet ⇒ Boolean
readonly
If 1 or true then the sheet is protected.
-
#sort ⇒ Boolean
readonly
If 1 or true then sorting should not be allowed when the sheet is protected.
Instance Method Summary collapse
-
#f_name ⇒ Boolean
create validating setters for boolean values.
-
#initialize(options = {}) ⇒ SheetProtection
constructor
Creates a new SheetProtection instance.
-
#to_xml_string(str = '') ⇒ String
Serialize the object.
Constructor Details
#initialize(options = {}) ⇒ SheetProtection
Creates a new SheetProtection instance
131 132 133 134 135 136 137 138 139 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 131 def initialize(={}) @objects = @scenarios = @select_locked_cells = @select_unlocked_cells = false @sheet = @format_cells = @format_rows = @format_columns = @insert_columns = @insert_rows = @insert_hyperlinks = @delete_columns = @delete_rows = @sort = @auto_filter = @pivot_tables = true @password = nil .each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" end end |
Instance Attribute Details
#auto_filter ⇒ Boolean (readonly)
If 1 or true then AutoFilters should not be allowed to operate when the sheet is protected. If 0 or false then AutoFilters should be allowed to operate when the sheet is protected. default true
11 12 13 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 11 def auto_filter @auto_filter end |
#delete_columns ⇒ Boolean (readonly)
If 1 or true then deleting columns should not be allowed when the sheet is protected. If 0 or false then deleting columns should be allowed when the sheet is protected. default true
17 18 19 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 17 def delete_columns @delete_columns end |
#delete_rows ⇒ Boolean (readonly)
If 1 or true then deleting rows should not be allowed when the sheet is protected. If 0 or false then deleting rows should be allowed when the sheet is protected. default true
23 24 25 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 23 def delete_rows @delete_rows end |
#format_cells ⇒ Boolean (readonly)
If 1 or true then formatting cells should not be allowed when the sheet is protected. If 0 or false then formatting cells should be allowed when the sheet is protected. default true
29 30 31 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 29 def format_cells @format_cells end |
#format_columns ⇒ Boolean (readonly)
If 1 or true then formatting columns should not be allowed when the sheet is protected. If 0 or false then formatting columns should be allowed when the sheet is protected. default true
35 36 37 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 35 def format_columns @format_columns end |
#format_rows ⇒ Boolean (readonly)
If 1 or true then formatting rows should not be allowed when the sheet is protected. If 0 or false then formatting rows should be allowed when the sheet is protected. default true
41 42 43 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 41 def format_rows @format_rows end |
#insert_columns ⇒ Boolean (readonly)
If 1 or true then inserting columns should not be allowed when the sheet is protected. If 0 or false then inserting columns should be allowed when the sheet is protected. default true
47 48 49 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 47 def insert_columns @insert_columns end |
#insert_hyperlinks ⇒ Boolean (readonly)
If 1 or true then inserting hyperlinks should not be allowed when the sheet is protected. If 0 or false then inserting hyperlinks should be allowed when the sheet is protected. default true
53 54 55 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 53 def insert_hyperlinks @insert_hyperlinks end |
#insert_rows ⇒ Boolean (readonly)
If 1 or true then inserting rows should not be allowed when the sheet is protected. If 0 or false then inserting rows should be allowed when the sheet is protected. default true
59 60 61 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 59 def insert_rows @insert_rows end |
#objects ⇒ Boolean (readonly)
If 1 or true then editing of objects should not be allowed when the sheet is protected. If 0 or false then objects are allowed to be edited when the sheet is protected. default false
65 66 67 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 65 def objects @objects end |
#password ⇒ String
Password hash default nil
110 111 112 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 110 def password @password end |
#pivot_tables ⇒ Boolean (readonly)
If 1 or true then PivotTables should not be allowed to operate when the sheet is protected. If 0 or false then PivotTables should be allowed to operate when the sheet is protected. default true
71 72 73 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 71 def pivot_tables @pivot_tables end |
#salt_value ⇒ String (readonly)
Specifies the salt which was prepended to the user-supplied password before it was hashed using the hashing algorithm
75 76 77 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 75 def salt_value @salt_value end |
#scenarios ⇒ Boolean (readonly)
If 1 or true then Scenarios should not be edited when the sheet is protected. If 0 or false then Scenarios are allowed to be edited when the sheet is protected. default false
81 82 83 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 81 def scenarios @scenarios end |
#select_locked_cells ⇒ Boolean (readonly)
If 1 or true then selection of locked cells should not be allowed when the sheet is protected. If 0 or false then selection of locked cells should be allowed when the sheet is protected. default false
87 88 89 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 87 def select_locked_cells @select_locked_cells end |
#select_unlocked_cells ⇒ Boolean (readonly)
If 1 or true then selection of unlocked cells should not be allowed when the sheet is protected. If 0 or false then selection of unlocked cells should be allowed when the sheet is protected. default false
93 94 95 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 93 def select_unlocked_cells @select_unlocked_cells end |
#sheet ⇒ Boolean (readonly)
If 1 or true then the sheet is protected. If 0 or false then the sheet is not protected. default true
99 100 101 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 99 def sheet @sheet end |
#sort ⇒ Boolean (readonly)
If 1 or true then sorting should not be allowed when the sheet is protected. If 0 or false then sorting should be allowed when the sheet is protected. default true
105 106 107 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 105 def sort @sort end |
Instance Method Details
#f_name ⇒ Boolean
create validating setters for boolean values
144 145 146 147 148 149 150 151 152 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 144 [:sheet, :objects, :scenarios, :select_locked_cells, :sort, :select_unlocked_cells, :format_cells, :format_rows, :format_columns, :insert_columns, :insert_rows, :insert_hyperlinks, :delete_columns, :delete_rows, :auto_filter, :pivot_tables].each do |f_name| define_method "#{f_name.to_s}=".to_sym do |v| Axlsx::validate_boolean(v) instance_variable_set "@#{f_name.to_s}".to_sym, v end end |
#to_xml_string(str = '') ⇒ String
Serialize the object
181 182 183 184 185 |
# File 'lib/axlsx/workbook/worksheet/sheet_protection.rb', line 181 def to_xml_string(str = '') str << '<sheetProtection ' str << instance_values.map{ |k,v| k.gsub(/_(.)/){ $1.upcase } << %{="#{v.to_s}"} }.join(' ') str << '/>' end |