Example usage for org.apache.poi.hssf.usermodel HSSFCellStyle setDataFormat

List of usage examples for org.apache.poi.hssf.usermodel HSSFCellStyle setDataFormat

Introduction

In this page you can find the example usage for org.apache.poi.hssf.usermodel HSSFCellStyle setDataFormat.

Prototype

@Override
public void setDataFormat(short fmt) 

Source Link

Document

set the data format (must be a valid format)

Usage

From source file:ro.nextreports.engine.exporter.XlsExporter.java

License:Apache License

private HSSFCellStyle buildBandElementStyle(BandElement bandElement, Object value, int gridRow, int gridColumn,
        int colSpan) {
    Map<String, Object> style = buildCellStyleMap(bandElement, value, gridRow, gridColumn, colSpan);
    HSSFCellStyle cellStyle;
    HSSFFont cellFont = null;/*from w  ww  .  j  a  v  a2s  .  c o m*/
    int fontKey = -1;
    // we have to create new fonts and styles if some formatting conditions are met  
    // also for subreports we may have a subreportCellStyle passed by ReportBandElement 
    boolean cacheFont = false;
    boolean cacheAllFont = false;
    if ((modifiedStyle[gridRow][gridColumn]) || bean.isSubreport()) {
        fontKey = getFontKey(style);
        if (fontKey != -1) {
            cellFont = condFonts.get(fontKey);
        }
        cellStyle = wb.createCellStyle();
        if (cellFont == null) {
            cellFont = wb.createFont();
            cacheFont = true;
        }
        modifiedStyle[gridRow][gridColumn] = false;
    } else {
        cellStyle = styles[gridRow][gridColumn];
        fontKey = getFontKey(style);
        if (fontKey != -1) {
            cellFont = fonts.get(fontKey);
        }
        if ((cellFont == null) && (bandElement != null)) {
            cellFont = wb.createFont();
            cacheAllFont = true;
        }
    }

    // HSSFPalette cellPal = wb.getCustomPalette();        
    if (style.containsKey(StyleFormatConstants.FONT_FAMILY_KEY)) {
        String val = (String) style.get(StyleFormatConstants.FONT_FAMILY_KEY);
        cellFont.setFontName(val);
    }
    if (style.containsKey(StyleFormatConstants.FONT_SIZE)) {
        Float val = (Float) style.get(StyleFormatConstants.FONT_SIZE);
        cellFont.setFontHeightInPoints(val.shortValue());
    }
    if (style.containsKey(StyleFormatConstants.FONT_COLOR)) {
        Color val = (Color) style.get(StyleFormatConstants.FONT_COLOR);
        cellFont.setColor(ExcelColorSupport.getNearestColor(val));
    }
    if (style.containsKey(StyleFormatConstants.FONT_STYLE_KEY)) {
        if (StyleFormatConstants.FONT_STYLE_NORMAL.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) {
            cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
        }
        if (StyleFormatConstants.FONT_STYLE_BOLD.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) {
            cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        }
        if (StyleFormatConstants.FONT_STYLE_ITALIC.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) {
            cellFont.setItalic(true);
        }
        if (StyleFormatConstants.FONT_STYLE_BOLDITALIC.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) {
            cellFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
            cellFont.setItalic(true);
        }
    }

    if (cacheFont && (fontKey != -1)) {
        condFonts.put(fontKey, cellFont);
    }
    if (cacheAllFont && (fontKey != -1)) {
        fonts.put(fontKey, cellFont);
    }
    if (style.containsKey(StyleFormatConstants.BACKGROUND_COLOR)) {
        Color val = (Color) style.get(StyleFormatConstants.BACKGROUND_COLOR);
        cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
        cellStyle.setFillForegroundColor(ExcelColorSupport.getNearestColor(val));
    }
    if (style.containsKey(StyleFormatConstants.HORIZONTAL_ALIGN_KEY)) {
        if (StyleFormatConstants.HORIZONTAL_ALIGN_LEFT
                .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
            cellStyle.setAlignment((short) 1);
        }
        if (StyleFormatConstants.HORIZONTAL_ALIGN_RIGHT
                .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
            cellStyle.setAlignment((short) 3);
        }
        if (StyleFormatConstants.HORIZONTAL_ALIGN_CENTER
                .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
            cellStyle.setAlignment((short) 2);
        }
    }

    if (style.containsKey(StyleFormatConstants.VERTICAL_ALIGN_KEY)) {
        if (StyleFormatConstants.VERTICAL_ALIGN_TOP
                .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
            cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_TOP);
        }
        if (StyleFormatConstants.VERTICAL_ALIGN_MIDDLE
                .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
            cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
        }
        if (StyleFormatConstants.VERTICAL_ALIGN_BOTTOM
                .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
            cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_BOTTOM);
        }
    } else {
        cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    }

    short left = 0, right = 0, top = 0, bottom = 0;
    Color leftColor = Color.BLACK, rightColor = Color.BLACK, topColor = Color.BLACK, bottomColor = Color.BLACK;
    if (style.containsKey(StyleFormatConstants.BORDER_LEFT)) {
        Float val = (Float) style.get(StyleFormatConstants.BORDER_LEFT);
        //
        left = val.shortValue();
        if (left == BORDER_THIN_VALUE) {
            cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
        }
        if (left == BORDER_MEDIUM_VALUE) {
            cellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
        }
        if (left == BORDER_THICK_VALUE) {
            cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THICK);
        }

        Color color = (Color) style.get(StyleFormatConstants.BORDER_LEFT_COLOR);
        leftColor = color;
        cellStyle.setLeftBorderColor(ExcelColorSupport.getNearestColor(color));
    }
    if (style.containsKey(StyleFormatConstants.BORDER_RIGHT)) {
        Float val = (Float) style.get(StyleFormatConstants.BORDER_RIGHT);
        //
        right = val.shortValue();
        if (right == BORDER_THIN_VALUE) {
            cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
        }
        if (right == BORDER_MEDIUM_VALUE) {
            cellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
        }
        if (right == BORDER_THICK_VALUE) {
            cellStyle.setBorderRight(HSSFCellStyle.BORDER_THICK);
        }
        Color color = (Color) style.get(StyleFormatConstants.BORDER_RIGHT_COLOR);
        rightColor = color;
        cellStyle.setRightBorderColor(ExcelColorSupport.getNearestColor(color));
    }
    if (style.containsKey(StyleFormatConstants.BORDER_TOP)) {
        Float val = (Float) style.get(StyleFormatConstants.BORDER_TOP);
        //
        top = val.shortValue();
        if (top == BORDER_THIN_VALUE) {
            cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
        }
        if (top == BORDER_MEDIUM_VALUE) {
            cellStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
        }
        if (top == BORDER_THICK_VALUE) {
            cellStyle.setBorderTop(HSSFCellStyle.BORDER_THICK);
        }
        Color color = (Color) style.get(StyleFormatConstants.BORDER_TOP_COLOR);
        topColor = color;
        cellStyle.setTopBorderColor(ExcelColorSupport.getNearestColor(color));
    }
    if (style.containsKey(StyleFormatConstants.BORDER_BOTTOM)) {
        Float val = (Float) style.get(StyleFormatConstants.BORDER_BOTTOM);
        //
        bottom = val.shortValue();
        if (bottom == BORDER_THIN_VALUE) {
            cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        }
        if (bottom == BORDER_MEDIUM_VALUE) {
            cellStyle.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
        }
        if (bottom == BORDER_THICK_VALUE) {
            cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THICK);
        }
        Color color = (Color) style.get(StyleFormatConstants.BORDER_BOTTOM_COLOR);
        bottomColor = color;
        cellStyle.setBottomBorderColor(ExcelColorSupport.getNearestColor(color));
    }
    border = new Border(left, right, top, bottom);
    border.setLeftColor(leftColor);
    border.setRightColor(rightColor);
    border.setTopColor(topColor);
    border.setBottomColor(bottomColor);

    if (cellFont != null) {
        cellStyle.setFont(cellFont);
    }

    if (style.containsKey(StyleFormatConstants.PATTERN)) {
        String pattern = (String) style.get(StyleFormatConstants.PATTERN);
        HSSFDataFormat format = wb.createDataFormat();
        cellStyle.setDataFormat(format.getFormat(pattern));
    }

    if (bandElement != null) {
        cellStyle.setWrapText(bandElement.isWrapText());
    }

    cellStyle = updateSubreportBandElementStyle(cellStyle, bandElement, value, gridRow, gridColumn, colSpan);

    return cellStyle;
}

