Class: Aspose::Cloud::Cells::Extractor

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

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Extractor

Returns a new instance of Extractor.



5
6
7
# File 'lib/Cells/extractor.rb', line 5

def initialize filename
  @filename = filename
end

Instance Method Details

#get_auto_shape(worksheet_name, shape_index, image_format) ⇒ Object

saves a specific auto-shape from a specific sheet as image

Parameters:

  • worksheet_name
  • shape_index
  • image_format


121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/Cells/extractor.rb', line 121

def get_auto_shape worksheet_name, shape_index, image_format
  begin
    if @filename==''
      raise 'Base file name is not specified'
    end
    str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + 
      worksheet_name.to_s + '/autoshapes/' + shape_index.to_s + '?format=' + image_format.to_s
			
    #Sign URI
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

    #Send request and receive response stream
    response_stream = RestClient.get signed_uri, {:accept=>'application/json'}

    #Validate output
    v_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
 
    if v_output == ''
      #Save output file
      output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename)+ 
        '_' + worksheet_name + '.' + image_format
      Aspose::Cloud::Common::Utils.save_file(response_stream, output_path)
      return output_path
    else 
      return v_output
    end
  rescue Exception=>e
    print e
  end
end

#get_chart(worksheet_name, chart_index, image_format) ⇒ Object

saves a specific chart from a specific sheet as image

Parameters:

  • worksheet_name
  • chart_index
  • image_format


85
86
87
88
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
114
# File 'lib/Cells/extractor.rb', line 85

def get_chart worksheet_name, chart_index, image_format
  begin
    if @filename==''
      raise 'Base file name is not specified'
    end
    str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + 
      worksheet_name.to_s + '/charts/' + chart_index.to_s + '?format=' + image_format.to_s
			
    #Sign URI
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

    #Send request and receive response stream
    response_stream = RestClient.get signed_uri, {:accept=>'application/json'}

    #Validate output
    v_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
 
    if v_output == ''
      #Save output file
      output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename)+ 
        '_' + worksheet_name + '.' + image_format
      Aspose::Cloud::Common::Utils.save_file(response_stream, output_path)
      return output_path
    else 
      return v_output
    end
  rescue Exception=>e
    print e
  end
end

#get_ole_object(worksheet_name, object_index, image_format) ⇒ Object

saves a specific OleObject from a specific sheet as image

Parameters:

  • worksheet_name
  • object_index
  • image_format


49
50
51
52
53
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
# File 'lib/Cells/extractor.rb', line 49

def get_ole_object worksheet_name, object_index, image_format
  begin
    if @filename==''
      raise 'Base file name is not specified'
    end
    str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + 
      worksheet_name.to_s + '/oleobjects/' + object_index.to_s + '?format=' + image_format.to_s
			
    #Sign URI
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

    #Send request and receive response stream
    response_stream = RestClient.get signed_uri, {:accept=>'application/json'}

    #Validate output
    v_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
 
    if v_output == ''
      #Save output file
      output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename)+ 
        '_' + worksheet_name + '.' + image_format
      Aspose::Cloud::Common::Utils.save_file(response_stream, output_path)
      return output_path
    else 
      return v_output
    end
  rescue Exception=>e
    print e
  end
end

#get_picture(worksheet_name, picture_index, image_format) ⇒ Object

saves a specific picture from a specific sheet as image

Parameters:

  • worksheet_name
  • picture_index
  • image_format


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/Cells/extractor.rb', line 13

def get_picture worksheet_name, picture_index, image_format
  begin
    if @filename==''
      raise 'Base file name is not specified'
    end
    str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + 
      worksheet_name.to_s + '/pictures/' + picture_index.to_s + '?format=' + image_format.to_s
			
    #Sign URI
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

    #Send request and receive response stream
    response_stream = RestClient.get signed_uri, {:accept=>'application/json'}

    #Validate output
    v_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)
 
    if v_output == ''
      #Save output file
      output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename)+ 
        '_' + worksheet_name + '.' + image_format
      Aspose::Cloud::Common::Utils.save_file(response_stream, output_path)
      return output_path
    else 
      return v_output
    end
  rescue Exception=>e
    print e
  end
end