aspose_cells_cloud 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,45 @@
1
+ module AsposeCellsCloud
2
+ #
3
+ class SaveResultTaskDescription < BaseObject
4
+ attr_accessor :task_type, :save_result_task_parameter
5
+ # attribute mapping from ruby-style variable name to JSON key
6
+ def self.attribute_map
7
+ {
8
+
9
+ #
10
+ :'task_type' => :'TaskType',
11
+
12
+ #
13
+ :'save_result_task_parameter' => :'SaveResultTaskParameter'
14
+
15
+ }
16
+ end
17
+
18
+ # attribute type
19
+ def self.swagger_types
20
+ {
21
+ :'task_type' => :'String',
22
+ :'save_result_task_parameter' => :'SaveResultTaskParameter'
23
+
24
+ }
25
+ end
26
+
27
+ def initialize(attributes = {})
28
+ return if !attributes.is_a?(Hash) || attributes.empty?
29
+
30
+ # convert string to symbol for hash key
31
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
32
+
33
+
34
+ if attributes[:'TaskType']
35
+ self.task_type = attributes[:'TaskType']
36
+ end
37
+
38
+ if attributes[:'SaveResultTaskParameter']
39
+ self.save_result_task_parameter = attributes[:'SaveResultTaskParameter']
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,45 @@
1
+ module AsposeCellsCloud
2
+ #
3
+ class SaveResultTaskParameter < BaseObject
4
+ attr_accessor :result_source, :result_destination
5
+ # attribute mapping from ruby-style variable name to JSON key
6
+ def self.attribute_map
7
+ {
8
+
9
+ #
10
+ :'result_source' => :'ResultSource',
11
+
12
+ #
13
+ :'result_destination' => :'ResultDestination'
14
+
15
+ }
16
+ end
17
+
18
+ # attribute type
19
+ def self.swagger_types
20
+ {
21
+ :'result_source' => :'String',
22
+ :'result_destination' => :'ResultDestination'
23
+
24
+ }
25
+ end
26
+
27
+ def initialize(attributes = {})
28
+ return if !attributes.is_a?(Hash) || attributes.empty?
29
+
30
+ # convert string to symbol for hash key
31
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
32
+
33
+
34
+ if attributes[:'ResultSource']
35
+ self.result_source = attributes[:'ResultSource']
36
+ end
37
+
38
+ if attributes[:'ResultDestination']
39
+ self.result_destination = attributes[:'ResultDestination']
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
@@ -1,7 +1,7 @@
1
1
  module AsposeCellsCloud
2
2
  #
3
3
  class Style < BaseObject
4
- attr_accessor :font, :name, :culture_custom, :custom, :background_color, :foreground_color, :is_formula_hidden, :is_date_time, :is_text_wrapped, :is_gradient, :is_locked, :is_percent, :shrink_to_fit, :indent_level, :number, :rotation_angle, :pattern, :text_direction, :vertical_alignment, :horizontal_alignment, :border_collection, :link
4
+ attr_accessor :font, :name, :culture_custom, :custom, :background_color, :foreground_color, :is_formula_hidden, :is_date_time, :is_text_wrapped, :is_gradient, :is_locked, :is_percent, :shrink_to_fit, :indent_level, :number, :rotation_angle, :pattern, :text_direction, :vertical_alignment, :horizontal_alignment, :border_collection, :background_theme_color, :foreground_theme_color, :link
5
5
  # attribute mapping from ruby-style variable name to JSON key
6
6
  def self.attribute_map
