json to xlsx
// Import XLSX CDN
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.min.js"
integrity="sha512-WaHZ16+n6qSSVxDii8MZGmFlnro3iZdJa/hb1XKraoMx1/HVILhLdAX22ypk4lT/8+t4XMYcjzCDwfvZ1CAJgw=="
crossorigin="anonymous"
referrerpolicy="no-referrer">
</script>
// File Saver
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.0/FileSaver.min.js"
integrity="sha512-csNcFYJniKjJxRWRV1R7fvnXrycHP6qDR21mgz1ZP55xY5d+aHLfo9/FcGDQLfn2IfngbAHd8LdfsagcCqgTcQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
/////
const worksheet = XLSX.utils.json_to_sheet(data);
const EXCEL_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
const workbook = {
Sheets: {
'data': worksheet
},
SheetNames: ['data']
};
const buffer = XLSX.write(wokbook, { bookType: 'xlsx', type: 'array' });
const file = new Blob([buffer], { type: EXCEL_TYPE });
saveAs(file, 'example.xslx');