Module: LibExcel

Defined in:
lib/libexcel.rb,
lib/libexcel/formula.rb,
lib/libexcel/document.rb,
lib/libexcel/worksheet.rb

Defined Under Namespace

Classes: Document, Formula, Worksheet

Constant Summary collapse

VERSION =
"0.1"

Class Method Summary collapse

Class Method Details

.range(args) ⇒ String

Creates the full Excel XML equation string

Returns:

  • (String)

    the full Excel style equation string



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/libexcel.rb', line 15

def range(args)
  if args[:cols].nil?
    (buf = static(args[:rows].first, args[:col])) << ':'
    buf << static(args[:rows].last, args[:col])
  elsif args[:rows].nil?
    (buf = static(args[:row], args[:cols].first)) << ':'
    buf << static(args[:row], args[:cols].last)
  else
    (buf = static(args[:rows].first, args[:cols].first)) << ':'
    buf << static(args[:rows].last, args[:cols].last)
  end
end

.static(row, col) ⇒ String

Creates part of the Excel XML style equation string

Examples:

static(1, 1)   => "R[1]C[1]"
static(0, 1)   => "R[0]C[1]"
static(1)      => "R[1]C"
static(nil, 1) => "RC[1]"

Parameters:

  • the (Integer, Integer)

    two integer values to be converted

Returns:

  • (String)

    the Excel style equation string



38
39
40
41
42
43
44
45
46
# File 'lib/libexcel.rb', line 38

def static(row, col)
  if col.nil?
    "R[#{row}]C"
  elsif row.nil?
    "RC[#{col}]"
  else
    "R[#{row}]C[#{col}]"
  end
end