Skip to content

Commit 75ebbd3

Browse files
committed
fix: xls export
1 parent 6aa81d6 commit 75ebbd3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

functions/src/rest/export-data.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,13 @@ app.post('/**', authenticated(), (req, res) => {
167167
};
168168

169169
case Type.xls:
170+
const data = XLSX.utils.json_to_sheet(docs, {header: appliedColumns.map(({label}) => label)});
171+
const wb = XLSX.utils.book_new();
172+
XLSX.utils.book_append_sheet(wb, data, "Sheet1");
173+
const sheetBuffer = XLSX.write(wb, {bookType: "xlsx", type: "buffer"});
170174
return {
171-
data: XLSX.utils.json_to_sheet(docs),
172-
type:
173-
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
175+
data: sheetBuffer,
176+
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
174177
};
175178

176179
case Type.csv:

0 commit comments

Comments
 (0)