|
|
|
@ -1,14 +1,11 @@
|
|
|
|
|
package cokr.xit.base.docs.hwp;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.IntStream;
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
|
|
import cokr.xit.foundation.Assert;
|
|
|
|
|
import cokr.xit.foundation.data.DataFormat;
|
|
|
|
|
import cokr.xit.foundation.data.DataObject;
|
|
|
|
|
import kr.dogfoot.hwplib.object.HWPFile;
|
|
|
|
@ -25,45 +22,63 @@ public class HWPTest {
|
|
|
|
|
@Test
|
|
|
|
|
void setValue() {
|
|
|
|
|
HWPFile file = HWPWriter.filepath(path("files\\hwp-test.hwp", false));
|
|
|
|
|
HWPWriter writer = new HWPWriter(file);
|
|
|
|
|
HWPWriter hwp = new HWPWriter(file);
|
|
|
|
|
|
|
|
|
|
String
|
|
|
|
|
userName = "이몽룡",
|
|
|
|
|
today = DataFormat.yyyy_mm_dd("20240312"),
|
|
|
|
|
|
|
|
|
|
name = "홍길동",
|
|
|
|
|
residentNo = "1234567890123",
|
|
|
|
|
address = "서울특별시 양천구";
|
|
|
|
|
|
|
|
|
|
int count = 20,
|
|
|
|
|
amt = 100000,
|
|
|
|
|
totalAmt = amt * count;
|
|
|
|
|
|
|
|
|
|
hwp.setValue("사용자", userName)
|
|
|
|
|
.setValue("출력일자", today)
|
|
|
|
|
|
|
|
|
|
.setValue("성명", name)
|
|
|
|
|
.setValue("주민번호", residentNo)
|
|
|
|
|
.setValue("주소", address)
|
|
|
|
|
.setValue("총건수", count)
|
|
|
|
|
.setValue("총금액", DataFormat.n_nn0(totalAmt));
|
|
|
|
|
/*
|
|
|
|
|
hwp.setValues(Map.of(
|
|
|
|
|
"사용자", userName,
|
|
|
|
|
"출력일자", today
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
TestObject tobj = new TestObject()
|
|
|
|
|
.setName("홍길동")
|
|
|
|
|
.setName(name)
|
|
|
|
|
.setResidentNo("123456780123")
|
|
|
|
|
.setAddress("서울특별시 양천구")
|
|
|
|
|
.setTotalCount(23)
|
|
|
|
|
.setTotalAmt(230000000);
|
|
|
|
|
writer.setValues(
|
|
|
|
|
.setAddress(address)
|
|
|
|
|
.setTotalCount(count)
|
|
|
|
|
.setTotalAmt(totalAmt);
|
|
|
|
|
|
|
|
|
|
hwp.setValues(
|
|
|
|
|
tobj,
|
|
|
|
|
Map.of(
|
|
|
|
|
"성명", TestObject::getName,
|
|
|
|
|
"주민번호", TestObject::getResidentNo,
|
|
|
|
|
"주소", TestObject::getAddress,
|
|
|
|
|
"총건수", TestObject::getTotalCount,
|
|
|
|
|
"총금액", TestObject::getTotalAmt
|
|
|
|
|
"총금액", (obj) -> DataFormat.n_nn0(obj.getTotalAmt())
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
writer
|
|
|
|
|
.setValues(Map.of(
|
|
|
|
|
"사용자", "이몽룡",
|
|
|
|
|
"출력일자", DataFormat.yyyy_mm_dd("20240312"),
|
|
|
|
|
|
|
|
|
|
"성명", "홍길동",
|
|
|
|
|
"주민번호", "1234567890123",
|
|
|
|
|
"주소", "서울특별시 양천구",
|
|
|
|
|
"총건수", 23,
|
|
|
|
|
"총금액", DataFormat.n_nn0(230000000)
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
List<DataObject> list = IntStream.range(0, 20).boxed().map(i ->
|
|
|
|
|
String
|
|
|
|
|
filepath1 = path("files\\4148020220006850A.jpg", false),
|
|
|
|
|
filepath2 = path("files\\4148020220006869A.jpg", false);
|
|
|
|
|
List<DataObject> list = IntStream.range(0, count).boxed().map(i ->
|
|
|
|
|
(DataObject)new DataObject()
|
|
|
|
|
.set("과태료", "과태료 " + i)
|
|
|
|
|
.set("단속일시", "단속일시 " + i)
|
|
|
|
|
.set("차량번호", "123가456" + (i % 10))
|
|
|
|
|
.set("고지번호", "고지번호 " + i)
|
|
|
|
|
.set("금액", "금액 " + i)
|
|
|
|
|
.set("금액", DataFormat.n_nn0(amt))
|
|
|
|
|
.set("가상계좌번호", "가상계좌번호 " + i)
|
|
|
|
|
.set("처리상태", "처리상태 " + i)
|
|
|
|
|
.set("처리일자", "처리일자 " + i)
|
|
|
|
@ -73,17 +88,13 @@ public class HWPTest {
|
|
|
|
|
.set("전자납부번호", "전자납부번호 " + i)
|
|
|
|
|
.set("납부기한", "납부기한 " + i)
|
|
|
|
|
.set("수납일자", "수납일자 " + i)
|
|
|
|
|
.set("단속사진", writer.image().add(path("files\\" + (i % 2 == 0 ? "4148020220006850A.jpg" : "4148020220006869A.jpg"), false)))
|
|
|
|
|
.set("단속사진", hwp.image().add(i % 2 == 0 ? filepath1 : filepath2))
|
|
|
|
|
).toList();
|
|
|
|
|
writer.table(2, 3, 4).setValues(list);
|
|
|
|
|
hwp.table(2, 3, 4).setValues(list);
|
|
|
|
|
//writer.header().setValue("abc");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try (FileOutputStream out = new FileOutputStream(path("files\\hwp-test-result.hwp", true))) {
|
|
|
|
|
writer.write(out);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw Assert.runtimeException(e);
|
|
|
|
|
}
|
|
|
|
|
hwp.write(path("files\\hwp-test-result.hwp", true));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static class TestObject {
|
|
|
|
|