From source file:ro.nextreports.engine.exporter.XlsExporter.java

License:Apache License

private void renderCell(BandElement bandElement, String bandName, Object value, int gridRow, int sheetRow,
        int sheetColumn, int rowSpan, int colSpan, boolean image) {

    if (bandElement instanceof ReportBandElement) {
        colSpan = 1;//from  ww w.j  av  a2  s . co  m
    }
    HSSFCellStyle cellStyle = buildBandElementStyle(bandElement, value, gridRow, sheetColumn, colSpan);

    // if we have a subreport on the current grid row we have to take care of the sheetColumn
    if (ReportLayout.HEADER_BAND_NAME.equals(bandName) && (gridRow == prevSubreportFirstRow)
            && (prevSubreportLastColumn != -1)) {
        sheetColumn = prevSubreportLastColumn - prevSubreportFirstColumn - 1 + sheetColumn;
    }
    HSSFCell c = xlsRow.createCell(sheetColumn);

    if (image) {
        if ((value == null) || "".equals(value)) {
            c.setCellType(HSSFCell.CELL_TYPE_STRING);
            c.setCellValue(new HSSFRichTextString(IMAGE_NOT_FOUND));
        } else {
            try {
                ImageBandElement ibe = (ImageBandElement) bandElement;
                byte[] imageBytes = getImage((String) value, ibe.getWidth(), ibe.getHeight());
                HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) sheetColumn, sheetRow,
                        (short) (sheetColumn + colSpan), (sheetRow + rowSpan));
                int index = wb.addPicture(imageBytes, HSSFWorkbook.PICTURE_TYPE_JPEG);

                // image is created over the cells, so if it's height is bigger we set the row height
                short height = xlsRow.getHeight();
                int realImageHeight = getRealImageSize((String) value)[1];
                if (ibe.isScaled()) {
                    realImageHeight = ibe.getHeight();
                }
                short imageHeight = (short) (realImageHeight * POINTS_FOR_PIXEL / 2.5);
                if (imageHeight > height) {
                    xlsRow.setHeight(imageHeight);
                }

                HSSFPicture picture = patriarch.createPicture(anchor, index);
                picture.resize();
                anchor.setAnchorType(2);
            } catch (Exception ex) {
                c.setCellType(HSSFCell.CELL_TYPE_STRING);
                c.setCellValue(new HSSFRichTextString(IMAGE_NOT_LOADED));
            }
        }

        if (cellStyle != null) {
            c.setCellStyle(cellStyle);
        }

    } else {
        if (bandElement instanceof HyperlinkBandElement) {
            Hyperlink hyp = ((HyperlinkBandElement) bandElement).getHyperlink();
            HSSFHyperlink link = new HSSFHyperlink(HSSFHyperlink.LINK_URL);
            link.setAddress(hyp.getUrl());
            c.setHyperlink(link);
            c.setCellValue(new HSSFRichTextString(hyp.getText()));
            c.setCellType(HSSFCell.CELL_TYPE_STRING);
        } else if (bandElement instanceof ReportBandElement) {
            Report report = ((ReportBandElement) bandElement).getReport();
            ExporterBean eb = null;
            try {
                eb = getSubreportExporterBean(report, true);
                XlsExporter subExporter = new XlsExporter(eb, cellStyle);
                subExporter.export();
                HSSFSheet subreportSheet = subExporter.getSubreportSheet();

                if (ReportLayout.HEADER_BAND_NAME.equals(bandName) && (gridRow == prevSubreportFirstRow)) {
                    // other subreports on the same header line after the first
                    sheetColumn = prevSubreportLastColumn;
                    sheetRow -= addedPageRows;
                    pageRow -= addedPageRows;
                    addedPageRows = 0;
                } else {
                    addedPageRows = subreportSheet.getLastRowNum();
                    pageRow += addedPageRows;
                    // if subreport is not on the first column we merge all cells in the columns before, between the rows subreport occupies
                    if (sheetColumn > 0) {
                        for (int i = 0; i <= sheetColumn - 1; i++) {
                            CellRangeAddress cra = new CellRangeAddress(sheetRow, pageRow, i, i);
                            regions.add(new XlsRegion(cra, null));
                        }
                    }
                }
                int cols = XlsUtil.copyToSheet(xlsSheet, sheetRow, sheetColumn, subreportSheet);
                addRegions(xlsSheet, subExporter.getSubreportRegions(), wb);
                if (ReportLayout.HEADER_BAND_NAME.equals(bandName)) {
                    prevSubreportFirstRow = gridRow;
                    prevSubreportFirstColumn = sheetColumn;
                    prevSubreportLastColumn = sheetColumn + cols;
                }
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if ((eb != null) && (eb.getResult() != null)) {
                    eb.getResult().close();
                }
            }
        } else if (bandElement instanceof ImageColumnBandElement) {
            try {
                ImageColumnBandElement icbe = (ImageColumnBandElement) bandElement;
                String v = StringUtil.getValueAsString(value, null);
                if (StringUtil.BLOB.equals(v)) {
                    c.setCellType(HSSFCell.CELL_TYPE_STRING);
                    c.setCellValue(new HSSFRichTextString(StringUtil.BLOB));
                } else {
                    byte[] imageD = StringUtil.decodeImage(v);
                    byte[] imageBytes = getImage(imageD, icbe.getWidth(), icbe.getHeight());
                    HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) sheetColumn, sheetRow,
                            (short) (sheetColumn + colSpan), (sheetRow + rowSpan));
                    int index = wb.addPicture(imageBytes, HSSFWorkbook.PICTURE_TYPE_JPEG);

                    // image is created over the cells, so if it's height is bigger we set the row height
                    short height = xlsRow.getHeight();
                    int realImageHeight = getRealImageSize(imageBytes)[1];
                    if (icbe.isScaled()) {
                        realImageHeight = icbe.getHeight();
                    }
                    short imageHeight = (short) (realImageHeight * POINTS_FOR_PIXEL / 2.5);
                    if (imageHeight > height) {
                        xlsRow.setHeight(imageHeight);
                    }

                    HSSFPicture picture = patriarch.createPicture(anchor, index);
                    picture.resize();
                    anchor.setAnchorType(2);
                }
            } catch (Exception e) {
                e.printStackTrace();
                c.setCellType(HSSFCell.CELL_TYPE_STRING);
                c.setCellValue(new HSSFRichTextString(IMAGE_NOT_LOADED));
            }

        } else {

            if (value == null) {
                c.setCellType(HSSFCell.CELL_TYPE_STRING);
                c.setCellValue(new HSSFRichTextString(""));
            } else if (value instanceof Number) {
                c.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                c.setCellValue(((Number) value).doubleValue());
            } else {
                String pattern = null;
                if (bandElement instanceof FieldBandElement) {
                    FieldBandElement fbe = (FieldBandElement) bandElement;
                    pattern = fbe.getPattern();
                }
                if ((value instanceof java.sql.Date) || (value instanceof java.sql.Timestamp)) {
                    Date date;
                    if (value instanceof java.sql.Date) {
                        date = new Date(((java.sql.Date) value).getTime());
                    } else {
                        date = (java.sql.Timestamp) value;
                    }
                    if (cellStyle != null) {
                        if (pattern == null) {
                            // use default pattern if none selected
                            Locale locale = Locale.getDefault();
                            pattern = ((SimpleDateFormat) DateFormat.getDateInstance(SimpleDateFormat.MEDIUM,
                                    locale)).toPattern();
                        } else {
                            pattern = StringUtil.getI18nString(pattern, getReportLanguage());
                        }
                        cellStyle.setDataFormat(wb.createDataFormat().getFormat(pattern));
                    }
                    c.setCellValue(date);
                } else {
                    c.setCellType(HSSFCell.CELL_TYPE_STRING);
                    String text = StringUtil.getValueAsString(value, pattern);
                    if ((bandElement != null) && bandElement.isWrapText()) {
                        // try to interpret new line characters
                        // \\n is used here to be possible to add in designer grid cell with \n
                        if (text.contains("\\n") || text.contains("\n") || text.contains("\r")
                                || text.contains("\r\n")) {
                            String crLf = Character.toString((char) 13) + Character.toString((char) 10);
                            int lines = countLines(text);
                            if (text.contains("\r\n")) {
                                text = text.replaceAll("\r\n", crLf);
                            } else {
                                text = text.replaceAll("(\n)|(\r)|(\\\\n)", crLf);
                            }
                            c.setCellValue(text);
                            cellStyle.setWrapText(true);
                            xlsRow.setHeightInPoints(
                                    lines * (cellStyle.getFont(wb).getFontHeightInPoints() + 3));
                        } else {
                            c.setCellValue(new HSSFRichTextString(text));
                        }
                    } else {
                        c.setCellValue(new HSSFRichTextString(text));
                    }

                }
            }
        }

        if (cellStyle != null) {
            if (bandElement != null) {
                cellStyle.setRotation(bandElement.getTextRotation());
            }
            if (!(bandElement instanceof ReportBandElement)) {
                c.setCellStyle(cellStyle);
            }
        }

        if ((rowSpan > 1) || (colSpan > 1)) {
            CellRangeAddress cra = new CellRangeAddress(sheetRow, sheetRow + rowSpan - 1, sheetColumn,
                    sheetColumn + colSpan - 1);
            Border beBorder = bandElement.getBorder();
            if (hasRowRenderConditions(bandElement, gridRow, value)) {
                // for row render conditions we must keep the row border
                beBorder = border;
            }
            regions.add(new XlsRegion(cra, beBorder));
        }

    }
}

From source file:teamdash.wbs.excel.StyleKey.java

License:Open Source License

public void configure(HSSFCellStyle style) {
    if (indent > 0)
        style.setIndention(indent);/*  w  w  w .  j  a v a  2s .  c om*/
    if (format > 0)
        style.setDataFormat(format);
}

From source file:ua.com.ecotep.unianalysis.export.XLSDataExport.java

@Override
public void exportData(String selectedFile, AnProperties props,
        ObservableList<ObservableList<Object>> exportData, List<String> columnTitles) throws Exception {
    if (selectedFile == null) {
        return;//  ww  w .ja va2s . co m
    }
    System.setProperty("java.awt.headless", "true");
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("Sheet1");
    HSSFPrintSetup ps = sheet.getPrintSetup();
    ps.setPaperSize(HSSFPrintSetup.A4_PAPERSIZE);
    ps.setLandscape(true);

    HSSFCellStyle cellStyleT = wb.createCellStyle();
    HSSFFont font1 = wb.createFont();
    font1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    font1.setFontHeightInPoints((short) 8);
    cellStyleT.setFont(font1);

    int rnumber = 0;
    HSSFRow row = sheet.createRow(0);
    sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 10));
    HSSFCell cell = row.createCell(0);

    cell.setCellValue(
            new HSSFRichTextString(" ???  ???  - "
                    + DateConverters.getDateToStr(LocalDate.now())));
    cell.setCellStyle(cellStyleT);
    rnumber++;

    if (props != null) {

        String val = " :  " + DateConverters.getDateToStr(props.getDateFrom())
                + "  " + DateConverters.getDateToStr(props.getDateTo());
        createHeaderCell(sheet, rnumber, val, cellStyleT);
        rnumber++;
        //----------
        if (props.isSalMode()) {
            String type = props.getSalSalerType() == AnProperties.SALER_TYPES.PROFILE
                    ? " "
                    : "  ";
            val = "? " + type + "| " + props.getSaler().getNameSaler();
            createHeaderCell(sheet, rnumber, val, cellStyleT);
            rnumber++;
            if (props.getSalSalerType() == AnProperties.SALER_TYPES.SALER) {
                type = props.isSalDirectSales() ? "? "
                        : " ";
                val = " : " + type;
                createHeaderCell(sheet, rnumber, val, cellStyleT);
                rnumber++;
                if (props.isSalFixedDepartment()) {
                    val = " : ";
                    createHeaderCell(sheet, rnumber, val, cellStyleT);
                    rnumber++;
                }

            }
        }
        if (props.isGoodMode()) {
            if (props.getGoodClassLev0() != null) {
                val = "? 1: " + props.getGoodClassLev0().getName();
                createHeaderCell(sheet, rnumber, val, cellStyleT);
                rnumber++;
                if (props.getGoodClassLev1() != null) {
                    val = "? 2: " + props.getGoodClassLev1().getName();
                    createHeaderCell(sheet, rnumber, val, cellStyleT);
                    rnumber++;
                    if (props.getGoodClassLev2() != null) {
                        val = "? 3: " + props.getGoodClassLev2().getName();
                        createHeaderCell(sheet, rnumber, val, cellStyleT);
                        rnumber++;
                        if (props.getGoodClassLev3() != null) {
                            val = "? 4: " + props.getGoodClassLev3().getName();
                            createHeaderCell(sheet, rnumber, val, cellStyleT);
                            rnumber++;
                        }
                    }
                }

                if (props.getGoodCustomSearch() != null && !props.getGoodCustomSearch().isEmpty()) {
                    val = " : " + props.getGoodCustomSearch();
                    createHeaderCell(sheet, rnumber, val, cellStyleT);
                    rnumber++;
                }

                if (props.isGoodPeriodAnalysis() && props.getGoodsIndateLst().size() == 2) {
                    val = " : " + DateConverters.getDateToStr(props.getGoodsIndateLst().get(0));
                    createHeaderCell(sheet, rnumber, val, cellStyleT);
                    rnumber++;
                    val = " : "
                            + DateConverters.getDateToStr(props.getGoodsIndateLst().get(1));
                    createHeaderCell(sheet, rnumber, val, cellStyleT);
                    rnumber++;
                }
                if (!props.isGoodPeriodAnalysis() && props.getGoodsIndateLst().size() > 0) {
                    val = "+: ";
                    for (LocalDate ld : props.getGoodsIndateLst()) {
                        val += DateConverters.getDateToStr(ld) + "; ";
                    }
                    createHeaderCell(sheet, rnumber, val, cellStyleT);
                    rnumber++;
                }

            }

        }

        if (!props.getClLst().isEmpty()) {
            if (props.isClIncluded()) {
                val = " : ";
                createHeaderCell(sheet, rnumber, val, cellStyleT);
                rnumber++;
            } else {
                val = " : ";
                createHeaderCell(sheet, rnumber, val, cellStyleT);
                rnumber++;
            }

            val = "+: ";
            for (ClientBean cb : props.getClLst()) {
                val += cb.getClientCl() + "; ";
            }
            createHeaderCell(sheet, rnumber, val, cellStyleT);
            rnumber++;
        }

        if (!props.getVLst().isEmpty()) {
            if (props.isVIncluded()) {
                val = " : ";
                createHeaderCell(sheet, rnumber, val, cellStyleT);
                rnumber++;
            } else {
                val = " : ";
                createHeaderCell(sheet, rnumber, val, cellStyleT);
                rnumber++;
            }
            val = "";
            for (String v : props.getVLst()) {
                val += v + "; ";
            }
            createHeaderCell(sheet, rnumber, val, cellStyleT);
            rnumber++;
        }
    }
    //----------                                    

    HSSFCellStyle cellStyleH = wb.createCellStyle();
    HSSFFont font = wb.createFont();
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    cellStyleH.setFont(font);
    cellStyleH.setWrapText(true);
    cellStyleH.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    cellStyleH.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);

    cellStyleH.setBorderLeft((short) 1);
    cellStyleH.setBorderRight((short) 1);
    cellStyleH.setBorderTop((short) 1);
    cellStyleH.setBorderBottom((short) 1);

    HSSFCellStyle cellStyleHh = wb.createCellStyle();
    font = wb.createFont();
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    cellStyleHh.setFont(font);
    cellStyleHh.setWrapText(true);
    cellStyleHh.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
    cellStyleHh.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);

    cellStyleHh.setBorderLeft((short) 1);
    cellStyleHh.setBorderRight((short) 1);
    cellStyleHh.setBorderTop((short) 1);
    cellStyleHh.setBorderBottom((short) 1);

    //filling table
    HSSFCellStyle cellStyleN = wb.createCellStyle();
    cellStyleN.setAlignment(HSSFCellStyle.ALIGN_LEFT);
    cellStyleN.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
    cellStyleN.setBorderLeft((short) 1);
    cellStyleN.setBorderRight((short) 1);
    cellStyleN.setBorderTop((short) 1);
    cellStyleN.setBorderBottom((short) 1);

    HSSFCellStyle cellStyleI = wb.createCellStyle();
    cellStyleI.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    cellStyleI.setVerticalAlignment(HSSFCellStyle.ALIGN_CENTER);
    cellStyleI.setBorderLeft((short) 1);
    cellStyleI.setBorderRight((short) 1);
    cellStyleI.setBorderTop((short) 1);
    cellStyleI.setBorderBottom((short) 1);

    HSSFCellStyle cellStyleD = wb.createCellStyle();
    cellStyleD.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
    cellStyleD.setVerticalAlignment(HSSFCellStyle.ALIGN_RIGHT);
    HSSFDataFormat df = wb.createDataFormat();
    cellStyleD.setDataFormat(df.getFormat("#,##0.0"));
    cellStyleD.setBorderLeft((short) 1);
    cellStyleD.setBorderRight((short) 1);
    cellStyleD.setBorderTop((short) 1);
    cellStyleD.setBorderBottom((short) 1);

    HSSFCellStyle cellStyleP = wb.createCellStyle();
    cellStyleP.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
    cellStyleP.setVerticalAlignment(HSSFCellStyle.ALIGN_RIGHT);

    cellStyleP.setDataFormat(df.getFormat("0.0\\%"));
    cellStyleP.setBorderLeft((short) 1);
    cellStyleP.setBorderRight((short) 1);
    cellStyleP.setBorderTop((short) 1);
    cellStyleP.setBorderBottom((short) 1);

    // filling column headers
    row = sheet.createRow(rnumber);

    String rowTitle = null;

    row = sheet.createRow(rnumber);
    row.setHeightInPoints(40);
    cell = row.createCell(0);
    cell.setCellValue(new HSSFRichTextString("?"));
    cell.setCellStyle(cellStyleH);

    for (int t = 0; t < columnTitles.size(); t++) {
        cell = row.createCell(t + 1);
        cell.setCellValue(new HSSFRichTextString(columnTitles.get(t)));
        cell.setCellStyle(cellStyleH);
    }

    // filling table with data
    rnumber++;

    for (ObservableList<Object> line : exportData) {
        row = sheet.createRow(rnumber);
        cell = row.createCell(0);
        cell.setCellValue(new HSSFRichTextString((String) line.get(0)));
        cell.setCellStyle(cellStyleN);
        for (int i = 1; i < line.size(); i++) {
            Double val = (Double) line.get(i);
            cell = row.createCell(i);
            cell.setCellStyle(cellStyleD);
            cell.setCellValue(val);
        }
        rnumber++;
    }
    for (int t = 0; t < columnTitles.size(); t++) {
        sheet.autoSizeColumn((short) t);
    }
    saveWorkBook(wb, selectedFile);
    execute(selectedFile);
}