Class: Aspose::Cloud::Cells::Convertor

Inherits:
Object
  • Object
show all
Defined in:
lib/Cells/convertor.rb

Overview

This class provides functionality for converting Excel Spreadsheets to other supported formats.

Instance Method Summary collapse

Constructor Details

#initialize(filename, worksheet_name) ⇒ Convertor

Constructor for the Convertor Class.

  • :name represents the name of the Excel Spreadsheet on the Aspose server



8
9
10
# File 'lib/Cells/convertor.rb', line 8

def initialize()
  
end

Instance Method Details

#autoshape_to_image(shape_index, image_format) ⇒ Object



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/Cells/convertor.rb', line 195

def autoshape_to_image shape_index,image_format
  begin
    if @filename==''
      raise 'Base File is not specified'
    end
    if @worksheet_name==''
      raise 'Worksheet is not specified'
    end
    str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + 
      @worksheet_name + '/autoshapes/' + shape_index.to_s + '?format=' + image_format.to_s;
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

    response = RestClient.get(signed_uri, :accept => 'application/json')
      
    v_output = Aspose::Cloud::Common::Utils.validate_output(response)
    if v_output==nil || v_output==''
      outputpath=$out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '_' + @worksheet_name + '.' + image_format
      Aspose::Cloud::Common::Utils.save_file(response, outputpath)
      return outputpath
    else
      return v_output
    end
  rescue Exception=>e
    print e
  end
end

#chart_to_image(chart_index, image_format) ⇒ Object



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/Cells/convertor.rb', line 168

def chart_to_image chart_index,image_format
  begin
    if @filename==''
      raise 'Base File is not specified'
    end
    if @worksheet_name==''
      raise 'Worksheet is not specified'
    end
    str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + 
      @worksheet_name + '/charts/' + chart_index.to_s + '?format=' + image_format.to_s;
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

    response = RestClient.get(signed_uri, :accept => 'application/json')
      
    v_output = Aspose::Cloud::Common::Utils.validate_output(response)
    if v_output==nil || v_output==''
      outputpath=$out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '_' + @worksheet_name + '.' + image_format
      Aspose::Cloud::Common::Utils.save_file(response, outputpath)
      return outputpath
    else
      return v_output
    end
  rescue Exception=>e
    print e
  end
end

#convert(local_file, save_format) ⇒ Object

Converts the file available at Aspose Storage and saves converted file locally.

  • :localFile represents converted local file path and name

  • :saveFormat represents the converted format. For a list of supported formats, please visit

http://aspose.com/docs/display/cells/workbook


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/Cells/convertor.rb', line 23

def convert local_file,save_format
  begin
    if @filename == ''
      raise 'Base file is not specified'
    end  
    url_doc = $product_uri + '/cells/' + @filename + '?format=' + save_format
    signed_url = Aspose::Cloud::Common::Utils.sign(url_doc)
    response = RestClient.get(signed_url, :accept => 'application/json')
    validate_output = Aspose::Cloud::Common::Utils.validate_output(response)
    if validate_output!=nil || validate_output!=''
      output = $out_put_location + local_file + '.' + save_format
      Aspose::Cloud::Common::Utils.save_file(response, output)
      return output
    else
      return validate_output
    end
  rescue Exception=>e
    print e
  end
end

#convert_to_image(image_format, worksheet_name) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/Cells/convertor.rb', line 44

def convert_to_image image_format,worksheet_name
  begin
    if @filename == ''
      raise 'Base File is not specified.'
    end
    str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + worksheet_name.to_s + '?format=' + image_format.to_s
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
    response = RestClient.get(signed_uri,:accept => 'application/json')
    validate_output = Aspose::Cloud::Common::Utils.validate_output(response)
    if validate_output!=nil || validate_output!=''
      output = $out_put_location + worksheet_name + '.' + image_format
      Aspose::Cloud::Common::Utils.save_file(response, output);
      return output
    else
      return validate_output
    end
    
  rescue Exception=>e
    print e
  end
end

#oleobject_to_image(object_index, image_format) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/Cells/convertor.rb', line 142

def oleobject_to_image object_index,image_format
  begin
    if @filename==''
      raise 'Base File is not specified'
    end
    if @worksheet_name==''
      raise 'Worksheet is not specified'
    end
    str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + 
      @worksheet_name + '/oleobjects/' + object_index.to_s + '?format=' + image_format.to_s;
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
    response = RestClient.get(signed_uri, :accept => 'application/json')
      
    v_output = Aspose::Cloud::Common::Utils.validate_output(response)
    if v_output==nil || v_output==''
      outputpath=$out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '_' + @worksheet_name + '.' + image_format
      Aspose::Cloud::Common::Utils.save_file(response, outputpath)
      return outputpath
    else
      return v_output
    end
  rescue Exception=>e
    print e
  end
end

#picture_to_image(picture_index, image_format) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/Cells/convertor.rb', line 115

def picture_to_image picture_index,image_format
  begin
    if @filename==''
      raise 'Base File is not specified'
    end
    if @worksheet_name==''
      raise 'Worksheet is not specified'
    end
    str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + 
      @worksheet_name + '/pictures/' + picture_index.to_s + '?format=' + image_format.to_s;
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  
    response = RestClient.get(signed_uri, :accept => 'application/json')
      
    v_output = Aspose::Cloud::Common::Utils.validate_output(response)
    if v_output==nil || v_output==''
      outputpath=$out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '_' + @worksheet_name + '.' + image_format
      Aspose::Cloud::Common::Utils.save_file(response, outputpath)
      return outputpath
    else
      return v_output
    end
  rescue Exception=>e
    print e
  end
end

#save(output_format) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/Cells/convertor.rb', line 66

def save output_format
  begin
    if @filename==''
      raise 'Base File is not specified.'
    end
    str_uri = $product_uri + '/cells/' + @filename + '?format=' + output_format.to_s
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
    response = RestClient.get(signed_uri,:accept => 'application/json')
    validate_output = Aspose::Cloud::Common::Utils.validate_output(response)
    if validate_output==nil || validate_output==''
      output = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '.' + output_format
      Aspose::Cloud::Common::Utils.save_file(response, output);
      return output
    else
      return validate_output
    end
    
    
  rescue Exception=>e
    print e
  end
end

#worksheet_to_image(image_format) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/Cells/convertor.rb', line 89

def worksheet_to_image image_format
  begin
    if @filename==''
      raise 'Base file name is not specified.'
    end
    if @worksheet_name == ''
      raise 'Worksheet is not specified'
    end
    str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + 
      @worksheet_name + '?format=' + image_format.to_s
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
    response = RestClient.get(signed_uri,:accept => 'application/json')
    v_output = Aspose::Cloud::Common::Utils.validate_output(response)
    if v_output==nil || v_output==''
      outputpath=$out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '_' + @worksheet_name + '.' + image_format
      Aspose::Cloud::Common::Utils.save_file(response, outputpath)
      return outputpath
    else
      return v_output
    end
  rescue Exception=>e
    print e
  end
  
end