@8sheets/vue
v1.6.0
Published
Vue 3 component for 8sheets, the Excel-compatible spreadsheet: <Sheet> with typed props, events and template ref.
Maintainers
Readme
8sheets for Vue
Sheet puts an 8sheets workbook, an Excel-compatible spreadsheet, in a Vue 3.4+ app. It is a plain ES module with a render function, so it needs no Vue compiler, and it is typed.
Install
npm i @8sheets/vue @8sheets/coreUse
<script setup>
import { reactive } from 'vue';
import { Sheet } from '@8sheets/vue';
const options = reactive({ chrome: 'light', parts: { titleBar: false } });
const onReady = (wb) => { wb.activeSheet.range('A1').values = [['Item', 'Qty'], ['Pens', 4]]; };
</script>
<template>
<Sheet :options="options" style="height: 480px" @ready="onReady" @cells-changed="(e) => console.log(e.count)" />
</template>The component renders one div that fills its container, so give the container or the component a height.
optionsgoes tomountWorkbook:parts,chrome,theme,fileName,language,data,sheetsand every option in the API reference. It is watched deeply; after mount only the changed keys go towb.setOptions, with no remount.dataandsheetsact only at mount.- Events keep the workbook's names:
@cells-changed,@selection-changed,@before-sheet-remove, plus@readyand@error. Calle.cancel()in abefore-…handler to stop the action. Only the events you listen to are subscribed. - A template ref exposes
workbook,whenReady(),openFile(file)andsaveXlsx(sink).useSheet()andSHEET_EVENTSare exported too. - On unmount the workbook is destroyed, with its listeners and Worker.
- Nuxt: wrap it in
<ClientOnly>.
Vite
// vite.config.js
export default defineConfig({
plugins: [vue()],
worker: { format: 'es' },
optimizeDeps: { exclude: ['@8sheets/core', '@8sheets/vue'] },
});The Workers are ES modules. optimizeDeps.exclude is needed only before Vite 8: the older dependency pre-bundling moves the 8sheets modules away from their Workers, so files can't be opened or saved in vite dev. On Vite 8 you can leave it out.
Documentation
React, Vue and Angular, For developers and the API reference for everything on the workbook.
Licence
8sheets is commercial software, not open source. You may install it and try it for free, to evaluate it. Using it in a product, or deploying it for your users or your own staff, needs a licence from 8sheets.com/pricing: Internal 999 USD or SaaS / OEM 2,999 USD, each paid once per company and covering every developer and every deployment, or Enterprise, quoted. There is no licence key and nothing in the package checks for one. The terms are in LICENSE.md and, once you hold a licence, the 8sheets Source Licence.
