docs.sheetjs.com/tests/cli-bunsea.sh

36 lines
751 B
Bash
Raw Normal View History

2024-05-29 05:10:39 +00:00
#!/bin/bash
# https://docs.sheetjs.com/docs/demos/cli/bunsea
cd /tmp
rm -rf sheetjs-bunsea
mkdir sheetjs-bunsea
cd sheetjs-bunsea
bun --version
curl -o pres.numbers https://docs.sheetjs.com/pres.numbers
cat >sheet2csv.ts <<EOF
const XLSX = require("xlsx");
/* process.argv[2] is the first argument to the script */
const filename = process.argv[2];
/* read file */
const wb = XLSX.readFile(filename);
/* generate CSV of first sheet */
const ws = wb.Sheets[wb.SheetNames[0]];
const csv = XLSX.utils.sheet_to_csv(ws);
/* print to terminal */
console.log(csv);
EOF
bun install https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz
bun run sheet2csv.ts pres.numbers
bun build ./sheet2csv.ts --compile --outfile sheet2csv
./sheet2csv pres.numbers