From c41590f080ffd696e8654be40e3ad92964438f08 Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Fri, 19 Apr 2024 14:25:46 +0900 Subject: [PATCH] =?UTF-8?q?getDownloadable()=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cokr/xit/base/docs/hwp/HWPWriter.java | 11 +++++++++++ src/main/java/cokr/xit/base/docs/xls/XLSWriter.java | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/main/java/cokr/xit/base/docs/hwp/HWPWriter.java b/src/main/java/cokr/xit/base/docs/hwp/HWPWriter.java index 0cb4982..432fcea 100644 --- a/src/main/java/cokr/xit/base/docs/hwp/HWPWriter.java +++ b/src/main/java/cokr/xit/base/docs/hwp/HWPWriter.java @@ -10,6 +10,7 @@ import java.util.function.Function; import java.util.stream.Collectors; import cokr.xit.foundation.Assert; +import cokr.xit.foundation.Downloadable; import kr.dogfoot.hwplib.object.HWPFile; import kr.dogfoot.hwplib.object.bodytext.control.Control; import kr.dogfoot.hwplib.object.bodytext.control.ControlField; @@ -176,4 +177,14 @@ public class HWPWriter extends HWP { throw Assert.runtimeException(e); } } + + /**현재 HWPWriter를 Downloadable로 변환한다. + * 결과로 받은 Downloadable은 파일이름을 지정해야 한다. + * @return Downloadable + */ + public Downloadable getDownloadable() { + return new Downloadable() + .setContentType(MIME_TYPE) + .setWriter(this::write); + } } \ No newline at end of file diff --git a/src/main/java/cokr/xit/base/docs/xls/XLSWriter.java b/src/main/java/cokr/xit/base/docs/xls/XLSWriter.java index ad009ea..c3aa71c 100644 --- a/src/main/java/cokr/xit/base/docs/xls/XLSWriter.java +++ b/src/main/java/cokr/xit/base/docs/xls/XLSWriter.java @@ -15,6 +15,8 @@ import java.util.stream.IntStream; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.util.CellRangeAddress; +import cokr.xit.foundation.Downloadable; + /**엑셀 파일 작성 클래스 * @author mjkhan */ @@ -346,4 +348,14 @@ public class XLSWriter extends XLS { super.clear(all); trackWidths = null; } + + /**현재 XLSWriter를 Downloadable로 변환한다. + * 결과로 받은 Downloadable은 파일이름을 지정해야 한다. + * @return Downloadable + */ + public Downloadable getDownloadable() { + return new Downloadable() + .setContentType(MIME_TYPE) + .setWriter(this::write); + } } \ No newline at end of file