Compare commits
No commits in common. "4085cef2797ea41f08c06ea42d02cf5a534c0c05" and "0c1751fd096277b6e9512ae1123aea7864719a6d" have entirely different histories.
4085cef279
...
0c1751fd09
@ -9,7 +9,6 @@ import java.beans.PropertyDescriptor;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -23,25 +22,6 @@ import org.springframework.stereotype.Component;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ExcelUtil {
|
public class ExcelUtil {
|
||||||
|
|
||||||
// DecimalFormat 인스턴스를 미리 생성
|
|
||||||
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#,##0.000");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 숫자 포맷팅을 위한 헬퍼 메서드
|
|
||||||
*/
|
|
||||||
public static String formatNumber(Object amount, Object grossWt) {
|
|
||||||
try {
|
|
||||||
if (amount != null && grossWt != null) {
|
|
||||||
double amountValue = Double.parseDouble(amount.toString());
|
|
||||||
double grossWtValue = Double.parseDouble(grossWt.toString());
|
|
||||||
return DECIMAL_FORMAT.format(amountValue * grossWtValue);
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
log.warn("Number formatting error: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
return "0.000";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* jxls을 이용한 엑셀데이터 축출
|
* jxls을 이용한 엑셀데이터 축출
|
||||||
*
|
*
|
||||||
@ -74,11 +54,6 @@ public class ExcelUtil {
|
|||||||
context.putVar("data", map);
|
context.putVar("data", map);
|
||||||
context.putVar("list", list);
|
context.putVar("list", list);
|
||||||
|
|
||||||
// 포맷팅 함수를 컨텍스트에 추가
|
|
||||||
context.putVar("formatNumber", new FormatNumberFunction());
|
|
||||||
context.putVar("decimalFormat", DECIMAL_FORMAT);
|
|
||||||
|
|
||||||
|
|
||||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
JxlsHelper.getInstance().processTemplate(is, byteArrayOutputStream, context);
|
JxlsHelper.getInstance().processTemplate(is, byteArrayOutputStream, context);
|
||||||
|
|
||||||
@ -187,13 +162,4 @@ public class ExcelUtil {
|
|||||||
}
|
}
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* JXLS 템플릿에서 사용할 수 있는 포맷팅 함수 클래스
|
|
||||||
*/
|
|
||||||
public static class FormatNumberFunction {
|
|
||||||
public String format(Object amount, Object grossWt) {
|
|
||||||
return formatNumber(amount, grossWt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user