7
7
  {
@@ -69,6 +69,12 @@ module AsposeCellsCloud
69
69
  #
70
70
  :'border_collection' => :'BorderCollection',
71
71
 
72
+ #
73
+ :'background_theme_color' => :'BackgroundThemeColor',
74
+
75
+ #
76
+ :'foreground_theme_color' => :'ForegroundThemeColor',
77
+
72
78
  #
73
79
  :'link' => :'link'
74
80
 
@@ -99,6 +105,8 @@ module AsposeCellsCloud
99
105
  :'vertical_alignment' => :'String',
100
106
  :'horizontal_alignment' => :'String',
101
107
  :'border_collection' => :'Array<Border>',
108
+ :'background_theme_color' => :'ThemeColor',
109
+ :'foreground_theme_color' => :'ThemeColor',
102
110
  :'link' => :'Link'
103
111
 
104
112
  }
@@ -197,6 +205,14 @@ module AsposeCellsCloud
197
205
  end
198
206
  end
199
207
 
208
+ if attributes[:'BackgroundThemeColor']
209
+ self.background_theme_color = attributes[:'BackgroundThemeColor']
210
+ end
211
+
212
+ if attributes[:'ForegroundThemeColor']
213
+ self.foreground_theme_color = attributes[:'ForegroundThemeColor']
214
+ end
215
+
200
216
  if attributes[:'link']
201
217
  self.link = attributes[:'link']
202
218
  end
@@ -0,0 +1,53 @@
1
+ module AsposeCellsCloud
2
+ #
3
+ class TaskDescription < BaseObject
4
+ attr_accessor :task_type, :import_data_task_parameter, :save_result_task_parameter
5
+ # attribute mapping from ruby-style variable name to JSON key
6
+ def self.attribute_map
7
+ {
8
+
9
+ #
10
+ :'task_type' => :'TaskType',
11
+
12
+ #
13
+ :'import_data_task_parameter' => :'ImportDataTaskParameter',
14
+
15
+ #
16
+ :'save_result_task_parameter' => :'SaveResultTaskParameter'
17
+
18
+ }
19
+ end
20
+
21
+ # attribute type
22
+ def self.swagger_types
23
+ {
24
+ :'task_type' => :'String',
25
+ :'import_data_task_parameter' => :'ImportDataTaskParameter',
26
+ :'save_result_task_parameter' => :'SaveResultTaskParameter'
27
+
28
+ }
29
+ end
30
+
31
+ def initialize(attributes = {})
32
+ return if !attributes.is_a?(Hash) || attributes.empty?
33
+
34
+ # convert string to symbol for hash key
35
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
36
+
37
+
38
+ if attributes[:'TaskType']
39
+ self.task_type = attributes[:'TaskType']
40
+ end
41
+
42
+ if attributes[:'ImportDataTaskParameter']
43
+ self.import_data_task_parameter = attributes[:'ImportDataTaskParameter']
44
+ end
45
+
46
+ if attributes[:'SaveResultTaskParameter']
47
+ self.save_result_task_parameter = attributes[:'SaveResultTaskParameter']
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,39 @@
1
+ module AsposeCellsCloud
2
+ #
3
+ class TasksData < BaseObject
4
+ attr_accessor :tasks
5
+ # attribute mapping from ruby-style variable name to JSON key
6
+ def self.attribute_map
7
+ {
8
+
9
+ #
10
+ :'tasks' => :'Tasks'
11
+
12
+ }
13
+ end
14
+
15
+ # attribute type
16
+ def self.swagger_types
17
+ {
18
+ :'tasks' => :'Array<TaskDescription>'
19
+
20
+ }
21
+ end
22
+
23
+ def initialize(attributes = {})
24
+ return if !attributes.is_a?(Hash) || attributes.empty?
25
+
26
+ # convert string to symbol for hash key
27
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
28
+
29
+
30
+ if attributes[:'Tasks']
31
+ if (value = attributes[:'Tasks']).is_a?(Array)
32
+ self.tasks = value
33
+ end
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module AsposeCellsCloud
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.5"
3
3
  end
data/test/cells_tests.rb CHANGED
@@ -10,7 +10,7 @@ class CellsTests < Minitest::Test
10
10
 
11
11
  def setup
