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
|
|
|
|
|
|
|
|
for n in {10..24}; do
|
|
|
|
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
|