🔷 sheetruby

Run Ruby code in Google Sheets using mruby/edge

What is sheetruby?

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.

How to Use

  1. Open your Google Spreadsheet
  2. Go to Extensions → Apps Script
  3. Copy the contents of combined.js and paste it into the script editor
  4. Save the script
  5. Return to your spreadsheet - the EVAL_RUBY_SCRIPT() function is now available!

EVAL_RUBY_SCRIPT() Function Specification

EVAL_RUBY_SCRIPT(ruby_code, [arg1], [arg2], [arg3])

Parameters

Type Handling

Examples

Basic calculation:
=EVAL_RUBY_SCRIPT("1 + 2")
# => 3
Using cell references:
=EVAL_RUBY_SCRIPT("$arg1 * 2", A1)
# If A1 = 21, returns 42
Array processing:
=EVAL_RUBY_SCRIPT("$arg1.map { |x| x * $arg2 }", A1:A3, B1)
# If A1:A3 = [[1], [2], [3]] and B1 = 10
# Returns [10, 20, 30]
Multiple arguments:
=EVAL_RUBY_SCRIPT("$arg1 + $arg2 + $arg3", A1, B1, C1)
# Sum of three cells
String manipulation:
=EVAL_RUBY_SCRIPT("$arg1.upcase", A1)
# If A1 = "hello", returns "HELLO"
Math functions (with mrubyedge-math):
=EVAL_RUBY_SCRIPT("Math.sqrt($arg1)", 16)
# => 4.0

Building from Source

Prerequisites

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"

Build

make build

This will generate combined.js in the project root.

Contributing

Bug reports and contributions are welcome! Please feel free to:

View on GitHub mruby/edge Project