Skip to content

Getting Started ​

Installation ​

bash
npm install vue-json-excel3
bash
pnpm add vue-json-excel3
bash
yarn add vue-json-excel3
bash
bun add vue-json-excel3

vue (version 3) is the only peer dependency.

Register the component ​

Locally ​

Import it in the component that needs it:

MyComponent.vue
vue
<script setup>
import JsonExcel from 'vue-json-excel3'
</script>

Globally ​

Or register it once in your app entry point:

main.js
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 ​

Released under the MIT License.