Skip to content

Commit d567789

Browse files
committed
Added create date on sheet
1 parent 65ea163 commit d567789

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/excel-generator.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,57 @@ class ExcelGenerator {
7171
console.log(`\t[WARN] Sheet name truncated: '${sheetDef.name}' → '${actualSheetName}'`);
7272
}
7373

74+
// 현재 날짜와 시간 생성
75+
const now = new Date();
76+
const creationDateTime = now.toLocaleString('ko-KR', {
77+
year: 'numeric',
78+
month: '2-digit',
79+
day: '2-digit',
80+
hour: '2-digit',
81+
minute: '2-digit',
82+
second: '2-digit',
83+
hour12: false
84+
});
85+
7486
if (recordCount > 0) {
7587
// 데이터와 스타일 적용 (1행부터 시작)
7688
excelStyleHelper.applySheetStyle(sheet, sheetDef.data, sheetDef.style, 1);
7789

78-
// 데이터 추가 후 맨 앞에 DB 정보 삽입
90+
// 데이터 추가 후 맨 앞에 정보 행들 삽입
7991
sheet.spliceRows(1, 0, [`📊 출처: ${sheetDef.dbKey} DB`]);
80-
sheet.spliceRows(2, 0, []); // 빈 행 추가
92+
sheet.spliceRows(2, 0, [`🕒 생성일시: ${creationDateTime}`]);
93+
sheet.spliceRows(3, 0, []); // 빈 행 추가
8194

8295
// DB 정보 셀 스타일링
8396
const dbCell = sheet.getCell('A1');
8497
dbCell.font = { bold: true, size: 11, color: { argb: 'FFFFFF' } };
8598
dbCell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: '366092' } };
8699

100+
// 생성일시 셀 스타일링
101+
const dateTimeCell = sheet.getCell('A2');
102+
dateTimeCell.font = { bold: true, size: 11, color: { argb: 'FFFFFF' } };
103+
dateTimeCell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: '4472C4' } };
104+
87105
console.log(`\t[DB정보] ${sheetDef.dbKey} DB 출처 표시 완료`);
106+
console.log(`\t[생성일시] ${creationDateTime} 표시 완료`);
88107
} else {
89108
// 데이터가 없는 경우
90109
sheet.addRow([`📊 출처: ${sheetDef.dbKey} DB`]);
110+
sheet.addRow([`🕒 생성일시: ${creationDateTime}`]);
91111
sheet.addRow([]);
92112
sheet.addRow(['데이터가 없습니다.']);
93113

94114
// 스타일링
95115
sheet.getCell('A1').font = { bold: true, size: 11, color: { argb: 'FFFFFF' } };
96116
sheet.getCell('A1').fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: '366092' } };
97-
sheet.getCell('A3').font = { italic: true, color: { argb: '999999' } };
117+
118+
sheet.getCell('A2').font = { bold: true, size: 11, color: { argb: 'FFFFFF' } };
119+
sheet.getCell('A2').fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: '4472C4' } };
120+
121+
sheet.getCell('A4').font = { italic: true, color: { argb: '999999' } };
98122

99123
console.log(`\t[DB정보] ${sheetDef.dbKey} DB 출처 표시 완료 (데이터 없음)`);
124+
console.log(`\t[생성일시] ${creationDateTime} 표시 완료 (데이터 없음)`);
100125
}
101126
console.log(`\t---> ${recordCount} rows were selected `);
102127
}

0 commit comments

Comments
 (0)