Skip to main content

Sheets in a Box with boxednode

boxednode1 is a tool for generating command-line tools that embed scripts. It automates the process of building NodeJS from source.

SheetJS is a JavaScript library for reading and writing data from spreadsheets.

This demo uses boxednode and SheetJS to create a standalone CLI tool for parsing spreadsheets and converting to other formats.

Tested Deployments

This demo was tested in the following deployments:

ArchitectureVersionNodeJSDate
darwin-x642.4.022.2.02024-05-28
darwin-arm2.4.322.2.02024-05-25
win11-x642.4.416.20.22024-12-19
linux-x642.4.021.7.12024-03-21
linux-arm2.4.320.13.12024-05-26

Integration Details

The SheetJS NodeJS module can be required from scripts. boxednode will automatically handle packaging.

Script Requirements

Scripts that exclusively use SheetJS libraries and NodeJS built-in modules can be bundled using boxednode

The demo script xlsx-cli.js runs in NodeJS. It is a simple command-line tool for reading and writing spreadsheets.

Complete Example

  1. Download the test file https://docs.sheetjs.com/pres.numbers:
curl -o pres.numbers https://docs.sheetjs.com/pres.numbers
  1. Download xlsx-cli.js
curl -o xlsx-cli.js https://docs.sheetjs.com/cli/xlsx-cli.js
  1. Install the dependencies:
yarn add https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz exit-on-epipe commander@2
  1. Create the standalone program:
npx [email protected] -s xlsx-cli.js -t xlsx-cli

When this demo was last tested in linux-arm, the build failed with an error:

../deps/v8/src/base/small-vector.h: In instantiation of ‘class v8::base::SmallVector<std::pair<const v8::internal::compiler::turboshaft::PhiOp*, const v8::internal::compiler::turboshaft::OpIndex>, 16>’: ../deps/v8/src/compiler/turboshaft/loop-unrolling-reducer.h:444:11: required from here ../deps/v8/src/base/macros.h:206:55: error: static assertion failed: T should be trivially copyable 206 | static_assert(::v8::base::is_trivially_copyable<T>::value, \ | ^~~~~

This affects NodeJS 22.2.0, but does not affect 20.13.1. It affects the V8 JavaScript Engine.

The -n flag controls the target NodeJS version. For this demo, the following command uses NodeJS 20.13.1:

npx [email protected] -s xlsx-cli.js -t xlsx-cli -n 20.13.1
  1. Run the generated program, passing pres.numbers as the argument:
./xlsx-cli pres.numbers

Footnotes

  1. The project does not have a website. The source repository is publicly available.

  2. Downloads can be found at the main NASM project website