|
|
|
@ -5,9 +5,14 @@ import java.io.OutputStream;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.BorderStyle;
|
|
|
|
|
import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
|
@ -438,7 +443,7 @@ public class XLSWriter extends XLS {
|
|
|
|
|
* @return 숫자 스타일(오른쪽 정렬, 천단위 구분)
|
|
|
|
|
*/
|
|
|
|
|
public CellStyle n_nn0() {
|
|
|
|
|
return cellStyle(new Styler().alignment(HorizontalAlignment.RIGHT).dataFormat("#,###"));
|
|
|
|
|
return cellStyle(new Styler().alignment(HorizontalAlignment.RIGHT).dataFormat("#,##0"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**숫자 스타일(오른쪽 정렬, 천단위 구분, 소수점 2자리 표기)을 반환한다.
|
|
|
|
@ -469,6 +474,19 @@ public class XLSWriter extends XLS {
|
|
|
|
|
return cellStyle(new Styler().dataFormat("HH:mm:ss").merge(Styler.CENTER));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Object> header(Iterable<CellDef> defs, Supplier<Styler> factory) {
|
|
|
|
|
ArrayList<Object> result = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (CellDef def: defs) {
|
|
|
|
|
result.add(def.label);
|
|
|
|
|
Styler styler = factory.get();
|
|
|
|
|
styler.width(def.width);
|
|
|
|
|
result.add(styler);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**셀스타일 정보. {@link #set(CellStyle) CellStyle을 설정}하는데 사용.
|
|
|
|
|
* @author mjkhan
|
|
|
|
|
*/
|
|
|
|
@ -791,4 +809,32 @@ public class XLSWriter extends XLS {
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author mjkhan
|
|
|
|
|
*/
|
|
|
|
|
public static class CellDef {
|
|
|
|
|
public static final Map<String, CellDef> toMap(CellDef... defs) {
|
|
|
|
|
return Stream.of(defs).collect(Collectors.toMap(
|
|
|
|
|
def -> def.label,
|
|
|
|
|
def -> def,
|
|
|
|
|
(k1, k2) -> k1,
|
|
|
|
|
LinkedHashMap::new
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String label;
|
|
|
|
|
private int width;
|
|
|
|
|
private Object value;
|
|
|
|
|
|
|
|
|
|
public CellDef(String label, int width, Object value) {
|
|
|
|
|
this.label = label;
|
|
|
|
|
this.width = width;
|
|
|
|
|
this.value = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Object getValue() {
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|