From d107833350abf9d640ade5d97567ecf73d38e458 Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Tue, 12 Dec 2023 13:32:38 +0900 Subject: [PATCH] =?UTF-8?q?merge(...)=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cokr/xit/base/file/xls/XLSWriter.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/java/cokr/xit/base/file/xls/XLSWriter.java b/src/main/java/cokr/xit/base/file/xls/XLSWriter.java index d2d1da9..558b336 100644 --- a/src/main/java/cokr/xit/base/file/xls/XLSWriter.java +++ b/src/main/java/cokr/xit/base/file/xls/XLSWriter.java @@ -15,6 +15,7 @@ import org.apache.poi.ss.usermodel.FillPatternType; import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.streaming.SXSSFCell; import org.apache.poi.xssf.streaming.SXSSFRow; import org.apache.poi.xssf.streaming.SXSSFSheet; @@ -156,6 +157,28 @@ public class XLSWriter extends XLS { return row(row).col(col); } + /**지정한 범위의 셀들을 병합한다. + * @param firstRow 시작행 인덱스 + * @param lastRow 끝행 인덱스 + * @param firstCol 시작열 인덱스 + * @param lastCol 끝열 인덱스 + * @return 현재 XLSWriter + */ + public XLSWriter merge(int firstRow, int lastRow, int firstCol, int lastCol) { + worksheet.addMergedRegion(new CellRangeAddress(firstRow, lastRow, firstCol, lastCol)); + return this; + } + + /**현재 행의 지정한 열의 셀들을 병합한다. + * @param firstCol 시작열 인덱스 + * @param lastCol 끝열 인덱스 + * @return 현재 XLSWriter + */ + public XLSWriter merge(int firstCol, int lastCol) { + int index = row.getRowNum(); + return merge(index, index, firstCol, lastCol); + } + /**지정한 값을 현재 작업셀에 설정하고 스타일을 적용한다. * @param val 설정값 * @param style 적용할 스타일(CellStyle, Styler, 또는 KeyStyle)