Soroban
Soroban is a calculating engine that understands Excel formulas.
Getting Started
Apart from the examples on this page, look at the tests and the API docs to get up to speed.
Example Usage
s = Soroban::Sheet.new()
s.A1 = 2
s.set('B1:B5' => [1,2,3,4,5])
s.C1 = "=SUM(A1, B1:B5, 5) + A1 ^ 3"
s.C2 = "=IF(C1>30,'Large','Tiny')"
puts s.C1 # => 30
s.bind(:input => :A1, :output => :C2)
puts s.output # => "Tiny"
s.input = 3
puts s.output # => "Large"
puts s.C1 # => 50
Bindings
Soroban allows you to bind meaningful variable names to individual cells and to ranges of cells. When bound to a range, variables act as an array.
s.set(:A1 => 'hello', 'B1:B5' => [1,2,3,4,5])
s.bind(:foo => :A1, :bar => 'B1:B5')
puts s.foo # => 'hello'
puts s.bar[0] # => 1
s.bar[0] = 'howdy'
puts s.B1 # => 'howdy'
Persistence
Soroban formulas are strings that begin with the = symbol. It is therefore
easy to persist them, which is mighty handy if you need to parse an Excel
spreadsheet, rip out formulas, store everything to a database and then perform
calculations based on user input.


