Class: GData::Spreadsheet

Inherits:
Base
  • Object
show all
Defined in:
lib/roo/google.rb

Instance Method Summary collapse

Instance Method Details

#add_to_cell_roo(row, col, value, sheet_no = 1) ⇒ Object

– new @@ added sheet_no to definition



45
46
47
# File 'lib/roo/google.rb', line 45

def add_to_cell_roo(row,col,value, sheet_no=1)
  save_entry_roo(entry_roo(value,row,col), sheet_no)
end

#entry_roo(formula, row = 1, col = 1) ⇒ Object

– new



35
36
37
38
39
40
41
# File 'lib/roo/google.rb', line 35

def entry_roo(formula, row=1, col=1)
  <<XML
<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gs='http://schemas.google.com/spreadsheets/2006'>
  <gs:cell row='#{row}' col='#{col}' inputValue='#{formula}' />
</entry>
XML
end

#evaluate_cell(cell, sheet_no = 1) ⇒ Object

– modified

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
# File 'lib/roo/google.rb', line 7

def evaluate_cell(cell, sheet_no=1)
  raise ArgumentError, "invalid cell: #{cell}" unless cell
  raise ArgumentError, "invalid sheet_no: #{sheet_no}" unless sheet_no >0 and sheet_no.class == Fixnum
  path = "/feeds/cells/#{@spreadsheet_id}/#{sheet_no}/#{@headers ? "private" : "public"}/basic/#{cell}"

  doc = Hpricot(request(path))
  result = (doc/"content").inner_html
end

#fulldoc(sheet_no) ⇒ Object



68
69
70
71
72
# File 'lib/roo/google.rb', line 68

def fulldoc(sheet_no)
  path = "/feeds/cells/#{@spreadsheet_id}/#{sheet_no}/private/full"
  doc = Hpricot(request(path))
  return doc
end

#get_one_sheetObject

– new



50
51
52
53
# File 'lib/roo/google.rb', line 50

def get_one_sheet
  path = "/feeds/cells/#{@spreadsheet_id}/1/private/full"
  doc = Hpricot(request(path))
end

new



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/roo/google.rb', line 56

def oben_unten_links_rechts(sheet_no)
  path = "/feeds/cells/#{@spreadsheet_id}/#{sheet_no}/private/full"
  doc = Hpricot(request(path))
  rows = []
  cols = []
  (doc/"gs:cell").each {|item|
    rows.push item['row'].to_i
    cols.push item['col'].to_i
  }
  return rows.min, rows.max, cols.min, cols.max
end

#save_entry_roo(entry, sheet_no) ⇒ Object

– new @@ added sheet_no to definition



29
30
31
32
# File 'lib/roo/google.rb', line 29

def save_entry_roo(entry, sheet_no)
  path = "/feeds/cells/#{@spreadsheet_id}/#{sheet_no}/#{@headers ? 'private' : 'public'}/full"
  post(path, entry)
end

#sheetlistObject

– new



17
18
19
20
21
22
23
24
25
# File 'lib/roo/google.rb', line 17

def sheetlist
  path = "/feeds/worksheets/#{@spreadsheet_id}/private/basic"
  doc = Hpricot(request(path))
  result = []
  (doc/"content").each { |elem|
    result << elem.inner_html
  }
  result
end