forked from sheetjs/docs.sheetjs.com
35 lines
750 B
Bash
Executable File
35 lines
750 B
Bash
Executable File
#!/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-latest/xlsx-latest.tgz
|
|
|
|
bun run sheet2csv.ts pres.numbers
|
|
|
|
bun build ./sheet2csv.ts --compile --outfile sheet2csv
|
|
./sheet2csv pres.numbers
|