Class: Aspose::Cloud::Cells::Workbook
- Inherits:
-
Object
- Object
- Aspose::Cloud::Cells::Workbook
- Defined in:
- lib/Cells/workbook.rb
Instance Method Summary collapse
- #add_worksheet(worksheet_name = '') ⇒ Object
- #clear_modify_password(password = '') ⇒ Object
- #create_empty_workbook ⇒ Object
- #create_workbook_from_smart_marker_template(template_file_name = '', data_file = '') ⇒ Object
- #create_workbook_from_template(template_file_name) ⇒ Object
- #decrypt_password(password) ⇒ Object
- #encrypt_workbook(encryption_type = 'XOR', password = '', key_length = '') ⇒ Object
- #get_default_style ⇒ Object
- #get_name_count ⇒ Object
- #get_properties ⇒ Object
- #get_property(property_name) ⇒ Object
- #get_worksheets_count ⇒ Object
-
#initialize(filename) ⇒ Workbook
constructor
A new instance of Workbook.
- #merge_workbook(merge_file_name = '') ⇒ Object
- #process_smart_marker(data_file = '') ⇒ Object
- #protect_workbook(protection_type = 'all', password = '') ⇒ Object
- #remove_all_properties ⇒ Object
- #remove_property(property_name) ⇒ Object
- #remove_worksheet(worksheet_name = '') ⇒ Object
- #set_modify_password(password = '') ⇒ Object
- #set_property(property_name = '', property_value = '') ⇒ Object
- #unprotect_workbook(password) ⇒ Object
Constructor Details
#initialize(filename) ⇒ Workbook
Returns a new instance of Workbook.
5 6 7 |
# File 'lib/Cells/workbook.rb', line 5 def initialize filename @filename = filename end |
Instance Method Details
#add_worksheet(worksheet_name = '') ⇒ Object
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
# File 'lib/Cells/workbook.rb', line 376 def add_worksheet worksheet_name='' begin if @filename == '' raise 'Base file name not specified' end str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + worksheet_name signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.put(signed_uri, '',:accept => 'application/json') json = JSON.parse(response) if json['Code']==201 return true else return false end rescue Exception=>e print e end end |
#clear_modify_password(password = '') ⇒ Object
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/Cells/workbook.rb', line 331 def clear_modify_password password='' begin if @filename == '' raise 'Base file name not specified' end fields_array = Hash.new fields_array['Password'] = password json_data = fields_array.to_json str_uri = $product_uri + '/cells/' + @filename + '/writeProtection' signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.delete(signed_uri,json_data, 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 |
#create_empty_workbook ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/Cells/workbook.rb', line 131 def create_empty_workbook begin str_uri = $product_uri + '/cells/' + @filename signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.put(signed_uri,'', :accept => 'application/json') json = JSON.parse(response) return json rescue Exception=>e print e end end |
#create_workbook_from_smart_marker_template(template_file_name = '', data_file = '') ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/Cells/workbook.rb', line 160 def create_workbook_from_smart_marker_template template_file_name ='',data_file='' begin if template_file_name == '' raise 'Template file not specified' end if data_file == '' raise 'Data file not specified' end str_uri = $product_uri + '/cells/' + @filename + '?templatefile=' + template_file_name + '&dataFile=' + data_file signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.put(signed_uri,'', :accept => 'application/json') json = JSON.parse(response) return json rescue Exception=>e print e end end |
#create_workbook_from_template(template_file_name) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/Cells/workbook.rb', line 144 def create_workbook_from_template template_file_name begin if template_file_name == '' raise 'Template file not specified' end str_uri = $product_uri + '/cells/' + @filename + '?templatefile=' + template_file_name signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.put(signed_uri,'', :accept => 'application/json') json = JSON.parse(response) return json rescue Exception=>e print e end end |
#decrypt_password(password) ⇒ Object
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
# File 'lib/Cells/workbook.rb', line 354 def decrypt_password password begin if @filename == '' raise 'Base file name not specified' end fields_array = Hash.new fields_array['Password'] = password json_data = fields_array.to_json str_uri = $product_uri + '/cells/' + @filename + '/encryption' signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.delete(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 |
#encrypt_workbook(encryption_type = 'XOR', password = '', key_length = '') ⇒ Object
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/Cells/workbook.rb', line 240 def encrypt_workbook encryption_type='XOR',password='',key_length='' begin if @filename == '' raise 'Base file name not specified' end fields_array = Hash.new fields_array['EncriptionType'] = encryption_type fields_array['KeyLength'] = key_length fields_array['Password'] = password json_data = fields_array.to_json str_uri = $product_uri + '/cells/' + @filename + '/encryption' 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 |
#get_default_style ⇒ Object
225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/Cells/workbook.rb', line 225 def get_default_style begin if @filename == '' raise 'Base file name not specified' end str_uri = $product_uri + '/cells/' + @filename + '/defaultStyle' signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.get(signed_uri, :accept => 'application/json') json = JSON.parse(response) return json['Style'] rescue Exception=>e print e end end |
#get_name_count ⇒ Object
210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/Cells/workbook.rb', line 210 def get_name_count begin if @filename == '' raise 'Base file name not specified' end str_uri = $product_uri + '/cells/' + @filename + '/names' signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.get(signed_uri, :accept => 'application/json') json = JSON.parse(response) return json['Names'].count rescue Exception=>e print e end end |
#get_properties ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/Cells/workbook.rb', line 9 def get_properties begin if @filename == '' raise 'Base file name not specified.' end str_uri = $product_uri + '/cells/' + @filename + '/documentProperties' signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.get(signed_uri, :accept => 'application/json') json = JSON.parse(response) if json['Code'] == 200 return json['DocumentProperties']['DocumentPropertyList'] else return false end rescue Exception=>e print e end end |
#get_property(property_name) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/Cells/workbook.rb', line 30 def get_property property_name begin if @filename == '' raise 'Base file name not specified.' end if property_name == '' raise 'Property name is not specified.' end str_uri = $product_uri + '/cells/' + @filename + '/documentProperties/' + property_name signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.get(signed_uri, :accept => 'application/json') json = JSON.parse(response) if json['Code'] == 200 return json['DocumentProperty'] else return false end rescue Exception=>e print e end end |
#get_worksheets_count ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/Cells/workbook.rb', line 195 def get_worksheets_count begin if @filename == '' raise 'Base file name not specified' end str_uri = $product_uri + '/cells/' + @filename + '/worksheets' signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.get(signed_uri, :accept => 'application/json') json = JSON.parse(response) return json['Worksheets']['WorksheetList'].size rescue Exception=>e print e end end |
#merge_workbook(merge_file_name = '') ⇒ Object
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
# File 'lib/Cells/workbook.rb', line 414 def merge_workbook merge_file_name ='' begin if @filename == '' raise 'Base file name not specified' end str_uri = $product_uri + '/cells/' + @filename + '/merge?mergeWith=' + merge_file_name signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.post(signed_uri,'',:accept => 'application/json') json = JSON.parse(response) if json['Code']==200 return true else return false end rescue Exception=>e print e end end |
#process_smart_marker(data_file = '') ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/Cells/workbook.rb', line 179 def process_smart_marker data_file='' begin if data_file == '' raise 'Data file not specified' end str_uri = $product_uri + '/cells/' + @filename + '/smartmarker?xmlFile=' + data_file signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.post(signed_uri,'', :accept => 'application/json') json = JSON.parse(response) return json rescue Exception=>e print e end end |
#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 |
#remove_all_properties ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/Cells/workbook.rb', line 86 def remove_all_properties begin if @filename == '' raise 'Base file name not specified.' end str_uri = $product_uri + '/cells/' + @filename + '/documentProperties' signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.delete(signed_uri, :accept=>'application/json') json = JSON.parse(response) if json['Code'] == 200 return true else return false end rescue Exception=>e print e end end |
#remove_property(property_name) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/Cells/workbook.rb', line 107 def remove_property property_name begin if @filename == '' raise 'Base file name not specified.' end if property_name == '' raise 'Property name is not specified.' end str_uri = $product_uri + '/cells/' + @filename + '/documentProperties/' + property_name signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.delete(signed_uri, :accept => 'application/json') json = JSON.parse(response) if json['Code'] == 200 return true else return false end rescue Exception=>e print e end end |
#remove_worksheet(worksheet_name = '') ⇒ Object
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
# File 'lib/Cells/workbook.rb', line 395 def remove_worksheet worksheet_name='' begin if @filename == '' raise 'Base file name not specified' end str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + worksheet_name signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.delete(signed_uri,:accept => 'application/json') json = JSON.parse(response) if json['Code']==200 return true else return false end rescue Exception=>e print e end end |
#set_modify_password(password = '') ⇒ Object
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/Cells/workbook.rb', line 309 def set_modify_password password='' begin if @filename == '' raise 'Base file name not specified' end fields_array = Hash.new fields_array['Password'] = password json_data = fields_array.to_json str_uri = $product_uri + '/cells/' + @filename + '/writeProtection' signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.put(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 |
#set_property(property_name = '', property_value = '') ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/Cells/workbook.rb', line 54 def set_property property_name='',property_value='' begin if @filename == '' raise 'Base file name not specified.' end if property_name == '' raise 'Property name is not specified.' end if property_value == '' raise 'Property Value is not specified.' end str_uri = $product_uri + '/cells/' + @filename + '/documentProperties/' + property_name put_data_arr = Hash.new put_data_arr['Link'] = nil put_data_arr['Name'] = property_name put_data_arr['Value'] = property_value put_data_arr['BuiltIn'] = 'False' json_data = put_data_arr.to_json signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.put(signed_uri,json_data, :accept => 'application/json') json = JSON.parse(response) if json['Code'] == 200 return json['DocumentProperty'] else return false end rescue Exception=>e print e end end |
#unprotect_workbook(password) ⇒ Object
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/Cells/workbook.rb', line 287 def unprotect_workbook password begin if @filename == '' raise 'Base file name not specified' end fields_array = Hash.new 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.delete(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 |