Example usage for org.apache.poi.hssf.usermodel HSSFRow setRowStyle

List of usage examples for org.apache.poi.hssf.usermodel HSSFRow setRowStyle

Introduction

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

Prototype

@Override
public void setRowStyle(CellStyle style) 

Source Link

Document

Applies a whole-row cell styling to the row.

Usage

From source file:xx.tream.chengxin.ms.action.TrainReportAction.java

@RequestMapping({ "/toExport" })
public String toExport(ModelMap modelMap, HttpServletRequest request, HttpServletResponse response,
        FormMap formMap, Integer currentPage, Integer pageSize) throws IOException {
    Map<String, Object> qm = formMap.getFormMap();
    List<Map<String, Object>> list = this.trainService.queryForParam(qm);
    //Map<String, Object> statisticsMap = this.trainService.statistics(qm);
    String trainIds = this.getTrainIds(list);
    List<Map<String, Object>> payingList = this.payingService.queryByTrainIds(trainIds);
    List<Map<String, Object>> incomeList = this.incomeService.queryByTrainIds(trainIds);
    List<Map<String, Object>> payoutList = this.payoutService.queryByTrainIds(trainIds);
    Map<Long, List<Map<String, Object>>> payingMap = converList(payingList);
    Map<Long, List<Map<String, Object>>> incomeMap = converList(incomeList);
    Map<Long, List<Map<String, Object>>> payoutMap = converList(payoutList);

    OutputStream os = response.getOutputStream();
    response.reset();/*  w  w  w .j  av  a  2s  .  c  om*/
    response.setCharacterEncoding("UTF-8");
    String title = "?" + getDateFile() + ".xls";
    response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(title, "UTF-8"));
    response.setContentType("application/vnd.ms-excel");
    HSSFWorkbook workbook = new HSSFWorkbook();
    HSSFSheet sheet = workbook.createSheet("?");
    HSSFRow headrow = sheet.createRow(0);
    HSSFCellStyle headcell = workbook.createCellStyle();

    HSSFFont font = workbook.createFont();
    font.setFontName("");
    font.setFontHeightInPoints((short) 10);
    headcell.setFont(font);
    headrow.setRowStyle(headcell);
    String payingValue[] = { "", "paying", "createUserName", "createTime", "createTime", "", "auditUserName",
            "auditTime", "auditTime" };
    String incomeValue[] = { "type", "income", "createUserName", "createTime", "createTime", "note",
            "auditUserName", "auditTime", "auditTime" };
    String payoutValue[] = { "type", "payout", "createUserName", "createTime", "createTime", "",
            "auditUserName", "auditTime", "auditTime" };
    String[] heads = { "", "?", "?", "??", "??", "",
            "", "", "", "", "/", "/?", "C1/C2",
            "", "", "", "", "", "?", "?",
            "?", "?", "", "", "", "" };
    String[] values = { "", "id", "autumnNumber", "name", "idcard", "pay", "allpaying", "count_all", "allip",
            "canpay", "newOrOld", "type", "licenseTag", "createUserName", "createTime", "createTime", "note" };
    HSSFCellStyle headStyle = ExcelUtil.headCell(workbook);
    HSSFCell cell = null;
    //
    int cr = 0;
    for (int i = 0; i < heads.length; i++) {
        cell = headrow.createCell(cr);
        cell.setCellValue(heads[i]);
        cell.setCellStyle(headStyle);
        sheet.setColumnWidth(cr, 5000);
        cr++;
    }
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    SimpleDateFormat sdf2 = new SimpleDateFormat("HH:mm");
    HSSFCellStyle rowStyle = ExcelUtil.leftCell(workbook);
    HSSFCellStyle paleBlueStyle = ExcelUtil.paleBlueForgroundCell(workbook);
    //HSSFCellStyle redFontStyle = ExcelUtil.leftFontRedCell(workbook);
    //HSSFCellStyle redFontForegroudStyle = ExcelUtil.leftFontRedForegroudCell(workbook);
    HSSFCellStyle rightStyle = ExcelUtil.rightCell(workbook);
    HSSFCellStyle rightForegroudStyle = ExcelUtil.rightPaleBlueForgroundCell(workbook);
    HSSFCellStyle rightredFontStyle = ExcelUtil.rightFontRedCell(workbook);
    HSSFCellStyle rightredFontForegroudStyle = ExcelUtil.rightFontRedForegroudCell(workbook);
    double ac[] = new double[5];

    //
    int rn = 1;
    HSSFRow row = null;
    //??
    for (int i = 0; i < list.size(); i++) {
        int a = 0;
        //
        int pb = 0;
        //
        cr = 0;
        row = sheet.createRow(rn++);
        Map<String, Object> trainMap = (Map<String, Object>) list.get(i);
        List<Map<String, Object>> payL = (List<Map<String, Object>>) payingMap.get((Long) trainMap.get("id"));
        List<Map<String, Object>> incomeL = (List<Map<String, Object>>) incomeMap
                .get((Long) trainMap.get("id"));
        List<Map<String, Object>> payoutL = (List<Map<String, Object>>) payoutMap
                .get((Long) trainMap.get("id"));
        for (int v = 0; v < values.length; v++) {
            cell = row.createCell(cr++);
            if (trainMap.get(values[v]) != null) {
                if (v == 14) {
                    cell.setCellValue(sdf.format((Date) trainMap.get(values[v])));
                } else if (v == 15) {
                    cell.setCellValue(sdf2.format((Date) trainMap.get(values[v])));
                } else if (v == 5 || v == 6 || v == 7 || v == 8 || v == 9) {
                    Double d = trainMap.get(values[v]) == null ? 0 : (Double) trainMap.get(values[v]);
                    ac[a] += d;
                    a++;
                    cell.setCellValue((Double) trainMap.get(values[v]));
                } else if (v == 1) {
                    cell.setCellValue((Long) trainMap.get(values[v]));
                } else {
                    cell.setCellValue((String) trainMap.get(values[v]));
                }
            } else {
                if (v == 0) {
                    cell.setCellValue(i + 1);
                } else {
                    cell.setCellValue("");
                }
            }
            if (v == 5 || v == 6 || v == 7 || v == 8 || v == 9) {//?
                cell.setCellStyle(rightForegroudStyle);
            } else {
                cell.setCellStyle(paleBlueStyle);
            }

        }

        //
        if (payL != null && payL.size() > 0) {
            for (int p = 0; p < payL.size(); p++) {
                Map<String, Object> pMap = payL.get(p);
                cr = values.length;
                for (int v = 0; v < payingValue.length; v++) {
                    cell = row.createCell(cr++);
                    if (v == 0) {
                        cell.setCellValue("" + (p + 1));
                    } else {
                        if (pMap.get(payingValue[v]) != null) {
                            if (v == 3 || v == 7) {
                                cell.setCellValue(sdf.format((Date) pMap.get(payingValue[v])));
                            } else if (v == 4 || v == 8) {
                                cell.setCellValue(sdf2.format((Date) pMap.get(payingValue[v])));
                            } else if (v == 1) {
                                Double nv = (Double) pMap.get(payingValue[v]);
                                cell.setCellValue(nv);
                            } else {
                                cell.setCellValue((String) pMap.get(payingValue[v]));
                            }
                        } else {
                            cell.setCellValue("");
                        }
                    }
                    if (v == 1) {//?
                        if (pb == 0) {
                            cell.setCellStyle(rightForegroudStyle);
                        } else {
                            cell.setCellStyle(rightStyle);
                        }
                    } else {
                        if (pb == 0) {
                            cell.setCellStyle(paleBlueStyle);

                        } else {
                            cell.setCellStyle(rowStyle);
                        }
                    }
                }
                pb++;
                row = sheet.createRow(rn++);

            }

        }
        //
        if (incomeL != null && incomeL.size() > 0) {
            for (int p = 0; p < incomeL.size(); p++) {
                Map<String, Object> iMap = incomeL.get(p);
                cr = values.length;
                for (int v = 0; v < incomeValue.length; v++) {
                    cell = row.createCell(cr++);
                    if (v == 0) {
                        cell.setCellValue(iMap.get(incomeValue[v]) + "()");
                    } else {
                        if (iMap.get(incomeValue[v]) != null) {
                            if (v == 3 || v == 7) {
                                cell.setCellValue(sdf.format((Date) iMap.get(incomeValue[v])));
                            } else if (v == 4 || v == 8) {
                                cell.setCellValue(sdf2.format((Date) iMap.get(incomeValue[v])));
                            } else if (v == 1) {
                                cell.setCellValue((Double) iMap.get(incomeValue[v]));
                            } else {
                                cell.setCellValue((String) iMap.get(incomeValue[v]));
                            }
                        } else {
                            cell.setCellValue("");
                        }
                    }
                    if (v == 1) {//?
                        if (pb == 0) {
                            cell.setCellStyle(rightForegroudStyle);
                        } else {
                            cell.setCellStyle(rightStyle);
                        }
                    } else {
                        if (pb == 0) {
                            cell.setCellStyle(paleBlueStyle);

                        } else {
                            cell.setCellStyle(rowStyle);
                        }
                    }
                }
                pb++;
                row = sheet.createRow(rn++);
            }
        }
        boolean flag = false;
        //
        if (payoutL != null && payoutL.size() > 0) {
            for (int p = 0; p < payoutL.size(); p++) {
                Map<String, Object> pMap = payoutL.get(p);
                cr = values.length;
                for (int v = 0; v < payoutValue.length; v++) {
                    cell = row.createCell(cr++);
                    if (v == 0) {
                        cell.setCellValue(pMap.get(payoutValue[v]) + "()");
                    } else {
                        if (pMap.get(payoutValue[v]) != null) {
                            if (v == 3 || v == 7) {
                                cell.setCellValue(sdf.format((Date) pMap.get(payoutValue[v])));
                            } else if (v == 4 || v == 8) {
                                cell.setCellValue(sdf2.format((Date) pMap.get(payoutValue[v])));
                            } else if (v == 1) {
                                flag = true;
                                cell.setCellValue(0 - (Double) pMap.get(payoutValue[v]));
                            } else {
                                cell.setCellValue((String) pMap.get(payoutValue[v]));
                            }
                        } else {
                            cell.setCellValue("");
                        }
                    }
                    if (pb == 0 && flag) {
                        flag = false;
                        cell.setCellStyle(rightredFontForegroudStyle);
                    } else if (flag) {
                        flag = false;
                        cell.setCellStyle(rightredFontStyle);
                    } else if (pb == 0) {
                        cell.setCellStyle(paleBlueStyle);
                    } else {
                        cell.setCellStyle(rowStyle);
                    }
                }
                pb++;
                if (p != payoutL.size() - 1) {
                    row = sheet.createRow(rn++);
                }
            }
        }
    }
    if (list != null && list.size() > 0) {
        row = sheet.createRow(rn++);
        cell = row.createCell(0);
        cell.setCellValue("?");
        cell.setCellStyle(headStyle);
        for (int i = 0; i < ac.length; i++) {
            cell = row.createCell(5 + i);
            cell.setCellValue(ac[i]);
            cell.setCellStyle(rightStyle);
        }
    }

    workbook.write(os);
    os.flush();
    os.close();
    return null;
}

