docs.sheetjs.com/docz/static/live/fetch.html

24 lines
913 B
HTML
Raw Permalink Normal View History

2022-10-19 10:05:59 +00:00
<body>
<style>TABLE { border-collapse: collapse; } TD { border: 1px solid; }</style>
<div id="tavolo"></div>
<script src="https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js"></script>
<script type="text/javascript">
(async() => {
/* fetch and parse workbook -- see the fetch example for details */
2024-04-26 04:16:13 +00:00
const workbook = XLSX.read(await (await fetch("https://docs.sheetjs.com/pres.numbers")).arrayBuffer());
2022-10-19 10:05:59 +00:00
let output = [];
/* loop through the worksheet names in order */
workbook.SheetNames.forEach(name => {
/* generate HTML from the corresponding worksheets */
const worksheet = workbook.Sheets[name];
const html = XLSX.utils.sheet_to_html(worksheet);
/* add a header with the title name followed by the table */
output.push(`<H3>${name}</H3>${html}`);
});
/* write to the DOM at the end */
tavolo.innerHTML = output.join("\n");
})();
</script>
</body>