Run Ruby code in Google Sheets using mruby/edge
sheetruby embeds the mruby/edge VM into Google Apps Script, allowing you to execute Ruby code directly in your spreadsheets. It compiles to WebAssembly and runs entirely within Google Sheets' Apps Script environment.
combined.js
and paste it into the script editorEVAL_RUBY_SCRIPT() function is now available!EVAL_RUBY_SCRIPT() Function SpecificationEVAL_RUBY_SCRIPT(ruby_code, [arg1], [arg2], [arg3])
$arg1, $arg2,
$arg3=EVAL_RUBY_SCRIPT("1 + 2")
# => 3
=EVAL_RUBY_SCRIPT("$arg1 * 2", A1)
# If A1 = 21, returns 42
=EVAL_RUBY_SCRIPT("$arg1.map { |x| x * $arg2 }", A1:A3, B1)
# If A1:A3 = [[1], [2], [3]] and B1 = 10
# Returns [10, 20, 30]
=EVAL_RUBY_SCRIPT("$arg1 + $arg2 + $arg3", A1, B1, C1)
# Sum of three cells
=EVAL_RUBY_SCRIPT("$arg1.upcase", A1)
# If A1 = "hello", returns "HELLO"
=EVAL_RUBY_SCRIPT("Math.sqrt($arg1)", 16)
# => 4.0
1. Install Emscripten SDK
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
2. Install Rust with the wasm32-unknown-emscripten target:
rustup target add wasm32-unknown-emscripten
3. Set the BINDGEN_EXTRA_CLANG_ARGS environment variable:
export BINDGEN_EXTRA_CLANG_ARGS="--sysroot=$EMSDK/upstream/emscripten/cache/sysroot"
make build
This will generate
combined.js
in the project root.
Bug reports and contributions are welcome! Please feel free to: