let getExcel2 = function (data) { //Todo: 컴퍼넌트. 주석 삭제하지 말자 let sheet_title = ""; let file_name = ""; if (data) { //let dateTime = new DateTime().format("Ymdhis"); sheet_title = "반입지시"; file_name = sheet_title + ".xlsx"; } else { sheet_title = "반입지시양식"; file_name = sheet_title + ".xlsx"; } const work_Book = new ExcelJS.Workbook(); const work_Sheet = work_Book.addWorksheet(sheet_title); const all_border = { top: { style: "thin", color: { argb: "FF000000" } }, left: { style: "thin", color: { argb: "FF000000" } }, bottom: { style: "thin", color: { argb: "FF000000" } }, right: { style: "thin", color: { argb: "FF000000" } }, }; const field_css = { yellow: { border: all_border, font: { color: { argb: "FF9C5700" }, bold: true }, alignment: { vertical: "middle", horizontal: "center" }, fill: { type: "pattern", pattern: "solid", fgColor: { argb: "FFFFEB9C" }, }, }, green: { border: all_border, font: { color: { argb: "FF006100" }, bold: true }, alignment: { vertical: "middle", horizontal: "center" }, fill: { type: "pattern", pattern: "solid", fgColor: { argb: "FFC6EFCE" }, }, }, red: { border: all_border, font: { color: { argb: "FF9C0006" }, bold: true }, alignment: { vertical: "middle", horizontal: "center" }, fill: { type: "pattern", pattern: "solid", fgColor: { argb: "FFFFC7CE" }, }, }, blue: { border: all_border, font: { font: { size: 11 }, color: { argb: "0E3979" }, bold: true }, alignment: { vertical: "middle", horizontal: "center" }, fill: { type: "pattern", pattern: "solid", fgColor: { argb: "EAEFF3" }, } }, title: { font: { size: 15, bold: true }, alignment: { vertical: "middle", horizontal: "center" }, }, box: { border: all_border, alignment: { vertical: "middle", horizontal: "center" }, font: { size: 11 }, }, }; let ws_row1 = work_Sheet.getRow(1); ws_row1.height = 32; ws_row1.getCell(1).value = "반입지시"; ws_row1.getCell(1).style = field_css.title work_Sheet.mergeCells('A1:U1'); let ws_row = work_Sheet.getRow(3); ws_row.height = 25; ws_row.getCell(1).style = field_css.blue; ws_row.getCell(1).value = "NO."; ws_row.getCell(2).style = field_css.blue; ws_row.getCell(2).value = "화주"; ws_row.getCell(3).style = field_css.blue; ws_row.getCell(3).value = "선사"; ws_row.getCell(4).style = field_css.blue; ws_row.getCell(4).value = "부킹 NO"; ws_row.getCell(5).style = field_css.blue; ws_row.getCell(5).value = "반출지"; ws_row.getCell(6).style = field_css.blue; ws_row.getCell(6).value = "반입지"; ws_row.getCell(7).style = field_css.blue; ws_row.getCell(7).value = "반입지 모선"; ws_row.getCell(8).style = field_css.blue; ws_row.getCell(8).value = "항차"; ws_row.getCell(9).style = field_css.blue; ws_row.getCell(9).value = "컨테이너번호"; ws_row.getCell(10).style = field_css.blue; ws_row.getCell(10).value = "적재유무"; ws_row.getCell(11).style = field_css.blue; ws_row.getCell(11).value = "컨.규격"; ws_row.getCell(12).style = field_css.blue; ws_row.getCell(12).value = "SEAL NO"; ws_row.getCell(13).style = field_css.blue; ws_row.getCell(13).value = "중량"; ws_row.getCell(14).style = field_css.blue; ws_row.getCell(14).value = "POD"; ws_row.getCell(15).style = field_css.blue; ws_row.getCell(15).value = "IMDG"; ws_row.getCell(16).style = field_css.blue; ws_row.getCell(16).value = "접안일"; ws_row.getCell(17).style = field_css.blue; ws_row.getCell(17).value = "차량정보"; ws_row.getCell(18).style = field_css.blue; ws_row.getCell(18).value = "반입차량연락처"; ws_row.getCell(19).style = field_css.blue; ws_row.getCell(19).value = "입고일"; ws_row.getCell(20).style = field_css.blue; ws_row.getCell(20).value = "비고"; ws_row.getCell(21).style = field_css.blue; ws_row.getCell(21).value = "요청사항"; work_Sheet.columns = [ { width: 9 }, { width: 15 }, { width: 15 }, { width: 18 }, { width: 11 }, { width: 11 }, { width: 11 }, { width: 11 }, { width: 15 }, { width: 18 }, { width: 11 }, { width: 13 }, { width: 11 }, { width: 13 }, { width: 15 }, { width: 23 }, { width: 15 }, { width: 20 }, { width: 18 }, { width: 25 }, { width: 25 }, ]; // //첫번째 숫자, 옆에 박스부분 채워놓는 부분 // for (let i = 0; i < data.length; i++) { // let row = work_Sheet.getRow(i + 4); // row.height = 22; // let numCell = row.getCell(1); // numCell.value = i + 1; // numCell.style = field_css.blue; // //박스 // for (let j = 2; j < 18; j++) { // let cell = row.getCell(j); // cell.style = field_css.box; // } // } // 데이터가 있으면 박스안에 데이터 들어가는 곳 if (data) { for (let i = 0; i < data.length; i++) { let ws_row = work_Sheet.getRow(i + 4); ws_row.height = 22; // 높이 설정 ws_row.getCell(2).value = data[i]["BP_NM"] || ''; ws_row.getCell(3).value = data[i]["LINER_CD"] || ''; ws_row.getCell(4).value = data[i]["BK_NO"] || ''; ws_row.getCell(5).value = data[i]["ARR_CD"] || ''; ws_row.getCell(6).value = data[i]["DEP_NM"] || ''; ws_row.getCell(7).value = data[i]["VES_CD"] || ''; ws_row.getCell(8).value = data[i]["VES_VOY"] || ''; ws_row.getCell(9).value = data[i]["CONTR_NO"] || ''; ws_row.getCell(10).value = data[i]["CONTR_LOAD_STS"] || ''; ws_row.getCell(11).value = data[i]["CONTR_SIZE_TYPE"] || ''; ws_row.getCell(12).value = data[i]["SEAL_NO"] || ''; ws_row.getCell(13).value = data[i]["CARGO_WT"] || ''; ws_row.getCell(14).value = data[i]["DEP_NM"] || ''; ws_row.getCell(15).value = data[i][""] || ''; ws_row.getCell(16).value = data[i]["CSDHPPRARNDE"] || ''; ws_row.getCell(17).value = data[i]["IN_VEH_NO"] || ''; ws_row.getCell(18).value = data[i]["IN_DRV_TEL_NO"] || ''; ws_row.getCell(19).value = data[i]["IN_DT"] || ''; ws_row.getCell(20).value = data[i]["REMK"] || ''; ws_row.getCell(21).value = data[i]["REQUEST"] || ''; ws_row.getCell(1).value = i + 1; ws_row.getCell(1).style = field_css.blue; for (let j = 2; j <= 21; j++) { ws_row.getCell(j).style = field_css.box; } } } work_Book.xlsx.writeBuffer().then((data) => { const blob = new Blob([data], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", }); const url = window.URL.createObjectURL(blob); const anchor = document.createElement("a"); anchor.href = url; anchor.download = file_name; anchor.click(); window.URL.revokeObjectURL(url); }); }