docs.sheetjs.com/tests/dom-jsdom.sh

37 lines
907 B
Bash
Raw Permalink Normal View History

2024-06-25 07:16:41 +00:00
#!/bin/bash
# https://docs.sheetjs.com/docs/demos/net/dom#jsdom
cd /tmp
rm -rf sheetjs-jsdom
mkdir sheetjs-jsdom
cd sheetjs-jsdom
2024-07-18 22:19:02 +00:00
npm i --save https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz
2024-06-25 07:16:41 +00:00
cat >SheetJSDOM.js <<EOF
const XLSX = require("xlsx");
const { readFileSync } = require("fs");
const { JSDOM } = require("jsdom");
/* obtain HTML string. This example reads from SheetJSTable.html */
const html_str = readFileSync("SheetJSTable.html", "utf8");
/* get first TABLE element */
const doc = new JSDOM(html_str).window.document.querySelector("table");
/* generate workbook */
const workbook = XLSX.utils.table_to_book(doc);
XLSX.writeFile(workbook, "SheetJSDOM.xlsx");
EOF
curl -LO https://docs.sheetjs.com/dom/SheetJSTable.html
2024-10-31 04:25:02 +00:00
for n in {10..25}; do
2024-06-25 07:16:41 +00:00
rm -f SheetJSDom.xlsx
npm i --save jsdom@$n
npm ls | grep jsdom
node SheetJSDom.js
npx -y xlsx-cli SheetJSDom.xlsx | head -n 3
done