Skip to content

Commit

Permalink
feat: 첫 번째 행 필드명 불러와 반환
Browse files Browse the repository at this point in the history
  • Loading branch information
w8385 committed Apr 16, 2024
1 parent 38a7d06 commit 6643e78
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/group/group.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,19 @@ export class GroupService {
await workbook.xlsx.load(excel.buffer);

const worksheet = workbook.getWorksheet(1);

const columns = [];
worksheet.getRow(1).eachCell((cell) => {
columns.push(cell.value);
});

const data = [];
worksheet.eachRow((row, rowNumber) => {
if (rowNumber !== 1) {
const rowObject = {};
row.eachCell((cell, colNumber) => {
rowObject[`column${colNumber}`] = cell.value;
const col = columns[colNumber - 1];
rowObject[col] = cell.value;
});
data.push(rowObject);
}
Expand Down

0 comments on commit 6643e78

Please sign in to comment.