docs.sheetjs.com/docz/static/astrojs/index.astro

28 lines
634 B
Plaintext
Raw Permalink Normal View History

2023-08-01 00:28:19 +00:00
---
/* -- the code in the frontmatter is only run at build time -- */
import { read, utils } from "xlsx";
/* parse workbook */
import b64 from "../data/pres.numbers";
const wb = read(b64, {type: "base64"});
/* generate row objects */
interface IPresident {
Name: string;
Index: number;
}
const data = utils.sheet_to_json<IPresident>(wb.Sheets[wb.SheetNames[0]]);
---
<html>
<body>
<h3>Presidents</h3>
<table>
<thead><tr><th>Name</th><th>Index</th></tr></thead>
<tbody>
{data.map(row => (<tr>
<td>{row.Name}</td><td>{row.Index}</td>
</tr>))}
</tbody>
</table>
</body>
</html>