class Axlsx::ProtectedRanges
A self serializing collection of ranges that should be protected in the worksheet
Attributes
worksheet[R]
Public Class Methods
new(worksheet)
click to toggle source
Calls superclass method
Axlsx::SimpleTypedList::new
# File lib/axlsx/workbook/worksheet/protected_ranges.rb, line 9 def initialize(worksheet) raise ArgumentError, 'You must provide a worksheet' unless worksheet.is_a?(Worksheet) super ProtectedRange @worksheet = worksheet end
Public Instance Methods
add_range(cells)
click to toggle source
Adds a protected range @param [Array|String] cells A string range reference or array of cells that will be protected
# File lib/axlsx/workbook/worksheet/protected_ranges.rb, line 17 def add_range(cells) sqref = if cells.is_a?(String) cells elsif cells.is_a?(SimpleTypedList) || cells.is_a?(Array) Axlsx::cell_range(cells, false) end @list << ProtectedRange.new(:sqref => sqref, :name => "Range#{size}") last end
to_xml_string(str = '')
click to toggle source
# File lib/axlsx/workbook/worksheet/protected_ranges.rb, line 27 def to_xml_string(str = '') return if empty? str << '<protectedRanges>' each { |range| range.to_xml_string(str) } str << '</protectedRanges>' end