#!/usr/bin/env pwsh # https://docs.sheetjs.com/docs/demos/net/dom#cheeriojs $oldDir = Get-Location $tempDir = Join-Path -Path $env:TEMP -ChildPath "sheetjs-cheeriojs" if (Test-Path -Path $tempDir) { Remove-Item -Path $tempDir -Recurse -Force } New-Item -ItemType Directory -Path $tempDir | Out-Null Set-Location -Path $tempDir npm i --save https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz Invoke-WebRequest -Uri "https://docs.sheetjs.com/dom/SheetJSCheerio.js" -OutFile "SheetJSCheerio.js" -MaximumRedirection 20 # NOTE: IWR does not correctly handle the redirect from SheetJSTable.html Invoke-WebRequest -Uri "https://docs.sheetjs.com/dom/SheetJSTable" -OutFile "SheetJSTable.html" -MaximumRedirection 20 $versions = @("1.2.0") foreach ($version in $versions) { if (Test-Path -Path "SheetJSCheerio.xlsx") { Remove-Item -Path "SheetJSCheerio.xlsx" -Force } npm i --save cheerio@$version npm ls cheerio node SheetJSCheerio.js npx -y xlsx-cli SheetJSCheerio.xlsx | Select-Object -First 3 } Set-Location $oldDir Remove-Item -Path $tempDir -Recurse -Force