Skip to content

Commit

Permalink
Replace xlxs package with exceljs
Browse files Browse the repository at this point in the history
  • Loading branch information
Onitoxan committed Oct 9, 2024
1 parent 4c84148 commit 7e6068c
Show file tree
Hide file tree
Showing 3 changed files with 676 additions and 191 deletions.
10 changes: 5 additions & 5 deletions apps/hpc-ftsadmin/src/app/utils/download-excel.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// TODO: Check if this should be done on backend side, Currently not working properly
import * as XLSX from 'xlsx';
import { Workbook } from 'exceljs';
export const downloadExcel = <T>(
data: T[],
fileName: string
): Promise<void> => {
return new Promise((resolve, reject) => {
try {
const worksheet = XLSX.utils.json_to_sheet<T>(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
XLSX.writeFile(workbook, `${fileName}.xlsx`);
const workbook = new Workbook();
const worksheet = workbook.addWorksheet('Sheet1');
worksheet.addRows(data);
workbook.xlsx.writeFile(`${fileName}.xlsx`);
resolve();
} catch (error) {
reject(error);
Expand Down
Loading

0 comments on commit 7e6068c

Please sign in to comment.