#!/usr/bin/env pwsh # https://docs.sheetjs.com/docs/demos/engines/goja $ErrorActionPreference = "Stop" $oldDir = Get-Location $tempDir = Join-Path -Path $env:TEMP -ChildPath "SheetGoja" if (Test-Path -Path $tempDir) { Remove-Item -Path $tempDir -Recurse -Force } New-Item -ItemType Directory -Path $tempDir | Out-Null Set-Location -Path $tempDir go mod init SheetGoja go get github.com/dop251/goja Invoke-WebRequest -Uri "https://cdn.sheetjs.com/xlsx-latest/package/dist/shim.min.js" -OutFile "shim.min.js" Invoke-WebRequest -Uri "https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js" -OutFile "xlsx.full.min.js" Invoke-WebRequest -Uri "https://sheetjs.com/pres.numbers" -OutFile "pres.numbers" Invoke-WebRequest -Uri "https://docs.sheetjs.com/goja/SheetGoja.go" -OutFile "SheetGoja.go" go build SheetGoja.go if ($LASTEXITCODE -ne 0) { throw "Build failed" } .\SheetGoja.exe pres.numbers if ($LASTEXITCODE -ne 0) { throw "Execution failed" } Set-Location $oldDir Remove-Item -Path $tempDir -Recurse -Force