sheetjs-vite/src/components/HelloWorld.vue

20 lines
554 B
Vue
Raw Normal View History

2023-06-07 03:22:26 +00:00
<script setup lang="ts">
2023-06-07 03:23:50 +00:00
// @ts-ignore
2023-06-07 03:30:28 +00:00
import b64 from '../../data/pres.xlsx?b64';
import { read, utils } from "xlsx";
/* parse workbook and convert first sheet to row array */
const wb = read(b64);
const ws = wb.Sheets[wb.SheetNames[0]];
interface IPresident { Name: string; Index: number; };
const data = utils.sheet_to_json<IPresident>(ws);
2023-06-07 03:22:26 +00:00
</script>
<template>
2023-06-07 03:23:50 +00:00
<table>
<tr><th>Name</th><th>Index</th></tr>
<tr v-for="(row,R) in data" v-bind:key="R">
<td>{{row.Name}}</td>
<td>{{row.Index}}</td>
</tr>
</table>
</template>