#!/usr/bin/env pwsh # https://docs.sheetjs.com/docs/demos/cli/bunsea $oldDir = Get-Location $tempDir = Join-Path -Path $env:TEMP -ChildPath "sheetjs-bunsea" if (Test-Path -Path $tempDir) { Remove-Item -Path $tempDir -Recurse -Force } New-Item -ItemType Directory -Path $tempDir | Out-Null Set-Location -Path $tempDir bun --version curl -o pres.numbers https://docs.sheetjs.com/pres.numbers @' 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); '@ | Out-File -FilePath "sheet2csv.ts" -Encoding utf8 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 Set-Location $oldDir Remove-Item -Path $tempDir -Recurse -Force