Class: Aspose::Cloud::Cells::Converter
- Inherits:
-
Object
- Object
- Aspose::Cloud::Cells::Converter
- Defined in:
- lib/Cells/convertor.rb
Instance Method Summary collapse
- #autoshape_to_image(shape_index, worksheet_name, save_format, password = '', folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
- #chart_to_image(chart_index, worksheet_name, save_format, password = '', folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
- #convert(output_filename, save_format, password = '', folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
- #convert_local_file(input_file, output_filename, save_format, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
- #convert_to_image(output_filename, worksheet_name, save_format, password = '', folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
-
#initialize(filename) ⇒ Converter
constructor
A new instance of Converter.
- #oleobject_to_image(object_index, worksheet_name, save_format, password = '', folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
- #picture_to_image(picture_index, worksheet_name, save_format, password = '', folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
Constructor Details
#initialize(filename) ⇒ Converter
Returns a new instance of Converter.
22 23 24 25 26 |
# File 'lib/Cells/convertor.rb', line 22 def initialize(filename) @filename = filename raise 'filename not specified.' if filename.empty? @base_uri = "#{Aspose::Cloud::Common::Product.product_uri}/cells/#{@filename}" end |
Instance Method Details
#autoshape_to_image(shape_index, worksheet_name, save_format, password = '', folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/Cells/convertor.rb', line 122 def autoshape_to_image(shape_index, worksheet_name, save_format, password='', folder_name = '', storage_type = 'Aspose', storage_name = '') raise 'shape_index not specified.' if shape_index.nil? raise 'worksheet_name not specified.' if worksheet_name.empty? raise 'save_format not specified.' if save_format.empty? str_uri = "#{@base_uri}/worksheets/#{worksheet_name}/autoshapes/#{shape_index}" qry = Hash.new qry[:format] = save_format qry[:password] = password unless password.empty? str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry) str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type) signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(signed_str_uri, {:accept => 'application/json'}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}.#{save_format}" valid_output.empty? ? Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) : valid_output end |
#chart_to_image(chart_index, worksheet_name, save_format, password = '', folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/Cells/convertor.rb', line 103 def chart_to_image(chart_index, worksheet_name, save_format, password='', folder_name = '', storage_type = 'Aspose', storage_name = '') raise 'chart_index not specified.' if chart_index.nil? raise 'worksheet_name not specified.' if worksheet_name.empty? raise 'save_format not specified.' if save_format.empty? str_uri = "#{@base_uri}/worksheets/#{worksheet_name}/charts/#{chart_index}" qry = Hash.new qry[:format] = save_format qry[:password] = password unless password.empty? str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry) str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type) signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(signed_str_uri, {:accept => 'application/json'}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}.#{save_format}" valid_output.empty? ? Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) : valid_output end |
#convert(output_filename, save_format, password = '', folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/Cells/convertor.rb', line 28 def convert(output_filename, save_format, password='', folder_name = '', storage_type = 'Aspose', storage_name = '') raise 'output_filename not specified.' if output_filename.empty? raise 'save_format not specified.' if save_format.empty? str_uri = "#{@base_uri}" qry = Hash.new qry[:format] = save_format qry[:password] = password unless password.empty? str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry) str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type) signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(signed_str_uri, {:accept => 'application/json'}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(output_filename)}.#{save_format}" valid_output.empty? ? Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) : valid_output end |
#convert_local_file(input_file, output_filename, save_format, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/Cells/convertor.rb', line 141 def convert_local_file(input_file, output_filename, save_format, folder_name = '', storage_type = 'Aspose', storage_name = '') raise 'input_file not specified.' if input_file.empty? raise 'output_filename not specified.' if output_filename.empty? raise 'save_format not specified.' if save_format.empty? str_uri = "#{Aspose::Cloud::Common::Product.product_uri}/cells/convert?format=#{save_format}" str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type) signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = Aspose::Cloud::Common::Utils.upload_file_binary(input_file, signed_str_uri) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) save_format = 'zip' if save_format.eql?('html') if valid_output.empty? output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(output_filename)}.#{save_format}" Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) end valid_output end |
#convert_to_image(output_filename, worksheet_name, save_format, password = '', folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/Cells/convertor.rb', line 46 def convert_to_image(output_filename, worksheet_name, save_format, password='', folder_name = '', storage_type = 'Aspose', storage_name = '') raise 'output_filename not specified.' if output_filename.empty? raise 'worksheet_name not specified.' if worksheet_name.empty? raise 'save_format not specified.' if save_format.empty? str_uri = "#{@base_uri}/worksheets/#{worksheet_name}" qry = Hash.new qry[:format] = save_format qry[:password] = password unless password.empty? str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry) str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type) signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(signed_str_uri, {:accept => 'application/json'}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(output_filename)}.#{save_format}" valid_output.empty? ? Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) : valid_output end |
#oleobject_to_image(object_index, worksheet_name, save_format, password = '', folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/Cells/convertor.rb', line 84 def oleobject_to_image(object_index, worksheet_name, save_format, password='', folder_name = '', storage_type = 'Aspose', storage_name = '') raise 'object_index not specified.' if object_index.nil? raise 'worksheet_name not specified.' if worksheet_name.empty? raise 'save_format not specified.' if save_format.empty? str_uri = "#{@base_uri}/worksheets/#{worksheet_name}/oleobjects/#{object_index}" qry = Hash.new qry[:format] = save_format qry[:password] = password unless password.empty? str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry) str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type) signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(signed_str_uri, {:accept => 'application/json'}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}.#{save_format}" valid_output.empty? ? Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) : valid_output end |
#picture_to_image(picture_index, worksheet_name, save_format, password = '', folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/Cells/convertor.rb', line 65 def picture_to_image(picture_index, worksheet_name, save_format, password='', folder_name = '', storage_type = 'Aspose', storage_name = '') raise 'picture_index not specified.' if picture_index.nil? raise 'worksheet_name not specified.' if worksheet_name.empty? raise 'save_format not specified.' if save_format.empty? str_uri = "#{@base_uri}/worksheets/#{worksheet_name}/pictures/#{picture_index}" qry = Hash.new qry[:format] = save_format qry[:password] = password unless password.empty? str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri,qry) str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type) signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(signed_str_uri, {:accept => 'application/json'}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}.#{save_format}" valid_output.empty? ? Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) : valid_output end |