def protect(password = nil, options = {})
      check_parameter(options, protect_default_settings.keys, 'protect')
      @protect = protect_default_settings.merge(options)

      # Set the password after the user defined values.
      @protect[:password] =
        sprintf("%X", encode_password(password)) if password && password != ''
    end
def protect(password = nil, options = {})
      check_parameter(options, protect_default_settings.keys, 'protect')
      @protect = protect_default_settings.merge(options)

      # Set the password after the user defined values.
      @protect[:password] =
        sprintf("%X", encode_password(password)) if password && password != ''
    end
Set the worksheet protection flags to prevent modification of worksheet
 objects.

 The protect() method is used to protect a worksheet from modification:

     worksheet.protect

 The protect() method also has the effect of enabling a cell's locked
 and hidden properties if they have been set. A locked cell cannot be
 edited and this property is on by default for all cells. A hidden
 cell will display the results of a formula but not the formula itself.

 See the protection.rb program in the examples directory of the distro
 for an illustrative example and the +set_locked+ and +set_hidden+ format
 methods in "CELL FORMATTING", see Format.

 You can optionally add a password to the worksheet protection:

     worksheet.protect('drowssap')

 Passing the empty string '' is the same as turning on protection
 without a password.

 Note, the worksheet level password in Excel provides very weak
 protection. It does not encrypt your data and is very easy to
 deactivate. Full workbook encryption is not supported by WriteXLSX
 since it requires a completely different file format and would take
 several man months to implement.

 You can specify which worksheet elements that you which to protect
 by passing a hash with any or all of the following keys:

     # Default shown.
     options = {
         :objects               => false,
         :scenarios             => false,
         :format_cells          => false,
         :format_columns        => false,
         :format_rows           => false,
         :insert_columns        => false,
         :insert_rows           => false,
         :insert_hyperlinks     => false,
         :delete_columns        => false,
         :delete_rows           => false,
         :select_locked_cells   => true,
         :sort                  => false,
         :autofilter            => false,
         :pivot_tables          => false,
         :select_unlocked_cells => true
     }

 The default boolean values are shown above. Individual elements
 can be protected as follows:

     worksheet.protect('drowssap', { :insert_rows => true } )