12
12
  #Get App key and App SID from https://cloud.aspose.com
13
- AsposeApp.app_key_and_sid("", "")
13
+ AsposeApp.app_key_and_sid("App Key", "App SID")
14
14
  @cells_api = CellsApi.new
15
15
  end
16
16
 
@@ -24,13 +24,29 @@ class CellsTests < Minitest::Test
24
24
  end
25
25
 
26
26
  def test_put_convert_work_book
27
- file_name = "myWorkbook.xlsx"
27
+ file_name = "Book1.xlsx"
28
28
  convert_to_format = "pdf"
29
29
  response = @cells_api.put_convert_work_book(File.open("../../../data/" << file_name,"r") { |io| io.read }, {format: convert_to_format})
30
30
  puts response
31
- assert(response, message="Failed to convert workbook from request content to {convert_to_format} format.")
31
+ assert(response, message="convert a workbook to a different file format without uploading to any storage.")
32
32
  end
33
33
 
34
+ def test_put_convert_work_book_with_additional_settings
35
+ file_name = "Book1.xlsx"
36
+ convert_to_format = "pdf"
37
+
38
+ pdf_save_options = PdfSaveOptions.new
39
+ pdf_save_options.calculate_formula = true
40
+ pdf_save_options.check_font_compatibility = false
41
+ pdf_save_options.compliance = "None"
42
+ pdf_save_options.one_page_per_sheet = false
43
+ pdf_save_options.save_format = "PDF"
44
+
45
+ response = @cells_api.put_convert_work_book(File.open("../../../data/" << file_name,"r") { |io| io.read }, {format: convert_to_format, save_options: pdf_save_options})
46
+ puts response
47
+ assert(response, message="convert a workbook to a different file format without uploading to any storage.")
48
+ end
49
+
34
50
  def test_get_work_book_with_format
35
51
  file_name = "myWorkbook.xlsx"
36
52
  upload_file(file_name)
@@ -41,7 +57,7 @@ class CellsTests < Minitest::Test
41
57
 
42
58
  def test_get_work_book
43
59
  file_name = "myWorkbook.xlsx"
44
- upload_file(file_name)
60
+ #upload_file(file_name)
45
61
 
46
62
  response = @cells_api.get_work_book(file_name)
47
63
  assert(response, message="Failed to read workbook info.")
@@ -56,12 +72,17 @@ class CellsTests < Minitest::Test
56
72
  end
57
73
 
58
74
  def test_post_document_save_as
59
- file_name = "myWorkbook.xlsx"
75
+ file_name = "SAASCELLS-157-6.xltx"
60
76
  upload_file(file_name)
61
77
 
62
- save_options = SavingSaveOptions.new
63
- save_options.clear_data = true
64
- response = @cells_api.post_document_save_as(file_name, save_options, {newfilename: "updatedWorkbook.xlsx", isAutoFitRows: true, isAutoFitColumns: true})
78
+ pdf_save_options = PdfSaveOptions.new
79
+ pdf_save_options.calculate_formula = true
80
+ pdf_save_options.check_font_compatibility = false
81
+ pdf_save_options.compliance = "None"
82
+ pdf_save_options.one_page_per_sheet = false
83
+ pdf_save_options.save_format = "PDF"
84
+
85
+ response = @cells_api.post_document_save_as(file_name, pdf_save_options, {newfilename: "SAASCELLS-157-6.pdf"})
65
86
  puts response
66
87
  assert(response, message="Failed to convert document and save result to storage.")
67
88
  end
@@ -171,14 +192,170 @@ class CellsTests < Minitest::Test
171
192
  end
172
193
 
173
194
  def test_post_import_data
