@@ -236,6 +236,7 @@ async function loadQueriesFromXML(xmlPath) {
236236 maxRows : s . $ . maxRows ? parseInt ( s . $ . maxRows ) : null ,
237237 db : s . $ . db || null ,
238238 queryRef : s . $ . queryRef || null ,
239+ style : s . $ . style || null , // 시트별 스타일 추가
239240 query : query
240241 } ;
241242 } ) ;
@@ -441,16 +442,16 @@ async function main() {
441442 let createSeparateToc = false ; // 별도 목차 파일 생성 여부
442443 let globalMaxRows = null ; // 전역 최대 조회 건수
443444
444- // 스타일 템플릿 적용
445+ // 기본 스타일 템플릿 적용 (CLI 옵션)
445446 const selectedStyle = await getStyleById ( argv . style ) ;
446447 if ( selectedStyle ) {
447- console . log ( `🎨 적용된 스타일: ${ selectedStyle . name } (${ selectedStyle . description } )` ) ;
448+ console . log ( `🎨 CLI에서 지정된 스타일: ${ selectedStyle . name } (${ selectedStyle . description } )` ) ;
448449 excelStyle = {
449450 header : selectedStyle . header || { } ,
450451 body : selectedStyle . body || { }
451452 } ;
452453 } else {
453- console . warn ( `⚠️ 스타일 템플릿을 찾을 수 없습니다: ${ argv . style } ` ) ;
454+ console . warn ( `⚠️ CLI에서 지정된 스타일 템플릿을 찾을 수 없습니다: ${ argv . style } ` ) ;
454455 console . warn ( ` 💡 기본 스타일을 사용합니다.` ) ;
455456 }
456457
@@ -479,6 +480,20 @@ async function main() {
479480 if ( excel . $ && excel . $ . separateToc ) createSeparateToc = excel . $ . separateToc === 'true' ;
480481 // excel 엘리먼트의 maxRows 읽기
481482 if ( excel . $ && excel . $ . maxRows ) globalMaxRows = parseInt ( excel . $ . maxRows ) ;
483+ // XML에서 스타일 템플릿 ID 읽기 (CLI 옵션보다 우선)
484+ if ( excel . $ && excel . $ . style ) {
485+ const xmlStyleId = excel . $ . style ;
486+ const xmlStyle = await getStyleById ( xmlStyleId ) ;
487+ if ( xmlStyle ) {
488+ console . log ( `🎨 XML에서 지정된 스타일: ${ xmlStyle . name } (${ xmlStyle . description } )` ) ;
489+ excelStyle = {
490+ header : xmlStyle . header || { } ,
491+ body : xmlStyle . body || { }
492+ } ;
493+ } else {
494+ console . warn ( `⚠️ XML에서 지정된 스타일을 찾을 수 없습니다: ${ xmlStyleId } ` ) ;
495+ }
496+ }
482497
483498 // XML에서 스타일 속성이 있으면 템플릿 스타일을 덮어씀
484499 if ( excel . header && excel . header [ 0 ] ) {
@@ -650,8 +665,27 @@ async function main() {
650665 }
651666
652667 if ( recordCount > 0 ) {
668+ // 시트별 스타일 적용 (우선순위: 시트별 > XML 전역 > CLI > 기본)
669+ let sheetStyle = excelStyle ; // 기본값은 전역 스타일
670+
671+ if ( sheetDef . style ) {
672+ const sheetStyleTemplate = await getStyleById ( sheetDef . style ) ;
673+ if ( sheetStyleTemplate ) {
674+ console . log ( `\t🎨 시트별 스타일 적용: ${ sheetStyleTemplate . name } (${ sheetStyleTemplate . description } )` ) ;
675+ sheetStyle = {
676+ header : sheetStyleTemplate . header || { } ,
677+ body : sheetStyleTemplate . body || { }
678+ } ;
679+ } else {
680+ console . warn ( `\t⚠️ 시트별 스타일을 찾을 수 없습니다: ${ sheetDef . style } ` ) ;
681+ console . warn ( `\t 💡 전역 스타일을 사용합니다.` ) ;
682+ }
683+ } else {
684+ console . log ( `\t🎨 전역 스타일 적용: ${ excelStyle . header ?. font ?. name || '기본' } 스타일` ) ;
685+ }
686+
653687 // 데이터와 스타일 적용 (1행부터 시작)
654- excelStyleHelper . applySheetStyle ( sheet , result . recordset , excelStyle , 1 ) ;
688+ excelStyleHelper . applySheetStyle ( sheet , result . recordset , sheetStyle , 1 ) ;
655689
656690 // 데이터 추가 후 맨 앞에 DB 정보 행 삽입
657691 sheet . spliceRows ( 1 , 0 , [ `📊 출처: ${ sheetDbKey } DB` ] ) ;
0 commit comments