use of com.kyj.fx.voeditor.visual.framework.excel.IExcelDataSetHandler in project Gargoyle by callakrsos.
the class FxExcelUtil method drawHeader.
/**
* 헤더부분을 실제 엑셀에 처리하기 위한 코드.
* @작성자 : KYJ
* @작성일 : 2016. 9. 7.
* @param sheetConverter
* @param createSheet
* @param columnExpr
* @param startRow
* @throws Exception
*/
private static void drawHeader(IExcelDataSetHandler<Sheet, LinkedHashMap<ExcelColumnExpression, List<Object>>> sheetConverter, Sheet createSheet, ExcelColumnExpression columnExpr, final int maxLevel) throws Exception {
Cell createCell = sheetConverter.createCell(createSheet, columnExpr.getDisplayText(), (/*startRow +*/
columnExpr.getLevel()), START_COLUMN_INDEX + columnExpr.getIndex());
List<ExcelColumnExpression> childrens = columnExpr.getChildrens();
if (childrens != null && !childrens.isEmpty()) {
int horizontalSize = childrens.size();
for (ExcelColumnExpression subColumnExpr : childrens) {
if (subColumnExpr.isVisible()) {
drawHeader(sheetConverter, createSheet, subColumnExpr, maxLevel);
}
}
/* 셀병합. Horizontal Merge 부모 레벨.*/
{
int level = columnExpr.getParent() == null ? HEADER_ROW_INDEX : columnExpr.getParent().getLevel();
int index = columnExpr.getIndex() + START_COLUMN_INDEX;
CellRangeAddress cellMerge = cellMerge(createSheet, level, level, index, (index + horizontalSize - 1));
border(cellMerge, createSheet);
headerStyle(createCell);
}
} else {
/*셀병합. Vertical Merge*/
//case1 자식레벨은 없고 , 본인 레벨이 max 레벨이 낮은경우
int level = columnExpr.getLevel();
int index = columnExpr.getIndex() + START_COLUMN_INDEX;
if (level < maxLevel) {
CellRangeAddress cellMerge = cellMerge(createSheet, level, maxLevel, index, index);
// style(createCell, DEFAULT_HEADER_STYLE);
border(cellMerge, createSheet);
}
/* 현재 레벨.*/
{
headerStyle(createCell, style -> {
style.setBorderTop(CellStyle.BORDER_THIN);
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setBorderRight(CellStyle.BORDER_THIN);
style.setBorderBottom(CellStyle.BORDER_THIN);
});
//컬럼 width 지정.
width(createSheet, columnExpr, index);
}
}
}
Aggregations