Method: Aspose::Cloud::Cells::Workbook#protect_workbook

Defined in:
lib/Cells/workbook.rb

#protect_workbook(protection_type = 'all', password = '') ⇒ Object



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/Cells/workbook.rb', line 264

def protect_workbook protection_type = 'all',password=''
  begin
    if @filename == ''
      raise 'Base file name not specified'
    end
    fields_array = Hash.new
    fields_array['ProtectionType'] = protection_type
    fields_array['Password'] = password
    json_data = fields_array.to_json
    str_uri = $product_uri + '/cells/' + @filename + '/protection'
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
    response = RestClient.post(signed_uri, json_data,:accept => 'application/json')
    json = JSON.parse(response)
    if json['Code']==200
      return true
    else
      return false
    end
  rescue Exception=>e
    print e
  end
end