11 lines
454 B
JavaScript
11 lines
454 B
JavaScript
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"); |