174
- file_name = "Sample_Test_Book.xls"
175
- upload_file(file_name)
195
+
196
+ import_batch_data_option = ImportBatchDataOption.new
197
+ import_batch_data_option.destination_worksheet = "Sheet1"
198
+ import_batch_data_option.is_insert = false
199
+ import_batch_data_option.import_data_type = "BatchData"
200
+ import_source = ImportSource.new
201
+ import_source.file_source_type = "CloudFileSystem"
202
+ import_source.file_path = "Batch_data_json.txt"
203
+ import_batch_data_option.source = import_source
204
+
205
+ import_string_array_option = ImportStringArrayOption.new
206
+ import_string_array_option.first_row = 1
207
+ import_string_array_option.first_column = 2
208
+ import_string_array_option.is_vertical = true
209
+ import_string_array_option.destination_worksheet = "Sheet1"
210
+ import_string_array_option.is_insert = true
211
+ import_string_array_option.import_data_type = "StringArray"
212
+ import_source = ImportSource.new
213
+ import_source.file_source_type = "CloudFileSystem"
214
+ import_source.file_path = "Array_string_json.txt"
215
+ import_string_array_option.source = import_source
216
+
217
+ import_int_array_option = ImportIntArrayOption.new
218
+ import_int_array_option.first_row = 1
219
+ import_int_array_option.first_column = 2
220
+ import_int_array_option.is_vertical = true
221
+ import_int_array_option.destination_worksheet = "Sheet1"
222
+ import_int_array_option.is_insert = true
223
+ import_int_array_option.import_data_type = "IntArray"
224
+ import_source = ImportSource.new
225
+ import_source.file_source_type = "CloudFileSystem"
226
+ import_source.file_path = "Array_int_json.txt"
227
+ import_int_array_option.source = import_source
228
+
229
+ import_double_array_option = ImportDoubleArrayOption.new
230
+ import_double_array_option.first_row = 1
231
+ import_double_array_option.first_column = 2
232
+ import_double_array_option.is_vertical = true
233
+ import_double_array_option.destination_worksheet = "Sheet1"
234
+ import_double_array_option.is_insert = true
235
+ import_double_array_option.import_data_type = "DoubleArray"
236
+ import_source = ImportSource.new
237
+ import_source.file_source_type = "CloudFileSystem"
238
+ import_source.file_path = "Array_double_json.txt"
239
+ import_double_array_option.source = import_source
240
+
241
+ import_data_options = [import_batch_data_option, import_string_array_option, import_int_array_option, import_double_array_option]
242
+ data_files = ["Batch_data_json.txt", "Array_string_json.txt", "Array_int_json.txt", "Array_double_json.txt"]
243
+
244
+ import_data_options.each_with_index { |option, index|
245
+
246
+ file_name = "Book1.xlsx"
247
+ upload_file(file_name)
248
+
249
+ data_file = data_files.at(index)
250
+ upload_file(data_file)
251
+
252
+ response = @cells_api.post_import_data(file_name, option)
253
+ assert(response, message="Failed to import data into the worksheet.")
254
+ }
255
+ end
256
+
257
+ def test_post_import_data_without_using_storage
258
+ file_name = "Book1.xlsx"
259
+ upload_file(file_name)
260
+
261
+ import_batch_data_option = ImportBatchDataOption.new
262
+ import_batch_data_option.destination_worksheet = "Sheet1"
263
+ import_batch_data_option.is_insert = false
264
+ import_batch_data_option.import_data_type = "BatchData"
265
+ import_source = ImportSource.new
266
+ import_source.file_source_type = "RequestFiles"
267
+ import_source.file_path = "Batch_data_json.txt"
268
+ import_batch_data_option.source = import_source
176
269
 
