--- title: Ruby + Bindings pagination_prev: demos/bigdata/index pagination_next: solutions/input --- import current from '/version.js'; ExecJS is a Ruby abstraction over a number of JS runtimes including V8. The [Standalone scripts](/docs/getting-started/installation/standalone) can be parsed and evaluated in every supported runtime. ## Integration Details _Load SheetJS Scripts_ The main library can be loaded and compiled in a new context: ```rb require "execjs" source = File.open("xlsx.full.min.js").read; context = ExecJS.compile(source); ``` To confirm the library is loaded, `XLSX.version` can be inspected: ```rb puts context.eval("XLSX.version"); ``` _Reading and Writing Files_ The architecture of ExecJS forces users to combine reading and writing in one function step. Base64 strings should be used for interchange. For example, the following snippet reads data from `pres.numbers`, generates an XLSB file, and writes to `sheetjsw.xlsb`: ```rb require "base64" # read and encode data to Base64 data = Base64.strict_encode64(File.open("pres.numbers").read); # define function and call with the data xlsb = context.call(<
  • xlsx.full.min.js
  • pres.numbers
  • {`\
    curl -LO https://cdn.sheetjs.com/xlsx-${current}/package/dist/xlsx.full.min.js
    curl -LO https://sheetjs.com/pres.numbers`}
    
    2) Download [`ExecSheetJS.rb`](pathname:///execjs/ExecSheetJS.rb): ```bash curl -LO https://docs.sheetjs.com/execjs/ExecSheetJS.rb ``` 3) Run the demo: ```bash ruby ExecSheetJS.rb pres.numbers ``` If the program succeeded, the CSV contents will be printed to console and the file `sheetjsw.xlsb` will be created. That file can be opened with Excel.