#!/bin/bash # https://docs.sheetjs.com/docs/demos/frontend/bundler/systemjs cd /tmp rm -rf sheetjs-systemjs mkdir sheetjs-systemjs cd sheetjs-systemjs npm init -y ## NodeJS Demo npm i --save https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz curl -LO https://docs.sheetjs.com/systemjs/SheetJSystem.js for v in 6.x 0.21.6 0.20.19 0.19.47; do echo "SystemJS NodeJS version $v" npm i --save systemjs@$v node SheetJSystem.js npx -y xlsx-cli Presidents.xlsx | head -n 3 rm -f Presidents.xlsx done ## Browser Demo curl -LO https://docs.sheetjs.com/pres.xlsx npm i --save puppeteer cat >test.js << 'EOF' const path = require('path'); const puppeteer = require('puppeteer'); (async() => { await new Promise((res,rej) => setTimeout(res, 1000)); const browser = await puppeteer.launch(); const page = await browser.newPage(); page.on("console", msg => console.log("PAGE LOG:", msg.text())); await page.setViewport({width: 1920, height: 1080}); const client = await page.target().createCDPSession(); await client.send('Browser.setDownloadBehavior', { behavior: 'allow', downloadPath: require("path").resolve('./') }); await page.goto('https://docs.sheetjs.com/systemjs/systemjs'); const xlf = await page.$('#xlf'); await xlf.uploadFile(path.resolve('./pres.xlsx')); await page.evaluate(() => { const xlf = document.querySelector('#xlf'); const evt = new Event('change', { bubbles: true }); xlf.dispatchEvent(evt); }); await new Promise((res,rej) => setTimeout(res, 1000)); const text = await page.$eval('#out', el => el.innerText); console.log(text); await browser.close(); process.exit(); })(); EOF node test.js