asposecloudsdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/.project +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +4 -0
- data/Rakefile +1 -0
- data/asposecloudsdk.gemspec +24 -0
- data/lib/Barcode/builder.rb +31 -0
- data/lib/Barcode/reader.rb +87 -0
- data/lib/Cells/chart_editor.rb +145 -0
- data/lib/Cells/convertor.rb +225 -0
- data/lib/Cells/extractor.rb +155 -0
- data/lib/Cells/text_editor.rb +99 -0
- data/lib/Cells/workbook.rb +437 -0
- data/lib/Cells/worksheet.rb +819 -0
- data/lib/Common/aspose_app.rb +14 -0
- data/lib/Common/product.rb +17 -0
- data/lib/Common/utils.rb +108 -0
- data/lib/Ocr/extractor.rb +128 -0
- data/lib/Pdf/annotation_editor.rb +533 -0
- data/lib/Pdf/converter.rb +201 -0
- data/lib/Pdf/document.rb +643 -0
- data/lib/Pdf/extractor.rb +139 -0
- data/lib/Pdf/text_editor.rb +231 -0
- data/lib/Slides/converter.rb +105 -0
- data/lib/Slides/document.rb +489 -0
- data/lib/Slides/extractor.rb +208 -0
- data/lib/Storage/folder.rb +227 -0
- data/lib/Words/builder.rb +159 -0
- data/lib/Words/converter.rb +79 -0
- data/lib/Words/document.rb +295 -0
- data/lib/Words/extractor.rb +318 -0
- data/lib/Words/mail_merge.rb +143 -0
- data/lib/aspose_barcode.rb +4 -0
- data/lib/aspose_cells.rb +7 -0
- data/lib/aspose_common.rb +12 -0
- data/lib/aspose_ocr.rb +4 -0
- data/lib/aspose_pdf.rb +6 -0
- data/lib/aspose_slides.rb +4 -0
- data/lib/aspose_storage.rb +2 -0
- data/lib/aspose_words.rb +6 -0
- data/lib/asposecloudsdk.rb +10 -0
- data/lib/asposecloudsdk/version.rb +3 -0
- metadata +145 -0
@@ -0,0 +1,155 @@
|
|
1
|
+
module Aspose
|
2
|
+
module Cloud
|
3
|
+
module Cells
|
4
|
+
class Extractor
|
5
|
+
def initialize filename
|
6
|
+
@filename = filename
|
7
|
+
end
|
8
|
+
|
9
|
+
# saves a specific picture from a specific sheet as image
|
10
|
+
# @param worksheet_name
|
11
|
+
# @param picture_index
|
12
|
+
# @param image_format
|
13
|
+
def get_picture worksheet_name, picture_index, image_format
|
14
|
+
begin
|
15
|
+
if @filename==''
|
16
|
+
raise 'Base file name is not specified'
|
17
|
+
end
|
18
|
+
str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' +
|
19
|
+
worksheet_name.to_s + '/pictures/' + picture_index.to_s + '?format=' + image_format.to_s
|
20
|
+
|
21
|
+
#Sign URI
|
22
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
23
|
+
|
24
|
+
#Send request and receive response stream
|
25
|
+
response_stream = RestClient.get signed_uri, {:accept=>'application/json'}
|
26
|
+
|
27
|
+
#Validate output
|
28
|
+
v_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
29
|
+
|
30
|
+
if v_output == ''
|
31
|
+
#Save output file
|
32
|
+
output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename)+
|
33
|
+
'_' + worksheet_name + '.' + image_format
|
34
|
+
Aspose::Cloud::Common::Utils.save_file(response_stream, output_path)
|
35
|
+
return output_path
|
36
|
+
else
|
37
|
+
return v_output
|
38
|
+
end
|
39
|
+
rescue Exception=>e
|
40
|
+
print e
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# saves a specific OleObject from a specific sheet as image
|
45
|
+
# @param worksheet_name
|
46
|
+
# @param object_index
|
47
|
+
# @param image_format
|
48
|
+
|
49
|
+
def get_ole_object worksheet_name, object_index, image_format
|
50
|
+
begin
|
51
|
+
if @filename==''
|
52
|
+
raise 'Base file name is not specified'
|
53
|
+
end
|
54
|
+
str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' +
|
55
|
+
worksheet_name.to_s + '/oleobjects/' + object_index.to_s + '?format=' + image_format.to_s
|
56
|
+
|
57
|
+
#Sign URI
|
58
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
59
|
+
|
60
|
+
#Send request and receive response stream
|
61
|
+
response_stream = RestClient.get signed_uri, {:accept=>'application/json'}
|
62
|
+
|
63
|
+
#Validate output
|
64
|
+
v_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
65
|
+
|
66
|
+
if v_output == ''
|
67
|
+
#Save output file
|
68
|
+
output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename)+
|
69
|
+
'_' + worksheet_name + '.' + image_format
|
70
|
+
Aspose::Cloud::Common::Utils.save_file(response_stream, output_path)
|
71
|
+
return output_path
|
72
|
+
else
|
73
|
+
return v_output
|
74
|
+
end
|
75
|
+
rescue Exception=>e
|
76
|
+
print e
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# saves a specific chart from a specific sheet as image
|
81
|
+
# @param worksheet_name
|
82
|
+
# @param chart_index
|
83
|
+
# @param image_format
|
84
|
+
|
85
|
+
def get_chart worksheet_name, chart_index, image_format
|
86
|
+
begin
|
87
|
+
if @filename==''
|
88
|
+
raise 'Base file name is not specified'
|
89
|
+
end
|
90
|
+
str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' +
|
91
|
+
worksheet_name.to_s + '/charts/' + chart_index.to_s + '?format=' + image_format.to_s
|
92
|
+
|
93
|
+
#Sign URI
|
94
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
95
|
+
|
96
|
+
#Send request and receive response stream
|
97
|
+
response_stream = RestClient.get signed_uri, {:accept=>'application/json'}
|
98
|
+
|
99
|
+
#Validate output
|
100
|
+
v_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
101
|
+
|
102
|
+
if v_output == ''
|
103
|
+
#Save output file
|
104
|
+
output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename)+
|
105
|
+
'_' + worksheet_name + '.' + image_format
|
106
|
+
Aspose::Cloud::Common::Utils.save_file(response_stream, output_path)
|
107
|
+
return output_path
|
108
|
+
else
|
109
|
+
return v_output
|
110
|
+
end
|
111
|
+
rescue Exception=>e
|
112
|
+
print e
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
#saves a specific auto-shape from a specific sheet as image
|
117
|
+
# @param worksheet_name
|
118
|
+
# @param shape_index
|
119
|
+
# @param image_format
|
120
|
+
|
121
|
+
def get_auto_shape worksheet_name, shape_index, image_format
|
122
|
+
begin
|
123
|
+
if @filename==''
|
124
|
+
raise 'Base file name is not specified'
|
125
|
+
end
|
126
|
+
str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' +
|
127
|
+
worksheet_name.to_s + '/autoshapes/' + shape_index.to_s + '?format=' + image_format.to_s
|
128
|
+
|
129
|
+
#Sign URI
|
130
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
131
|
+
|
132
|
+
#Send request and receive response stream
|
133
|
+
response_stream = RestClient.get signed_uri, {:accept=>'application/json'}
|
134
|
+
|
135
|
+
#Validate output
|
136
|
+
v_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
|
137
|
+
|
138
|
+
if v_output == ''
|
139
|
+
#Save output file
|
140
|
+
output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename)+
|
141
|
+
'_' + worksheet_name + '.' + image_format
|
142
|
+
Aspose::Cloud::Common::Utils.save_file(response_stream, output_path)
|
143
|
+
return output_path
|
144
|
+
else
|
145
|
+
return v_output
|
146
|
+
end
|
147
|
+
rescue Exception=>e
|
148
|
+
print e
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Aspose
|
2
|
+
module Cloud
|
3
|
+
module Cells
|
4
|
+
class TextEditor
|
5
|
+
def initialize filename
|
6
|
+
@filename = filename
|
7
|
+
end
|
8
|
+
|
9
|
+
def find_text text
|
10
|
+
begin
|
11
|
+
if @filename == ''
|
12
|
+
raise 'Base File Name is not Specified.'
|
13
|
+
end
|
14
|
+
str_uri = $product_uri + '/cells/' + @filename + '/findText?text=' + text.to_s
|
15
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
16
|
+
response = RestClient.post signed_uri, '' , {:accept => 'application/json'}
|
17
|
+
json = JSON.parse(response)
|
18
|
+
return json['TextItems']['TextItemList']
|
19
|
+
rescue Exception=>e
|
20
|
+
print e
|
21
|
+
end
|
22
|
+
end
|
23
|
+
def find_text_in_worksheet worksheet_name,text
|
24
|
+
begin
|
25
|
+
if @filename == ''
|
26
|
+
raise 'Base File Name is not Specified.'
|
27
|
+
end
|
28
|
+
str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + worksheet_name.to_s + '/findText?text=' + text.to_s
|
29
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
30
|
+
response = RestClient.post signed_uri, '' , {:accept => 'application/json'}
|
31
|
+
json = JSON.parse(response)
|
32
|
+
return json['TextItems']['TextItemList']
|
33
|
+
rescue Exception=>e
|
34
|
+
print e
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_text_items worksheet_name
|
39
|
+
begin
|
40
|
+
if @filename == ''
|
41
|
+
raise 'Base File Name is not Specified.'
|
42
|
+
end
|
43
|
+
str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + worksheet_name.to_s + '/textItems'
|
44
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
45
|
+
response = RestClient.get signed_uri, {:accept => 'application/json'}
|
46
|
+
json = JSON.parse(response)
|
47
|
+
return json['TextItems']['TextItemList']
|
48
|
+
rescue Exception=>e
|
49
|
+
print e
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def replace_text old_text,new_text
|
54
|
+
begin
|
55
|
+
if @filename == ''
|
56
|
+
raise 'Base File Name is not Specified.'
|
57
|
+
end
|
58
|
+
str_uri = $product_uri + '/cells/' + @filename + '/replaceText?oldValue=' + old_text.to_s + '&newValue=' + new_text.to_s
|
59
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
60
|
+
response = RestClient.post signed_uri,'', {:accept => 'application/json'}
|
61
|
+
v_output = Aspose::Cloud::Common::Utils.validate_output(response)
|
62
|
+
if v_output==nil || v_output==''
|
63
|
+
# Save doc on server
|
64
|
+
folder = Aspose::Cloud::AsposeStorage::Folder.new
|
65
|
+
output_stream = folder.get_file(@filename);
|
66
|
+
output_path = $out_put_location + @filename;
|
67
|
+
Aspose::Cloud::Common::Utils.save_file(output_stream, output_path);
|
68
|
+
return 'Value is changed';
|
69
|
+
end
|
70
|
+
rescue Exception=>e
|
71
|
+
print e
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def replace_text_in_worksheet worksheet_name, old_text, new_text
|
76
|
+
begin
|
77
|
+
if(@filename == '')
|
78
|
+
raise 'Base File Name is not Specified.'
|
79
|
+
end
|
80
|
+
str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + worksheet_name.to_s + '/replaceText?oldValue=' + old_text.to_s + '&newValue=' + new_text.to_s
|
81
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
82
|
+
response = RestClient.post signed_uri,'', {:accept => 'application/json'}
|
83
|
+
v_output = Aspose::Cloud::Common::Utils.validate_output(response)
|
84
|
+
if v_output==nil || v_output==''
|
85
|
+
# Save doc on server
|
86
|
+
folder = Aspose::Cloud::AsposeStorage::Folder.new
|
87
|
+
output_stream = folder.get_file(@filename);
|
88
|
+
output_path = $out_put_location + @filename;
|
89
|
+
Aspose::Cloud::Common::Utils.save_file(output_stream, output_path);
|
90
|
+
return 'Value is changed';
|
91
|
+
end
|
92
|
+
rescue Exception=>e
|
93
|
+
print e
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,437 @@
|
|
1
|
+
module Aspose
|
2
|
+
module Cloud
|
3
|
+
module Cells
|
4
|
+
class Workbook
|
5
|
+
def initialize filename
|
6
|
+
@filename = filename
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_properties
|
10
|
+
begin
|
11
|
+
if @filename == ''
|
12
|
+
raise 'Base file name not specified.'
|
13
|
+
end
|
14
|
+
str_uri = $product_uri + '/cells/' + @filename + '/documentProperties'
|
15
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
16
|
+
response = RestClient.get(signed_uri, :accept => 'application/json')
|
17
|
+
json = JSON.parse(response)
|
18
|
+
if json['Code'] == 200
|
19
|
+
return json['DocumentProperties']['DocumentPropertyList']
|
20
|
+
else
|
21
|
+
return false
|
22
|
+
end
|
23
|
+
|
24
|
+
rescue Exception=>e
|
25
|
+
print e
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_property property_name
|
31
|
+
begin
|
32
|
+
if @filename == ''
|
33
|
+
raise 'Base file name not specified.'
|
34
|
+
end
|
35
|
+
if property_name == ''
|
36
|
+
raise 'Property name is not specified.'
|
37
|
+
end
|
38
|
+
str_uri = $product_uri + '/cells/' + @filename + '/documentProperties/' + property_name
|
39
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
40
|
+
response = RestClient.get(signed_uri, :accept => 'application/json')
|
41
|
+
json = JSON.parse(response)
|
42
|
+
if json['Code'] == 200
|
43
|
+
return json['DocumentProperty']
|
44
|
+
else
|
45
|
+
return false
|
46
|
+
end
|
47
|
+
|
48
|
+
rescue Exception=>e
|
49
|
+
print e
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def set_property property_name='',property_value=''
|
55
|
+
begin
|
56
|
+
if @filename == ''
|
57
|
+
raise 'Base file name not specified.'
|
58
|
+
end
|
59
|
+
if property_name == ''
|
60
|
+
raise 'Property name is not specified.'
|
61
|
+
end
|
62
|
+
if property_value == ''
|
63
|
+
raise 'Property Value is not specified.'
|
64
|
+
end
|
65
|
+
str_uri = $product_uri + '/cells/' + @filename + '/documentProperties/' + property_name
|
66
|
+
put_data_arr = Hash.new
|
67
|
+
put_data_arr['Link'] = nil
|
68
|
+
put_data_arr['Name'] = property_name
|
69
|
+
put_data_arr['Value'] = property_value
|
70
|
+
put_data_arr['BuiltIn'] = 'False'
|
71
|
+
json_data = put_data_arr.to_json
|
72
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
73
|
+
response = RestClient.put(signed_uri,json_data, :accept => 'application/json')
|
74
|
+
json = JSON.parse(response)
|
75
|
+
if json['Code'] == 200
|
76
|
+
return json['DocumentProperty']
|
77
|
+
else
|
78
|
+
return false
|
79
|
+
end
|
80
|
+
|
81
|
+
rescue Exception=>e
|
82
|
+
print e
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
def remove_all_properties
|
87
|
+
begin
|
88
|
+
if @filename == ''
|
89
|
+
raise 'Base file name not specified.'
|
90
|
+
end
|
91
|
+
str_uri = $product_uri + '/cells/' + @filename + '/documentProperties'
|
92
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
93
|
+
response = RestClient.delete(signed_uri, :accept=>'application/json')
|
94
|
+
json = JSON.parse(response)
|
95
|
+
if json['Code'] == 200
|
96
|
+
return true
|
97
|
+
else
|
98
|
+
return false
|
99
|
+
end
|
100
|
+
|
101
|
+
rescue Exception=>e
|
102
|
+
print e
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
def remove_property property_name
|
108
|
+
begin
|
109
|
+
if @filename == ''
|
110
|
+
raise 'Base file name not specified.'
|
111
|
+
end
|
112
|
+
if property_name == ''
|
113
|
+
raise 'Property name is not specified.'
|
114
|
+
end
|
115
|
+
str_uri = $product_uri + '/cells/' + @filename + '/documentProperties/' + property_name
|
116
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
117
|
+
response = RestClient.delete(signed_uri, :accept => 'application/json')
|
118
|
+
json = JSON.parse(response)
|
119
|
+
if json['Code'] == 200
|
120
|
+
return true
|
121
|
+
else
|
122
|
+
return false
|
123
|
+
end
|
124
|
+
|
125
|
+
rescue Exception=>e
|
126
|
+
print e
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
def create_empty_workbook
|
132
|
+
begin
|
133
|
+
str_uri = $product_uri + '/cells/' + @filename
|
134
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
135
|
+
response = RestClient.put(signed_uri,'', :accept => 'application/json')
|
136
|
+
json = JSON.parse(response)
|
137
|
+
return json
|
138
|
+
rescue Exception=>e
|
139
|
+
print e
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
def create_workbook_from_template template_file_name
|
145
|
+
begin
|
146
|
+
if template_file_name == ''
|
147
|
+
raise 'Template file not specified'
|
148
|
+
end
|
149
|
+
str_uri = $product_uri + '/cells/' + @filename + '?templatefile=' + template_file_name
|
150
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
151
|
+
response = RestClient.put(signed_uri,'', :accept => 'application/json')
|
152
|
+
json = JSON.parse(response)
|
153
|
+
return json
|
154
|
+
rescue Exception=>e
|
155
|
+
print e
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
def create_workbook_from_smart_marker_template template_file_name ='',data_file=''
|
161
|
+
begin
|
162
|
+
if template_file_name == ''
|
163
|
+
raise 'Template file not specified'
|
164
|
+
end
|
165
|
+
if data_file == ''
|
166
|
+
raise 'Data file not specified'
|
167
|
+
end
|
168
|
+
str_uri = $product_uri + '/cells/' + @filename + '?templatefile=' + template_file_name + '&dataFile=' + data_file
|
169
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
170
|
+
response = RestClient.put(signed_uri,'', :accept => 'application/json')
|
171
|
+
json = JSON.parse(response)
|
172
|
+
return json
|
173
|
+
rescue Exception=>e
|
174
|
+
print e
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
|
179
|
+
def process_smart_marker data_file=''
|
180
|
+
begin
|
181
|
+
if data_file == ''
|
182
|
+
raise 'Data file not specified'
|
183
|
+
end
|
184
|
+
str_uri = $product_uri + '/cells/' + @filename + '/smartmarker?xmlFile=' + data_file
|
185
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
186
|
+
response = RestClient.post(signed_uri,'', :accept => 'application/json')
|
187
|
+
json = JSON.parse(response)
|
188
|
+
return json
|
189
|
+
rescue Exception=>e
|
190
|
+
print e
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
|
195
|
+
def get_worksheets_count
|
196
|
+
begin
|
197
|
+
if @filename == ''
|
198
|
+
raise 'Base file name not specified'
|
199
|
+
end
|
200
|
+
str_uri = $product_uri + '/cells/' + @filename + '/worksheets'
|
201
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
202
|
+
response = RestClient.get(signed_uri, :accept => 'application/json')
|
203
|
+
json = JSON.parse(response)
|
204
|
+
return json['Worksheets']['WorksheetList'].size
|
205
|
+
rescue Exception=>e
|
206
|
+
print e
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def get_name_count
|
211
|
+
begin
|
212
|
+
if @filename == ''
|
213
|
+
raise 'Base file name not specified'
|
214
|
+
end
|
215
|
+
str_uri = $product_uri + '/cells/' + @filename + '/names'
|
216
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
217
|
+
response = RestClient.get(signed_uri, :accept => 'application/json')
|
218
|
+
json = JSON.parse(response)
|
219
|
+
return json['Names'].count
|
220
|
+
rescue Exception=>e
|
221
|
+
print e
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def get_default_style
|
226
|
+
begin
|
227
|
+
if @filename == ''
|
228
|
+
raise 'Base file name not specified'
|
229
|
+
end
|
230
|
+
str_uri = $product_uri + '/cells/' + @filename + '/defaultStyle'
|
231
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
232
|
+
response = RestClient.get(signed_uri, :accept => 'application/json')
|
233
|
+
json = JSON.parse(response)
|
234
|
+
return json['Style']
|
235
|
+
rescue Exception=>e
|
236
|
+
print e
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
def encrypt_workbook encryption_type='XOR',password='',key_length=''
|
241
|
+
begin
|
242
|
+
if @filename == ''
|
243
|
+
raise 'Base file name not specified'
|
244
|
+
end
|
245
|
+
fields_array = Hash.new
|
246
|
+
fields_array['EncriptionType'] = encryption_type
|
247
|
+
fields_array['KeyLength'] = key_length
|
248
|
+
fields_array['Password'] = password
|
249
|
+
json_data = fields_array.to_json
|
250
|
+
str_uri = $product_uri + '/cells/' + @filename + '/encryption'
|
251
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
252
|
+
response = RestClient.post(signed_uri, json_data,:accept => 'application/json')
|
253
|
+
json = JSON.parse(response)
|
254
|
+
if json['Code']==200
|
255
|
+
return true
|
256
|
+
else
|
257
|
+
return false
|
258
|
+
end
|
259
|
+
rescue Exception=>e
|
260
|
+
print e
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
def protect_workbook protection_type = 'all',password=''
|
265
|
+
begin
|
266
|
+
if @filename == ''
|
267
|
+
raise 'Base file name not specified'
|
268
|
+
end
|
269
|
+
fields_array = Hash.new
|
270
|
+
fields_array['ProtectionType'] = protection_type
|
271
|
+
fields_array['Password'] = password
|
272
|
+
json_data = fields_array.to_json
|
273
|
+
str_uri = $product_uri + '/cells/' + @filename + '/protection'
|
274
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
275
|
+
response = RestClient.post(signed_uri, json_data,:accept => 'application/json')
|
276
|
+
json = JSON.parse(response)
|
277
|
+
if json['Code']==200
|
278
|
+
return true
|
279
|
+
else
|
280
|
+
return false
|
281
|
+
end
|
282
|
+
rescue Exception=>e
|
283
|
+
print e
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
def unprotect_workbook password
|
288
|
+
begin
|
289
|
+
if @filename == ''
|
290
|
+
raise 'Base file name not specified'
|
291
|
+
end
|
292
|
+
fields_array = Hash.new
|
293
|
+
fields_array['Password'] = password
|
294
|
+
json_data = fields_array.to_json
|
295
|
+
str_uri = $product_uri + '/cells/' + @filename + '/protection'
|
296
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
297
|
+
response = RestClient.delete(signed_uri,json_data,:accept=>'application/json')
|
298
|
+
json = JSON.parse(response)
|
299
|
+
if json['Code']==200
|
300
|
+
return true
|
301
|
+
else
|
302
|
+
return false
|
303
|
+
end
|
304
|
+
rescue Exception=>e
|
305
|
+
print e
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
def set_modify_password password=''
|
310
|
+
begin
|
311
|
+
if @filename == ''
|
312
|
+
raise 'Base file name not specified'
|
313
|
+
end
|
314
|
+
fields_array = Hash.new
|
315
|
+
fields_array['Password'] = password
|
316
|
+
json_data = fields_array.to_json
|
317
|
+
str_uri = $product_uri + '/cells/' + @filename + '/writeProtection'
|
318
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
319
|
+
response = RestClient.put(signed_uri, json_data,:accept => 'application/json')
|
320
|
+
json = JSON.parse(response)
|
321
|
+
if json['Code']==200
|
322
|
+
return true
|
323
|
+
else
|
324
|
+
return false
|
325
|
+
end
|
326
|
+
rescue Exception=>e
|
327
|
+
print e
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
def clear_modify_password password=''
|
332
|
+
begin
|
333
|
+
if @filename == ''
|
334
|
+
raise 'Base file name not specified'
|
335
|
+
end
|
336
|
+
fields_array = Hash.new
|
337
|
+
fields_array['Password'] = password
|
338
|
+
json_data = fields_array.to_json
|
339
|
+
str_uri = $product_uri + '/cells/' + @filename + '/writeProtection'
|
340
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
341
|
+
response = RestClient.delete(signed_uri,json_data, json_data,:accept => 'application/json')
|
342
|
+
json = JSON.parse(response)
|
343
|
+
if json['Code']==200
|
344
|
+
return true
|
345
|
+
else
|
346
|
+
return false
|
347
|
+
end
|
348
|
+
rescue Exception=>e
|
349
|
+
print e
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
|
354
|
+
def decrypt_password password
|
355
|
+
begin
|
356
|
+
if @filename == ''
|
357
|
+
raise 'Base file name not specified'
|
358
|
+
end
|
359
|
+
fields_array = Hash.new
|
360
|
+
fields_array['Password'] = password
|
361
|
+
json_data = fields_array.to_json
|
362
|
+
str_uri = $product_uri + '/cells/' + @filename + '/encryption'
|
363
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
364
|
+
response = RestClient.delete(signed_uri,json_data,:accept => 'application/json')
|
365
|
+
json = JSON.parse(response)
|
366
|
+
if json['Code']==200
|
367
|
+
return true
|
368
|
+
else
|
369
|
+
return false
|
370
|
+
end
|
371
|
+
rescue Exception=>e
|
372
|
+
print e
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
def add_worksheet worksheet_name=''
|
377
|
+
begin
|
378
|
+
if @filename == ''
|
379
|
+
raise 'Base file name not specified'
|
380
|
+
end
|
381
|
+
str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + worksheet_name
|
382
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
383
|
+
response = RestClient.put(signed_uri, '',:accept => 'application/json')
|
384
|
+
json = JSON.parse(response)
|
385
|
+
if json['Code']==201
|
386
|
+
return true
|
387
|
+
else
|
388
|
+
return false
|
389
|
+
end
|
390
|
+
rescue Exception=>e
|
391
|
+
print e
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
def remove_worksheet worksheet_name=''
|
396
|
+
begin
|
397
|
+
if @filename == ''
|
398
|
+
raise 'Base file name not specified'
|
399
|
+
end
|
400
|
+
str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + worksheet_name
|
401
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
402
|
+
response = RestClient.delete(signed_uri,:accept => 'application/json')
|
403
|
+
json = JSON.parse(response)
|
404
|
+
if json['Code']==200
|
405
|
+
return true
|
406
|
+
else
|
407
|
+
return false
|
408
|
+
end
|
409
|
+
rescue Exception=>e
|
410
|
+
print e
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
def merge_workbook merge_file_name =''
|
415
|
+
begin
|
416
|
+
if @filename == ''
|
417
|
+
raise 'Base file name not specified'
|
418
|
+
end
|
419
|
+
str_uri = $product_uri + '/cells/' + @filename + '/merge?mergeWith=' + merge_file_name
|
420
|
+
signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
|
421
|
+
response = RestClient.post(signed_uri,'',:accept => 'application/json')
|
422
|
+
json = JSON.parse(response)
|
423
|
+
if json['Code']==200
|
424
|
+
return true
|
425
|
+
else
|
426
|
+
return false
|
427
|
+
end
|
428
|
+
rescue Exception=>e
|
429
|
+
print e
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
end
|
434
|
+
end
|
435
|
+
|
436
|
+
end
|
437
|
+
end
|