From source file:xx.tream.chengxin.ms.service.ReportServiceImpl.java

public HSSFWorkbook financialStatements(HSSFWorkbook workbook, Map<String, Object> queryMap) {
    HSSFSheet sheet = workbook.createSheet("");
    HSSFRow headrow = sheet.createRow(0);
    HSSFCellStyle headcell = ExcelUtil.headCell(workbook);
    headrow.setRowStyle(headcell);
    String start = (String) queryMap.get("beginTime");
    String end = (String) queryMap.get("endTime");
    Date startDate = DateUtil.stringToDate(start, "yyyy-MM-dd");
    Date endDate = DateUtil.stringToDate(end, "yyyy-MM-dd");
    HSSFCellStyle rightcell = ExcelUtil.rightCell(workbook);

    //HSSFCellStyle leftcell = ExcelUtil.leftCell(workbook);
    HSSFCellStyle centercell = ExcelUtil.centerCell(workbook);
    //?  //from  w  ww  .j a  v  a2 s  .  co m
    int icount = 0;
    if (endDate != null) {
        //1
        Calendar cal = Calendar.getInstance();
        cal.setTime(endDate);
        cal.add(Calendar.DATE, 1);
        endDate = cal.getTime();
        end = DateUtil.DateToString(endDate, "yyyy-MM-dd");
        queryMap.put("endTime", end);
    }

    // 
    ExcelUtil.mergeRegion(sheet, 0, 1, 0, 0, "", headcell);
    sheet.setColumnWidth(0, 6500);
    icount++;
    // 
    ExcelUtil.mergeRegion(sheet, 0, 1, 1, 1, "", headcell);
    sheet.setColumnWidth(1, 4500);
    HSSFRow row = sheet.createRow(1);
    icount++;
    int col = 2;
    //    
    String[] incomeItems = ParamUtil.incomeItems;
    for (int i = 0; i < incomeItems.length - 1; i++) {
        //???
        HSSFCell cell = row.createCell(col);
        cell.setCellValue(incomeItems[i]);
        cell.setCellStyle(headcell);
        sheet.setColumnWidth(col, 4500);
        col++;
        icount++;
    }
    String[] otherIncomeItems = reportParamService.queryIncomeOtherItem(startDate, endDate);
    int n = 0;
    if (otherIncomeItems != null && otherIncomeItems.length > 0) {
        for (int i = 0; i < otherIncomeItems.length; i++) {
            HSSFCell cell = row.createCell(col);
            cell.setCellValue("(" + otherIncomeItems[i] + ")");
            cell.setCellStyle(headcell);
            sheet.setColumnWidth(col, 4500);
            icount++;
            col++;
        }
        n = otherIncomeItems.length;
    }
    int s = 2;
    int e = incomeItems.length + n;
    ExcelUtil.mergeRegion(sheet, 0, 0, s, e, "", headcell);
    //
    String[] incomeCommonItems = ParamUtil.incomeCommonItems;
    for (int i = 0; i < incomeCommonItems.length - 1; i++) {
        //???
        HSSFCell cell = row.createCell(col);
        cell.setCellValue(incomeCommonItems[i]);
        cell.setCellStyle(headcell);
        sheet.setColumnWidth(col, 4500);
        col++;
        icount++;
    }
    String[] otherIncomeCommonItems = reportParamService.queryIncomeCommonOtherItem(startDate, endDate);
    n = 0;
    if (otherIncomeCommonItems != null && otherIncomeCommonItems.length > 0) {
        for (int i = 0; i < otherIncomeCommonItems.length; i++) {
            HSSFCell cell = row.createCell(col);
            cell.setCellValue("(" + otherIncomeCommonItems[i] + ")");
            cell.setCellStyle(headcell);
            sheet.setColumnWidth(col, 4500);
            icount++;
            col++;
        }
        n = otherIncomeCommonItems.length;
    }
    s = e + 1;
    e = e + incomeCommonItems.length - 1 + n;
    ExcelUtil.mergeRegion(sheet, 0, 0, s, e, "", headcell);

    //
    n = 0;
    String payoutItems[] = ParamUtil.payoutItems;
    for (int i = 0; i < payoutItems.length - 1; i++) {
        //???
        HSSFCell cell = row.createCell(col);
        cell.setCellValue(payoutItems[i]);
        cell.setCellStyle(headcell);
        sheet.setColumnWidth(col, 4500);
        col++;
    }
    String[] payoutOtherItems = reportParamService.queryPayoutOtherItem(startDate, endDate);
    if (payoutOtherItems != null && payoutOtherItems.length > 0) {
        for (int i = 0; i < payoutOtherItems.length; i++) {
            HSSFCell cell = row.createCell(col);
            cell.setCellValue("(" + payoutOtherItems[i] + ")");
            cell.setCellStyle(headcell);
            sheet.setColumnWidth(col, 4500);
            col++;
        }
        n = payoutOtherItems.length;
    }
    s = e + 1;
    e = e + payoutItems.length - 1 + n;
    ExcelUtil.mergeRegion(sheet, 0, 0, s, e, "", headcell);
    //    
    String[] payoutCommonItems = ParamUtil.payoutCommonItems;
    for (int i = 0; i < payoutCommonItems.length - 1; i++) {
        //???
        HSSFCell cell = row.createCell(col);
        cell.setCellValue(payoutCommonItems[i]);
        cell.setCellStyle(headcell);
        sheet.setColumnWidth(col, 4500);
        col++;

    }
    String payoutCommonOtherTypes[] = reportParamService.queryPayoutCommonOtherItem(startDate, endDate);
    if (payoutCommonOtherTypes != null && payoutCommonOtherTypes.length > 0) {
        for (int i = 0; i < payoutCommonOtherTypes.length; i++) {
            HSSFCell cell = row.createCell(col);
            cell.setCellValue("(" + payoutCommonOtherTypes[i] + ")");
            cell.setCellStyle(headcell);
            sheet.setColumnWidth(col, 4500);
            col++;

        }
        n = payoutCommonOtherTypes.length;
    }
    s = e + 1;
    e = e + payoutCommonItems.length - 1 + n;
    ExcelUtil.mergeRegion(sheet, 0, 0, s, e, "", headcell);
    HSSFCell cell = null;
    //?
    queryMap.put("", "");
    List<Map<String, Object>> list = this.reportParamService.queryIncomeAndPayout(queryMap, incomeItems,
            otherIncomeItems, incomeCommonItems, otherIncomeCommonItems, payoutItems, payoutOtherItems,
            payoutCommonItems, payoutCommonOtherTypes);
    if (list != null && list.size() > 0) {
        double[] count = new double[col];
        for (int i = 0; i < list.size(); i++) {
            col = 0;
            row = sheet.createRow(2 + i);
            Map<String, Object> map = list.get(i);
            cell = row.createCell(col);
            cell.setCellValue((String) map.get("audittime"));
            col++;
            cell = row.createCell(col);
            if (map.get("paying") != null) {
                Double v = (Double) map.get("paying");
                count[col] = count[col] + v;
                cell.setCellValue(v);
            }
            col++;
            //
            if (incomeItems != null && incomeItems.length > 0) {
                for (int k = 0; k < incomeItems.length - 1; k++) {
                    cell = row.createCell(col);
                    if (map.get("i" + k) != null) {
                        Double v = (Double) map.get("i" + k);
                        count[col] = count[col] + v;
                        cell.setCellValue(v);
                    }
                    col++;
                }
            }
            if (otherIncomeItems != null && otherIncomeItems.length > 0) {
                for (int k = 0; k < otherIncomeItems.length; k++) {
                    cell = row.createCell(col);
                    if (map.get("io" + k) != null) {
                        Double v = (Double) map.get("io" + k);
                        count[col] = count[col] + v;
                        cell.setCellValue(v);
                    }
                    col++;
                }
            }
            //
            if (incomeCommonItems != null && incomeCommonItems.length > 0) {
                for (int k = 0; k < incomeCommonItems.length - 1; k++) {
                    cell = row.createCell(col);
                    if (map.get("ic" + k) != null) {
                        Double v = (Double) map.get("ic" + k);
                        count[col] = count[col] + v;
                        cell.setCellValue(v);
                    }
                    col++;
                }
            }
            if (otherIncomeCommonItems != null && otherIncomeCommonItems.length > 0) {
                for (int k = 0; k < otherIncomeCommonItems.length; k++) {
                    cell = row.createCell(col);
                    if (map.get("ico" + k) != null) {
                        Double v = (Double) map.get("ico" + k);
                        count[col] = count[col] + v;
                        cell.setCellValue(v);
                    }
                    col++;
                }
            }
            //
            if (payoutItems != null && payoutItems.length > 0) {
                for (int k = 0; k < payoutItems.length - 1; k++) {
                    cell = row.createCell(col);
                    if (map.get("p" + k) != null) {
                        Double v = (Double) map.get("p" + k);
                        count[col] = count[col] + v;
                        cell.setCellValue(v);
                    }
                    col++;
                }
            }
            if (payoutOtherItems != null && payoutOtherItems.length > 0) {
                for (int k = 0; k < payoutOtherItems.length; k++) {
                    cell = row.createCell(col);
                    if (map.get("po" + k) != null) {
                        Double v = (Double) map.get("po" + k);
                        count[col] = count[col] + v;
                        cell.setCellValue(v);
                    }
                    col++;
                }
            }
            //
            if (payoutCommonItems != null && payoutCommonItems.length > 0) {
                for (int k = 0; k < payoutCommonItems.length - 1; k++) {
                    cell = row.createCell(col);
                    if (map.get("pc" + k) != null) {
                        Double v = (Double) map.get("pc" + k);
                        count[col] = count[col] + v;
                        cell.setCellValue(v);
                    }
                    col++;
                }
            }
            if (payoutCommonOtherTypes != null && payoutCommonOtherTypes.length > 0) {
                for (int k = 0; k < payoutCommonOtherTypes.length; k++) {
                    cell = row.createCell(col);
                    if (map.get("pco" + k) != null) {
                        Double v = (Double) map.get("pco" + k);
                        count[col] = count[col] + v;
                        cell.setCellValue(v);
                    }
                    col++;
                }
            }

        }
        //?
        row = sheet.createRow(2 + list.size());
        cell = null;
        for (int i = 0; i < count.length; i++) {
            if (i == 0) {
                cell = row.createCell(0);
                cell.setCellValue("?");
                cell.setCellStyle(headcell);
            } else {
                cell = row.createCell(i);
                cell.setCellValue(count[i]);
            }

        }
        double ivalue = 0;
        double pvalue = 0;
        for (int i = 0; i < icount; i++) {
            ivalue += count[i];
        }
        for (int i = icount; i < count.length; i++) {
            pvalue += count[i];
        }
        //
        row = sheet.createRow(3 + list.size());
        cell = row.createCell(0);
        cell.setCellValue(":");
        cell.setCellStyle(headcell);
        cell = row.createCell(1);
        cell.setCellValue(ivalue);
        cell = row.createCell(2);
        cell.setCellValue(":");
        cell.setCellStyle(headcell);
        cell = row.createCell(3);
        cell.setCellValue(pvalue);
    }
    int rowNum = 0;
    //
    List<Map<String, Object>> trainIPOList = this.queryTrainIncomePayout(queryMap);
    if (trainIPOList != null && trainIPOList.size() > 0) {

        sheet = workbook.createSheet("");
        String heads[] = { "", "?", "", "", "", "",
                "" };
        String values[] = { "name", "idcard", "payable", "allincome", "allpaying", "allpayout" };
        row = sheet.createRow(rowNum);

        for (int i = 0; i < heads.length; i++) {
            cell = row.createCell(i);
            cell.setCellValue(heads[i]);
            cell.setCellStyle(headcell);
            sheet.setColumnWidth(i, 4500);
        }
        rowNum++;
        double countAll[] = new double[heads.length];
        for (int i = 0; i < trainIPOList.size(); i++) {
            row = sheet.createRow(rowNum);
            Map<String, Object> map = trainIPOList.get(i);
            //
            double allpip = 0;
            for (int k = 0; k < values.length; k++) {
                cell = row.createCell(k);
                if (map.get(values[k]) != null) {
                    if (k > 1) {
                        double value = (Double) map.get(values[k]);
                        if (k < 4) {
                            allpip += value;
                        }
                        cell.setCellValue(value);
                        countAll[k] += value;
                    } else {
                        cell.setCellValue((String) map.get(values[k]));
                    }
                }
            }
            //
            cell = row.createCell(values.length);
            cell.setCellValue(allpip);
            countAll[values.length] += allpip;
            rowNum++;
        }
        //?
        row = sheet.createRow(rowNum);
        cell = row.createCell(0);
        cell.setCellValue("?");
        cell.setCellStyle(headcell);
        for (int i = 2; i < countAll.length; i++) {
            cell = row.createCell(i);
            cell.setCellValue(countAll[i]);
        }
        rowNum++;
    }
    rowNum = 0;
    //
    List<Map<String, Object>> countList = this.queryCountByTime(queryMap);
    if (countList != null && countList.size() > 0) {

        sheet = workbook.createSheet("");
        String heads[] = { "", "?", "?", "?",
                "?", "?", "?",
                "???" };
        String values[] = { "audittime", "payable", "paying", "income", "incomeCommon", "payout",
                "payoutCommon", "canPay" };
        row = sheet.createRow(rowNum);

        for (int i = 0; i < heads.length; i++) {
            cell = row.createCell(i);
            cell.setCellValue(heads[i]);
            cell.setCellStyle(headcell);
            sheet.setColumnWidth(i, 4500);
        }
        rowNum++;
        double countAll[] = new double[heads.length];
        for (int i = 0; i < countList.size(); i++) {
            row = sheet.createRow(rowNum);
            Map<String, Object> map = countList.get(i);
            for (int k = 0; k < values.length; k++) {
                cell = row.createCell(k);
                if (map.get(values[k]) != null) {
                    if (k > 0) {
                        double value = (Double) map.get(values[k]);
                        cell.setCellValue(value);
                        cell.setCellStyle(rightcell);
                        countAll[k] += value;
                    } else {
                        cell.setCellValue((String) map.get(values[k]));
                        cell.setCellStyle(centercell);
                    }
                }
            }

            rowNum++;
        }
        //?
        row = sheet.createRow(rowNum);
        cell = row.createCell(0);
        cell.setCellValue("?");
        cell.setCellStyle(headcell);
        for (int i = 1; i < countAll.length; i++) {
            cell = row.createCell(i);
            cell.setCellValue(countAll[i]);
            if (countAll[i] >= 0) {
                cell.setCellStyle(rightcell);
            } else {

            }

        }
        rowNum++;
    }

    return workbook;
}