Getting Started
Installation
bash
npm install vue-json-excel3bash
pnpm add vue-json-excel3bash
yarn add vue-json-excel3bash
bun add vue-json-excel3vue (version 3) is the only peer dependency.
Register the component
Locally
Import it in the component that needs it:
vue
<script setup>
import JsonExcel from 'vue-json-excel3'
</script>Globally
Or register it once in your app entry point:
js
import { createApp } from 'vue'
import JsonExcel from 'vue-json-excel3'
import App from './App.vue'
const app = createApp(App)
app.component('downloadExcel', JsonExcel)
app.mount('#app')Use it in your template
Wrap any content — text, an icon, your own button — and pass the data to export. Clicking it downloads the file.
html
<download-excel :data="json_data">
Download Data
<img src="download_icon.png" />
</download-excel>Set type to xlsx or csv to change the file format, and use fields to choose and label the columns. Every option is listed on the Props page.
About the .xls format
The default xls type uses an HTML table to build the file. Microsoft Excel no longer recognises HTML as native content, so it shows a warning before opening the file. The content renders correctly, but the message can't be avoided — use type="xlsx" to get a native workbook without the warning.
Next steps
Simple exampleChoose fields, label columns and download an .xls file.Export CSVSwitch the type prop to csv and get a comma-separated file.Export .xlsxNative Excel workbooks with no "file format" warning.Multi-line valuesLine breaks inside a single cell.Using callbacksFormat values, fetch data on demand and show a loader.Cell formats & widthsCurrency, percentage and number formats, plus column widths.