From 75ebbd3741347ebcc06355a207b1a9ddfd24d114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Malo=C4=8Da?= Date: Tue, 25 Jun 2024 10:22:18 +0200 Subject: [PATCH] fix: xls export --- functions/src/rest/export-data.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/functions/src/rest/export-data.ts b/functions/src/rest/export-data.ts index 320a02fb..e5669450 100644 --- a/functions/src/rest/export-data.ts +++ b/functions/src/rest/export-data.ts @@ -167,10 +167,13 @@ app.post('/**', authenticated(), (req, res) => { }; case Type.xls: + const data = XLSX.utils.json_to_sheet(docs, {header: appliedColumns.map(({label}) => label)}); + const wb = XLSX.utils.book_new(); + XLSX.utils.book_append_sheet(wb, data, "Sheet1"); + const sheetBuffer = XLSX.write(wb, {bookType: "xlsx", type: "buffer"}); return { - data: XLSX.utils.json_to_sheet(docs), - type: - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' + data: sheetBuffer, + type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }; case Type.csv: