Search in sources :

Example 1 with IExcelDataSetHandler

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);
        }
    }
}
Also used : ClientAnchor(org.apache.poi.ss.usermodel.ClientAnchor) Drawing(org.apache.poi.ss.usermodel.Drawing) ByteArrayOutputStream(java.io.ByteArrayOutputStream) URL(java.net.URL) ITableColumnForExcel(com.kyj.fx.voeditor.visual.framework.excel.ITableColumnForExcel) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) XSSFFont(org.apache.poi.xssf.usermodel.XSSFFont) TableColumn(javafx.scene.control.TableColumn) LinkedHashMap(java.util.LinkedHashMap) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Map(java.util.Map) Cell(org.apache.poi.ss.usermodel.Cell) Picture(org.apache.poi.ss.usermodel.Picture) XSSFColor(org.apache.poi.xssf.usermodel.XSSFColor) TableView(javafx.scene.control.TableView) GargoyleException(com.kyj.fx.voeditor.visual.exceptions.GargoyleException) IExcelScreenHandler(com.kyj.fx.voeditor.visual.framework.excel.IExcelScreenHandler) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) Sheet(org.apache.poi.ss.usermodel.Sheet) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Predicate(java.util.function.Predicate) DefautExcelDataSetHandler(com.kyj.fx.voeditor.visual.framework.excel.DefautExcelDataSetHandler) AnchorType(org.apache.poi.ss.usermodel.ClientAnchor.AnchorType) FileOutputStream(java.io.FileOutputStream) Set(java.util.Set) IOException(java.io.IOException) IExcelDataSetHandler(com.kyj.fx.voeditor.visual.framework.excel.IExcelDataSetHandler) XSSFCellStyle(org.apache.poi.xssf.usermodel.XSSFCellStyle) File(java.io.File) Consumer(java.util.function.Consumer) List(java.util.List) Workbook(org.apache.poi.ss.usermodel.Workbook) ExcelColumnExpression(com.kyj.fx.voeditor.visual.framework.excel.ExcelColumnExpression) CreationHelper(org.apache.poi.ss.usermodel.CreationHelper) ObservableList(javafx.collections.ObservableList) CellStyle(org.apache.poi.ss.usermodel.CellStyle) RegionUtil(org.apache.poi.ss.util.RegionUtil) InputStream(java.io.InputStream) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) Cell(org.apache.poi.ss.usermodel.Cell) ExcelColumnExpression(com.kyj.fx.voeditor.visual.framework.excel.ExcelColumnExpression)

Aggregations

GargoyleException (com.kyj.fx.voeditor.visual.exceptions.GargoyleException)1 DefautExcelDataSetHandler (com.kyj.fx.voeditor.visual.framework.excel.DefautExcelDataSetHandler)1 ExcelColumnExpression (com.kyj.fx.voeditor.visual.framework.excel.ExcelColumnExpression)1 IExcelDataSetHandler (com.kyj.fx.voeditor.visual.framework.excel.IExcelDataSetHandler)1 IExcelScreenHandler (com.kyj.fx.voeditor.visual.framework.excel.IExcelScreenHandler)1 ITableColumnForExcel (com.kyj.fx.voeditor.visual.framework.excel.ITableColumnForExcel)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Consumer (java.util.function.Consumer)1