엑셀 다운로드 수정

main
mjkhan21 11 months ago
parent 49fc0d657a
commit f61ad60c84

@ -477,4 +477,14 @@ public class CmmnUtil {
return result; return result;
} }
public static XLSWriter.Styler headerStyle(XLSWriter xlsx) {
return new XLSWriter.Styler()
.foregroundColor(HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex())
.configure(styler -> {
Font font = xlsx.workbook().createFont();
font.setColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
styler.font(font);
styler.alignment(HorizontalAlignment.CENTER);
});
}
} }

@ -1,17 +1,12 @@
package cokr.xit.fims.crdn.web; package cokr.xit.fims.crdn.web;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Supplier;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
@ -23,6 +18,7 @@ import cokr.xit.base.file.xls.XLSWriter.Styler;
import cokr.xit.base.user.ManagedUser; import cokr.xit.base.user.ManagedUser;
import cokr.xit.base.user.dao.UserMapper; import cokr.xit.base.user.dao.UserMapper;
import cokr.xit.base.web.ApplicationController; import cokr.xit.base.web.ApplicationController;
import cokr.xit.fims.cmmn.CmmnUtil;
import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.Crdn;
import cokr.xit.fims.crdn.CrdnQuery; import cokr.xit.fims.crdn.CrdnQuery;
import cokr.xit.fims.crdn.dao.GlobalStngMapper; import cokr.xit.fims.crdn.dao.GlobalStngMapper;
@ -100,41 +96,30 @@ public class Crdn06Controller extends ApplicationController {
.setFilename("단속자료 목록.xlsx") .setFilename("단속자료 목록.xlsx")
.worksheet(0); .worksheet(0);
Supplier<Styler> defaultHeader = () -> new XLSWriter.Styler()
.foregroundColor(HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex())
.configure(styler -> {
Font font = xlsx.workbook().createFont();
font.setColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
styler.font(font);
styler.alignment(HorizontalAlignment.CENTER);
});
CellStyle center = xlsx.cellStyle(Styler.CENTER); CellStyle center = xlsx.cellStyle(Styler.CENTER);
CellStyle numeric = xlsx.n_nn0();
CellStyle dateYMD = xlsx.yyyy_mm_dd(); CellStyle dateYMD = xlsx.yyyy_mm_dd();
CellStyle dateDT = xlsx.yyyy_mm_dd_hh_mm_ss(); CellStyle dateDT = xlsx.yyyy_mm_dd_hh_mm_ss();
List<DataObject> list = crdnService.getCrackdownList(query.setFetchSize(0)); List<DataObject> list = crdnService.getCrackdownList(query.setFetchSize(0));
Map<String, Object> valueMap = new HashMap<String, Object>();
valueMap.put("자료출처", xlsx.style("CRDN_INPT_SE_NM", center)); CellDef.setValues(
valueMap.put("차량번호", "VHRNO"); cellDefs,
valueMap.put("위반일시", xlsx.format(o -> xlsx.str2datetime(o.get("CRDN_YMD_TM"))).style(dateDT)); Map.of(
valueMap.put("단속장소", "CRDN_PLC"); "자료출처", xlsx.style("CRDN_INPT_SE_NM", center),
valueMap.put("체납액", "ATCH_FILE_CNT"); "위반일시", xlsx.format(o -> xlsx.str2datetime(o.get("CRDN_YMD_TM"))).style(dateDT),
valueMap.put("사진건수", xlsx.style("ATCH_FILE_CNT", center)); "사진건수", xlsx.style("ATCH_FILE_CNT", center),
valueMap.put("스티커번호", "CRDN_SN"); "장애차량확인", xlsx.style("PARKNG_PSBLTY_RSLT_NM", center),
valueMap.put("장애차량확인", xlsx.style("PARKNG_PSBLTY_RSLT_NM", center)); "처리상태", xlsx.style("CRDN_STTS_NM", center),
valueMap.put("처리상태", xlsx.style("CRDN_STTS_NM", center)); "제외사유", xlsx.style("LEVY_EXCL_RSN_NM", center),
valueMap.put("제외사유", xlsx.style("LEVY_EXCL_RSN_NM", center)); "제외처리일자", xlsx.format(o -> xlsx.str2date(o.get("LEVY_EXCL_YMD"))).style(dateYMD)
valueMap.put("제외처리일자", xlsx.format(o -> xlsx.str2date(o.get("LEVY_EXCL_YMD"))).style(dateYMD)); )
valueMap.put("제외내역", "LEVY_EXCL_ETC_CN"); );
CellDef.setValues(cellDefs, valueMap);
xlsx.cell(0, 0) xlsx.cell(0, 0)
.value("단속자료 목록", center) .value("단속자료 목록", center)
.merge(0, cellDefs.size()-1) .merge(0, cellDefs.size()-1)
.cell(3, 0) .cell(3, 0)
.rowValues(CellDef.header(cellDefs, defaultHeader)) .rowValues(CellDef.header(cellDefs, () -> CmmnUtil.headerStyle(xlsx)))
.cell(4, 0) .cell(4, 0)
.values(list, CellDef.values(cellDefs)); .values(list, CellDef.values(cellDefs));

Loading…
Cancel
Save