From 0797299b5e311ac3e6aa63cc4ebe88bc7555a30e Mon Sep 17 00:00:00 2001 From: leebj Date: Thu, 5 Sep 2024 16:49:41 +0900 Subject: [PATCH] =?UTF-8?q?=EC=97=91=EC=85=80=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=86=8C=EC=8A=A4=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cokr/xit/fims/cmmn/xls/FormatMaker.java | 68 +++++++++++++++++++ .../cokr/xit/fims/cmmn/xls/StyleMaker.java | 24 +++++++ 2 files changed, 92 insertions(+) create mode 100644 src/main/java/cokr/xit/fims/cmmn/xls/FormatMaker.java create mode 100644 src/main/java/cokr/xit/fims/cmmn/xls/StyleMaker.java diff --git a/src/main/java/cokr/xit/fims/cmmn/xls/FormatMaker.java b/src/main/java/cokr/xit/fims/cmmn/xls/FormatMaker.java new file mode 100644 index 00000000..4e272d98 --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/xls/FormatMaker.java @@ -0,0 +1,68 @@ +package cokr.xit.fims.cmmn.xls; + +import java.io.File; +import java.util.Map; + +import org.apache.poi.hssf.util.HSSFColor; + +import cokr.xit.base.docs.xls.Comment; +import cokr.xit.base.docs.xls.Format; +import cokr.xit.base.docs.xls.Style; +import cokr.xit.foundation.data.DataFormat; + +public class FormatMaker { + + @SuppressWarnings("rawtypes") + public static Format photoCellForApproval(Format format, Comment comment, String key) { + return format.of(key) + .value(obj -> { + if(((Map)obj).get(key) == null) { + return "없음"; + } + String value = (String)((Map)obj).get(key); + if(value.equals("")) { + return "없음"; + } + if(!(new File(value)).exists()) { + return "이미지 경로 존재하지 않음"; + } + if((new File(value)).length() == 0) { + return "이미지 크기 오류"; + } + if((new File(value)).length() > (1024 * 1024 * 3)){ + return "사진크기(3MB)초과"; + } + return " "; + }) + .onCell(obj -> { + if(((Map)obj).get(key) == null) { return; } + String value = (String)((Map)obj).get(key); + if(value.equals("")) { return; } + if(!(new File(value)).exists()) { return; } + if((new File(value)).length() == 0) { return; } + if((new File(value)).length() > (1024 * 1024 * 3)){ return; } + + comment.setImageComment((String)((Map)obj).get(key)); + }) + .style(new Style().foregroundColor(HSSFColor.HSSFColorPredefined.YELLOW.getIndex())); + } + + + @SuppressWarnings("rawtypes") + public static Format yyyy_mm_dd_hh_mm_ss(Format format, String key) { + return format.of(key).value(o -> { + return DataFormat.yyyy_mm_dd_hh_mm_ss(((Map) o).get(key)); + }); + } + + + @SuppressWarnings("rawtypes") + public static Format yyyy_mm_dd(Format format, String key) { + return format.of(key).value(o -> { + return DataFormat.yyyy_mm_dd(((Map) o).get(key)); + }); + } + + + +} diff --git a/src/main/java/cokr/xit/fims/cmmn/xls/StyleMaker.java b/src/main/java/cokr/xit/fims/cmmn/xls/StyleMaker.java new file mode 100644 index 00000000..ad7bd1d4 --- /dev/null +++ b/src/main/java/cokr/xit/fims/cmmn/xls/StyleMaker.java @@ -0,0 +1,24 @@ +package cokr.xit.fims.cmmn.xls; + +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.HorizontalAlignment; + +import cokr.xit.base.docs.xls.Style; +import cokr.xit.base.docs.xls.XLSWriter; + + +public class StyleMaker { + + public static Style headerStyle(XLSWriter xlsx) { + return new Style() + .foregroundColor(HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex()) + .configure(styl -> { + Font font = xlsx.workbook().createFont(); + font.setColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex()); + styl.font(font); + styl.alignment(HorizontalAlignment.CENTER); + }); + } + +}