Export Excel .xlsx
To export JSON as a native Excel workbook, set the type prop to "xlsx". Unlike the default xls type, Excel opens these files without a format warning.
.xlsx files also support cell formats and column widths.
Ask AI about this page
To export JSON as a native Excel workbook, set the type prop to "xlsx". Unlike the default xls type, Excel opens these files without a format warning.
<script setup>
import JsonExcel from 'vue-json-excel3'
const jsonFields = {
'Complete name': 'name',
City: 'city',
Telephone: 'phone.mobile',
'Telephone 2': {
field: 'phone.landline',
callback: (value) => `Landline Phone - ${value}`,
},
}
const jsonData = [
{
name: 'Tony Peña',
city: 'New York',
country: 'United States',
birthdate: '1978-03-15',
phone: { mobile: '1-541-754-3010', landline: '(541) 754-3010' },
},
{
name: 'Thessaloniki',
city: 'Athens',
country: 'Greece',
birthdate: '1987-11-23',
phone: { mobile: '+1 855 275 5071', landline: '(2741) 2621-244' },
},
]
</script>
<template>
<JsonExcel
class="btn"
:data="jsonData"
:fields="jsonFields"
type="xlsx"
worksheet="My Worksheet"
name="filename.xlsx"
>
Download Excel (.xlsx)
</JsonExcel>
</template>
.xlsx files also support cell formats and column widths.