Sheets in a Box with boxednode
boxednode
1 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.
This demo was tested in the following deployments:
Architecture | Version | NodeJS | Date |
---|---|---|---|
darwin-x64 | 2.4.0 | 22.2.0 | 2024-05-28 |
darwin-arm | 2.4.3 | 22.2.0 | 2024-05-25 |
win11-x64 | 2.4.4 | 16.20.2 | 2024-12-19 |
linux-x64 | 2.4.0 | 21.7.1 | 2024-03-21 |
linux-arm | 2.4.3 | 20.13.1 | 2024-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
- Download the test file https://docs.sheetjs.com/pres.numbers:
curl -o pres.numbers https://docs.sheetjs.com/pres.numbers
- Download
xlsx-cli.js
curl -o xlsx-cli.js https://docs.sheetjs.com/cli/xlsx-cli.js
- Install the dependencies:
- npm
- pnpm
- Yarn
npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz exit-on-epipe commander@2
pnpm install --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz exit-on-epipe commander@2
yarn add https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz exit-on-epipe commander@2
- Create the standalone program:
- Linux/MacOS
- Windows
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
npx [email protected] -s xlsx-cli.js -t xlsx-cli.exe -n 16.20.2
The Windows builds require Visual Studio with "Desktop development with C++" workload, Python 3.11, and NASM2.
The build command must be run in "x64 Native Tools Command Prompt"
When the demo was last tested, the build failed:
Not an executable Python program
Could not find Python.
By default, Windows aliases python
to a Microsoft Store installer. If the
official installer was used, the alias should be disabled manually:
-
Open Start menu and type "app alias". Click "Manage app execution aliases".
-
Disable the App Installer for all items with
python
in the name.
Using Python 3.12, the build fails with an error:
Please use python3.11 or python3.10 or python3.9 or python3.8 or python3.7 or python3.6.
In the most recent test, Python 3.11.8 was installed from the official site.
When the demo was last tested on Windows, the build failed:
error MSB8020: The build tools for Visual Studio 2019 (Platform Toolset = 'v142') cannot be found. To build using the v142 build tools, please install Visual Studio 2019 build tools.
This error was fixed by installing the v142
build tools through the Visual
Studio installer.
In the most recent Windows test against NodeJS 20.8.0
, the build failed due
to an issue in the OpenSSL dependency:
...\node-v20.8.0\deps\openssl\openssl\crypto\cversion.c(75,33): error C2153: integer literals must have at least one digit [...\node-v20.8.0\deps\openssl\openssl.vcxproj]
SheetJS libraries are compatible with NodeJS versions dating back to v0.8
. The
workaround is to select NodeJS v16.20.2
using the -n
flag. This version was
was chosen since NodeJS v18
upgraded the OpenSSL dependency.
- Run the generated program, passing
pres.numbers
as the argument:
- Linux/MacOS
- Windows
./xlsx-cli pres.numbers
.\xlsx-cli.exe pres.numbers
Footnotes
-
The project does not have a website. The source repository is publicly available. ↩
-
Downloads can be found at the main NASM project website ↩