Skip to content

Commit 3f89684

Browse files
committed
링크 오류 수정
1 parent 1d2c4a0 commit 3f89684

File tree

2 files changed

+37
-28
lines changed

2 files changed

+37
-28
lines changed

src/excel-style-helper.js

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,41 @@ function populateTableOfContents(tocSheet, sheetNames) {
393393
}
394394
}
395395

396-
// 데이터 건수 스타일링
396+
// 데이터 건수 스타일링 및 하이퍼링크
397397
const recordCountCell = row.getCell(3);
398+
const recordCountText = (obj.recordCount || 0).toString();
399+
400+
// 데이터 건수에도 하이퍼링크 적용
401+
const recordCountFormula = `HYPERLINK("#'${sheetNameForLink}'!A1","${recordCountText}")`;
402+
403+
try {
404+
recordCountCell.value = { formula: recordCountFormula };
405+
recordCountCell.font = {
406+
color: { argb: '0563C1' },
407+
underline: true
408+
};
409+
} catch (error) {
410+
// HYPERLINK 함수 실패 시 직접 하이퍼링크 방식 시도
411+
try {
412+
recordCountCell.value = {
413+
text: recordCountText,
414+
hyperlink: `#'${sheetNameForLink}'!A1`
415+
};
416+
recordCountCell.font = {
417+
color: { argb: '0563C1' },
418+
underline: true
419+
};
420+
} catch (error2) {
421+
// 모든 방법 실패 시 일반 텍스트로 표시
422+
recordCountCell.value = obj.recordCount || 0;
423+
recordCountCell.font = {
424+
color: obj.recordCount > 0 ? { argb: '2F5597' } : { argb: '999999' }
425+
};
426+
}
427+
}
428+
398429
recordCountCell.numFmt = '#,##0'; // 천 단위 구분자
399430
recordCountCell.alignment = { horizontal: 'right' };
400-
recordCountCell.font = {
401-
color: obj.recordCount > 0 ? { argb: '2F5597' } : { argb: '999999' }
402-
};
403431

404432
// 비고 컬럼 스타일링
405433
if (isTruncated) {

src/index.js

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -331,32 +331,13 @@ async function main() {
331331

332332
// 목차 시트에 내용 채우기
333333
if (createdSheetNames.length > 0 && tocSheet) {
334-
// 이미 생성된 목차 시트에 내용 추가
335-
tocSheet.addRow(['No', 'Sheet Name', 'Data Count']);
336-
createdSheetNames.forEach((obj, idx) => {
337-
const row = tocSheet.addRow([idx + 1, obj.displayName, createdSheetCounts[idx]]);
338-
// 시트명에 하이퍼링크 추가 (실제 탭 이름 기준)
339-
row.getCell(2).value = {
340-
text: obj.displayName,
341-
hyperlink: `#'${obj.tabName}'!A1`
342-
};
343-
row.getCell(2).font = { color: { argb: '0563C1' }, underline: true };
344-
// 데이터 건수에도 하이퍼링크 추가
345-
row.getCell(3).value = {
346-
text: createdSheetCounts[idx].toString(),
347-
hyperlink: `#'${obj.tabName}'!A1`
348-
};
349-
row.getCell(3).font = { color: { argb: '0563C1' }, underline: true };
350-
});
334+
// excel-style-helper 모듈의 함수 사용하여 안전한 목차 생성
335+
excelStyleHelper.populateTableOfContents(tocSheet, createdSheetNames);
336+
351337
// 목차 시트를 첫 번째로 이동
352338
workbook.worksheets = [tocSheet, ...workbook.worksheets.filter(ws => ws.name !== '목차')];
353-
// 간단한 스타일
354-
tocSheet.getRow(1).font = { bold: true };
355-
tocSheet.columns = [
356-
{ header: 'No', key: 'no', width: 6 },
357-
{ header: 'Sheet Name', key: 'name', width: 30 },
358-
{ header: 'Data Count', key: 'count', width: 12 }
359-
];
339+
340+
console.log(`[목차] 내용 채우기 완료 (총 ${createdSheetNames.length}개 시트)`);
360341

361342
if (createSeparateToc) {
362343
// 별도 목차 엑셀 파일 생성

0 commit comments

Comments
 (0)