diff --git a/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java b/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java index ffd784c..acdeac2 100644 --- a/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java +++ b/src/main/java/cokr/xit/adds/nims/web/AddsNimsController.java @@ -24,6 +24,7 @@ import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.VerticalAlignment; import org.json.simple.JSONObject; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; @@ -988,17 +989,26 @@ public class AddsNimsController extends ApplicationController { CellDef.setValues(cellDefs, valueMap); + Style headerStyle = new Style().foregroundColor(HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex()) + .configure(styl -> { + styl.alignment(HorizontalAlignment.CENTER); + styl.alignment(VerticalAlignment.CENTER); + }); Style headerStyle2 = new Style().foregroundColor(HSSFColor.HSSFColorPredefined.GREY_50_PERCENT.getIndex()) .configure(styl -> { Font font = xlsx.workbook().createFont(); font.setColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex()); styl.alignment(HorizontalAlignment.CENTER); + styl.alignment(VerticalAlignment.CENTER); }); - xlsx.cell(0, 0).value("마약류 제품 구분별 현황").value(center).merge(0, cellDefs.size()-1); + xlsx.cell(0, 1).value("마약류 제품 구분별 현황").value(center).merge(1, cellDefs.size()-1); + // 관할관청 - rowspan + xlsx.cell(2, 0).value("관할관청").value(headerStyle).merge(2, 3, 0, 0); xlsx.cell(2, 1).value("마약/향정 구분(폐기건수 / 폐기수량)").value(headerStyle2).merge(1, 7); xlsx.cell(2, 8).value("중점/일반 구분(폐기건수 / 폐기수량)").value(headerStyle2).merge(8, 11); - xlsx.cell(3, 0).rowValues(CellDef.header(cellDefs, () -> StyleMaker.headerStyle(xlsx))); + List cellDefs2 = cellDefs.subList(1, cellDefs.size()); + xlsx.cell(3, 1).rowValues(CellDef.header(cellDefs2, () -> StyleMaker.headerStyle(xlsx))); xlsx.cell(4, 0).values(list, CellDef.values(cellDefs.stream().map(i -> {if(i.getValue() instanceof Format) {i.setField(null);}; return i;}).toList())); ModelAndView mav = new ModelAndView("downloadView"); @@ -1020,7 +1030,7 @@ public class AddsNimsController extends ApplicationController { List list = addsNimsService.getDsuseMgtDsuseQyByPrdStatistics(query); Map valueMap = new HashMap(); - valueMap.put("No.", format.of("ROW_NUM").style(center)); + valueMap.put("NO.", format.of("ROW_NUM").style(center)); valueMap.put("관할관청", format.of("dept_nm").style(center)); valueMap.put("제품코드", format.of("prduct_cd").style(center)); valueMap.put("제품명", format.of("prduct_nm").style(left)); @@ -1033,17 +1043,31 @@ public class AddsNimsController extends ApplicationController { CellDef.setValues(cellDefs, valueMap); + Style headerStyle = new Style().foregroundColor(HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex()) + .configure(styl -> { + styl.alignment(HorizontalAlignment.CENTER); + styl.alignment(VerticalAlignment.CENTER); + }); + Style headerStyle2 = new Style().foregroundColor(HSSFColor.HSSFColorPredefined.GREY_50_PERCENT.getIndex()) .configure(styl -> { Font font = xlsx.workbook().createFont(); font.setColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex()); styl.alignment(HorizontalAlignment.CENTER); + styl.alignment(VerticalAlignment.CENTER); }); xlsx.cell(0, 0).value("마약류 제품별 폐기 현황").value(center).merge(0, cellDefs.size()-1); - xlsx.cell(2, 1).value("마약/향정 구분").value(headerStyle2).merge(1, 7); - xlsx.cell(2, 8).value("중점/일반 구분").value(headerStyle2).merge(8, 11); - xlsx.cell(3, 0).rowValues(CellDef.header(cellDefs, () -> StyleMaker.headerStyle(xlsx))); + // rowspan + xlsx.cell(2, 0).value("NO.").value(headerStyle).merge(2, 3, 0, 0); + xlsx.cell(2, 1).value("관할관청").value(headerStyle).merge(2, 3, 1, 1); + xlsx.cell(2, 2).value("제품코드").value(headerStyle).merge(2, 3, 2, 2); + xlsx.cell(2, 3).value("제품명").value(headerStyle).merge(2, 3, 3, 3); + xlsx.cell(2, 4).value("처리상태 별 (폐기건수 / 폐기수량)").value(headerStyle2).merge(4, 7); + xlsx.cell(2, 8).value("폐기건수").value(headerStyle).merge(2, 3, 8, 8); + xlsx.cell(2, 9).value("폐기수량").value(headerStyle).merge(2, 3, 9, 9); + List cellDefs2 = cellDefs.subList(4, cellDefs.size()-2); + xlsx.cell(3, 4).rowValues(CellDef.header(cellDefs2, () -> StyleMaker.headerStyle(xlsx))); xlsx.cell(4, 0).values(list, CellDef.values(cellDefs.stream().map(i -> {if(i.getValue() instanceof Format) {i.setField(null);}; return i;}).toList())); ModelAndView mav = new ModelAndView("downloadView"); diff --git a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtDsuseQyByPrdStatistics-main.jsp b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtDsuseQyByPrdStatistics-main.jsp index 1ee1736..b4e6cf8 100644 --- a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtDsuseQyByPrdStatistics-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtDsuseQyByPrdStatistics-main.jsp @@ -303,8 +303,8 @@ // 끝에서 2개의 th 요소 선택 let lastColNames = $(`#theadTr0--${pageName} th`).not("[colspan]").slice(-2); - $P.control.query.cellDefs = getCellDefs2( - [...firstColNames, ...middleColNames, ...lastColNames], + $P.control.query.cellDefs = getCellDefs( + $([...firstColNames, ...middleColNames, ...lastColNames]), $($("#${infoPrefix}Row--${pageName}")[0].content).find("td") .not(".dummy-td").not(":eq(0)").not("[colspan]") ); @@ -383,43 +383,35 @@ $P.fnReset(); }); -function getCellDefs2(ths, $tds, fieldGetterOption){ - let cellDefs = []; - - for(let i=0; i < ths.length; i++){ - - let label = $(ths[i]).text(); - label = label.replace("\n", ""); - label = label.replace("\t", ""); - label = label.replace(" ", ""); - - if(label !== ""){ - - let width = $(ths[i]).outerWidth(); - width = Math.ceil(width/10) + 2; - - let field = ""; - if(fieldGetterOption != null){ - field = fieldGetterOption($tds.eq(i)); - } else { - field = $tds.eq(i).text(); - } - - field = field.replace("{", ""); - field = field.replace("}", ""); - field = field.replace("\n", ""); - field = field.replace("\t", ""); - field = field.replace(" ", ""); - - cellDefs.push({ - label : label, - width : width, - field : field - }); - } - - } - - return JSON.stringify(cellDefs); -} +// function getCellDefs2(ths, $tds, fieldGetterOption){ +// let cellDefs = []; +// +// ths.forEach((th, idx) => { +// let label = $(ths).text(); +// label = label.replace("\n", ""); +// label = label.replace("\t", ""); +// label = label.replace(" ", ""); +// +// if(label !== ""){ +// let field = ""; +// if(fieldGetterOption != null){ +// field = fieldGetterOption($tds.eq(idx)); +// } else { +// field = $tds.eq(idx).text(); +// } +// field = field.replace("{", ""); +// field = field.replace("}", ""); +// field = field.replace("\n", ""); +// field = field.replace("\t", ""); +// field = field.replace(" ", ""); +// +// cellDefs.push({ +// label : label, +// width : Math.ceil($(ths).outerWidth()/10) + 2, +// field : field +// }); +// } +// }); +// return JSON.stringify(cellDefs); +// }