Class: Aspose::Cloud::Cells::TextEditor

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

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ TextEditor

Returns a new instance of TextEditor.



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

def initialize filename
  @filename = filename
end

Instance Method Details

#find_text(text) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/Cells/text_editor.rb', line 9

def find_text text
  begin
    if @filename == ''
      raise 'Base File Name is not Specified.'
    end
    str_uri = $product_uri + '/cells/' + @filename + '/findText?text=' + text.to_s
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
    response = RestClient.post signed_uri, '' , {:accept => 'application/json'}
    json = JSON.parse(response)
    return json['TextItems']['TextItemList']
  rescue Exception=>e
    print e
  end
end

#find_text_in_worksheet(worksheet_name, text) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/Cells/text_editor.rb', line 23

def find_text_in_worksheet worksheet_name,text
  begin
    if @filename == ''
      raise 'Base File Name is not Specified.'
    end
    str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + worksheet_name.to_s +  '/findText?text=' + text.to_s
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
    response = RestClient.post signed_uri, '' , {:accept => 'application/json'}
    json = JSON.parse(response)
    return json['TextItems']['TextItemList']
  rescue Exception=>e
    print e
  end
end

#get_text_items(worksheet_name) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/Cells/text_editor.rb', line 38

def get_text_items worksheet_name
  begin
    if @filename == ''
      raise 'Base File Name is not Specified.'
    end
    str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + worksheet_name.to_s +  '/textItems' 
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
    response = RestClient.get signed_uri, {:accept => 'application/json'}
    json = JSON.parse(response)
    return json['TextItems']['TextItemList']
  rescue Exception=>e
    print e
  end
end

#replace_text(old_text, new_text) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/Cells/text_editor.rb', line 53

def replace_text old_text,new_text
  begin
    if @filename == ''
      raise 'Base File Name is not Specified.'
    end
    str_uri = $product_uri + '/cells/' + @filename + '/replaceText?oldValue=' + old_text.to_s + '&newValue=' + new_text.to_s 
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
    response = RestClient.post signed_uri,'', {:accept => 'application/json'}
    v_output = Aspose::Cloud::Common::Utils.validate_output(response)
    if v_output==nil || v_output==''
      # Save doc on server
      folder = Aspose::Cloud::AsposeStorage::Folder.new
      output_stream = folder.get_file(@filename);
      output_path = $out_put_location + @filename;
      Aspose::Cloud::Common::Utils.save_file(output_stream, output_path);
      return 'Value is changed';
    end
  rescue Exception=>e
    print e
  end
end

#replace_text_in_worksheet(worksheet_name, old_text, new_text) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/Cells/text_editor.rb', line 75

def replace_text_in_worksheet worksheet_name, old_text, new_text
  begin
    if(@filename == '')
      raise 'Base File Name is not Specified.'
    end
    str_uri = $product_uri + '/cells/' + @filename + '/worksheets/' + worksheet_name.to_s + '/replaceText?oldValue=' + old_text.to_s + '&newValue=' + new_text.to_s 
    signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
    response = RestClient.post signed_uri,'', {:accept => 'application/json'}
    v_output = Aspose::Cloud::Common::Utils.validate_output(response)
    if v_output==nil || v_output==''
      # Save doc on server
      folder = Aspose::Cloud::AsposeStorage::Folder.new
      output_stream = folder.get_file(@filename);
      output_path = $out_put_location + @filename;
      Aspose::Cloud::Common::Utils.save_file(output_stream, output_path);
      return 'Value is changed';
    end
  rescue Exception=>e
    print e
  end
end