177
- import_option = ImportDataImportOption.new
178
- import_option.destination_worksheet = "Sheet3"
179
- import_option.is_insert = true
180
- response = @cells_api.post_import_data(file_name, import_option)
181
- assert(response, message="Failed to import data to workbook")
270
+ file = File.open("../../../data/Batch_data_json.txt","r") { |io| io.read }
271
+
272
+ response = @cells_api.post_import_data(file_name, import_batch_data_option, {file: file})
273
+ puts response
274
+ assert(response, message="Failed to import data into the worksheet.")
275
+ end
276
+
277
+ def test_post_run_task
278
+ file_name = "TaskBook.xlsx"
279
+ upload_file(file_name)
280
+
281
+ tasks_data = TasksData.new
282
+
283
+ # First Task
284
+ task_description_1 = TaskDescription.new
285
+ task_description_1.task_type = "ImportData"
286
+
287
+ import_data_task_parameter = ImportDataTaskParameter.new
288
+
289
+ workbook = ImportSource.new
290
+ workbook.file_source_type = "CloudFileSystem"
291
+ workbook.file_path = "TaskBook.xlsx"
292
+
293
+ import_data_task_parameter.workbook = workbook
294
+
295
+ import_batch_data_option = ImportBatchDataOption.new
296
+ import_batch_data_option.destination_worksheet = "Sheet1"
297
+ import_batch_data_option.is_insert = true
298
+
299
+ source = ImportSource.new
300
+ source.file_source_type = "RequestFiles"
301
+ source.file_path = "Batch_data_xml.txt"
302
+
303
+ import_batch_data_option.source = source
304
+
305
+ import_data_task_parameter.import_batch_data_option = import_batch_data_option
306
+
307
+ task_description_1.import_data_task_parameter = import_data_task_parameter
308
+
309
+ # Second Task
310
+ task_description_2 = TaskDescription.new
311
+ task_description_2.task_type = "ImportData"
312
+
313
+ import_data_task_parameter = ImportDataTaskParameter.new
314
+
315
+ workbook = ImportSource.new
316
+ workbook.file_source_type = "InMemoryFiles"
317
+ workbook.file_path = "TaskBook.xlsx"
318
+
319
+ import_data_task_parameter.workbook = workbook
320
+
321
+ import_batch_data_option = ImportBatchDataOption.new
322
+ import_batch_data_option.destination_worksheet = "Sheet2"
323
+ import_batch_data_option.is_insert = true
324
+
325
+ source = ImportSource.new
326
+ source.file_source_type = "RequestFiles"
327
+ source.file_path = "Batch_data_xml_2.txt"
328
+
329
+ import_batch_data_option.source = source
330
+
331
+ import_data_task_parameter.import_batch_data_option = import_batch_data_option
332
+
333
+ task_description_2.import_data_task_parameter = import_data_task_parameter
334
+
335
+ # Third task
336
+ task_description_3 = TaskDescription.new
337
+ task_description_3.task_type = "ImportData"
338
+
339
+ save_result_task_parameter = SaveResultTaskParameter.new
340
+ save_result_task_parameter.result_source = "InMemoryFiles"
341
+
342
+ result_destination = ResultDestination.new
343
+ result_destination.destination_type = "CloudFileSystem"
344
+ result_destination.input_file = "TaskBook.xlsx"
345
+ result_destination.output_file = "ImpDataBook.xlsx"
346
+
347
+ save_result_task_parameter.result_destination = result_destination
348
+
349
+ task_description_3.save_result_task_parameter = save_result_task_parameter
350
+
351
+ tasks_data.tasks = [task_description_1, task_description_2, task_description_3]
352
+
353
+ file1 = File.open("../../../data/Batch_data_xml.txt","r") { |io| io.read }
354
+ file2 = File.open("../../../data/Batch_data_xml_2.txt","r") { |io| io.read }
355
+ files = [file1, file2]
356
+
357
+ response = @cells_api.post_run_task(tasks_data, files)
358
+ assert(response, message="Failed to import data into the worksheet")
182
359
  end
183
360
 
184
361
  def test_post_workbooks_merge
@@ -814,33 +991,6 @@ class CellsTests < Minitest::Test
814
991
  assert(response, message="Failed to read cell's style info")
815
992
  end
816
993
 
