xlsx-js-style | xlsx-js-style homepage (gitbrent.github.io)
import { utils, writeFile } from 'xlsx-js-style';
const tableEl = document.getElementById("export-table");
const workbook = utils.table_to_book(tableEl);worksheet[i].t = "s";
worksheet[i].s = {s: {font: {name: "宋体",bold: true,},alignment: {horizontal: "center",vertical: "center",wrapText: true,},border: {top: { style: "thin", color: { rgb: "000000" } },bottom: { style: "thin", color: { rgb: "000000" } },left: { style: "thin", color: { rgb: "000000" } },right: { style: "thin", color: { rgb: "000000" } },},fill: {fgColor: { rgb: "909399" },},},
};const worksheet = workbook?.Sheets?.Sheet1;
workbook.SheetNames = [sheetName];
workbook.Sheets[sheetName] = worksheet;
const innerHTML = document.getElementById("export-html").innerHTML;
utils.sheet_add_aoa(worksheet, [[innerHTML]], { origin: -1 });
writeFile(workbook, '名称.xlsx');