Enhance Excel export functionality in backend and frontend; implement Excel file generation and update download logic for correct file extension

This commit is contained in:
Torsten Schulz (local)
2025-10-18 00:03:11 +02:00
parent 6a519fc4d4
commit 6b89272335
5 changed files with 872 additions and 23 deletions

View File

@@ -34,7 +34,7 @@ class ExportController {
}
/**
* Exportiert Daten als Excel
* Exportiert Daten als Excel (.xlsx)
*/
async exportExcel(req, res) {
try {
@@ -47,11 +47,11 @@ class ExportController {
});
}
const excel = await ExportService.exportExcel(userId, startDate, endDate);
const buffer = await ExportService.exportExcel(userId, startDate, endDate);
res.setHeader('Content-Type', 'text/csv; charset=utf-8');
res.setHeader('Content-Disposition', `attachment; filename="zeiterfassung_${startDate}_${endDate}.csv"`);
res.send(excel);
res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
res.setHeader('Content-Disposition', `attachment; filename="zeiterfassung_${startDate}_${endDate}.xlsx"`);
res.send(buffer);
} catch (error) {
console.error('Fehler beim Excel-Export:', error);
res.status(500).json({