817
- def test_post_update_worksheet_cell_style
818
- file_name = "myWorkbook.xlsx"
819
- upload_file(file_name)
820
-
821
- sheet_name = "Sheet1"
822
- cell_name = "A3"
823
- cell_style = Style.new
824
- font = Font.new
825
- font.double_size = 20
826
- font.is_bold = true
827
- font.is_italic = true
828
- font.is_strikeout = true
829
- font.size = 15
830
-
831
- cell_style.font = font
832
- cell_style.shrink_to_fit = true
833
-
834
- background_color = Color.new
835
- background_color.r = "255"
836
- background_color.g = "255"
837
- background_color.b = "255"
838
- cell_style.background_color = background_color
839
-
840
- response = @cells_api.post_update_worksheet_cell_style(file_name, sheet_name, cell_name, cell_style)
841
- assert(response, message="Failed to update cell's style")
842
- end
843
-
844
994
  def test_get_worksheet_cell
845
995
  file_name = "myWorkbook.xlsx"
846
996
  upload_file(file_name)
@@ -1101,16 +1251,6 @@ class CellsTests < Minitest::Test
1101
1251
  assert(response, message="Failed to delete worksheet's cell comment")
1102
1252
  end
1103
1253
 
1104
- def test_post_copy_worksheet
1105
- file_name = "myWorkbook.xlsx"
1106
- upload_file(file_name)
1107
-
1108
- sheet_name = "Sheet3"
1109
- source_sheet = "Sheet1"
1110
- response = @cells_api.post_copy_worksheet(file_name, sheet_name, source_sheet)
1111
- assert(response, message="Failed to copy worksheet")
1112
- end
1113
-
1114
1254
  def test_post_work_sheet_text_search
1115
1255
  file_name = "myWorkbook.xlsx"
1116
1256
  upload_file(file_name)
@@ -1734,4 +1874,48 @@ class CellsTests < Minitest::Test
1734
1874
  response = @cells_api.delete_worksheet_picture(file_name, sheet_name, picture_index)
1735
1875
  assert(response, message="Failed to delete a picture from excel worksheet")
1736
1876
  end
1877
+
1878
+ def test_post_update_worksheet_cell_style
1879
+ file_name = "test_cells.xlsx"
1880
+ upload_file(file_name)
1881
+
1882
+ sheet_name = "Sheet3"
1883
+ cell_name = "A1"
1884
+
1885
+ cell_style = Style.new
1886
+ background_theme_color = ThemeColor.new
1887
+ background_theme_color.color_type = "Text2"
1888
+ background_theme_color.tint = 1
1889
+ cell_style.background_theme_color = background_theme_color
1890
+
1891
+ response = @cells_api.post_update_worksheet_cell_style(file_name, sheet_name, cell_name, cell_style)
1892
+ assert(response, message="Failed to update cell's style of a worksheet")
1893
+ end
1894
+
1895
+ def test_post_copy_worksheet
1896
+ file_name = "Book1.xlsx"
1897
+ upload_file(file_name)
1898
+
1899
+ sheet_name = "NewSheet"
1900
+ source_sheet = "Sheet3"
1901
+
1902
+ copy_options = CopyOptions.new
1903
+ copy_options.copy_names = true
1904
+
1905
+ response = @cells_api.post_copy_worksheet(file_name, sheet_name, source_sheet, copy_options)
1906
+ assert(response, message="Failed to copy a worksheet")
1907
+ end
1908
+
1909
+ def test_delete_work_sheet_comments
1910
+ file_name = "test_cells.xlsx"
1911
+ upload_file(file_name)
1912
+
1913
+ sheet_name = "Sheet1"
1914
+
1915
+ response = @cells_api.delete_work_sheet_comments(file_name, sheet_name)
1916
+ assert(response, message="Failed to delete all comments in a worksheet")
1917
+ end
1918
+
1919
+
1920
+
1737
1921
  end