嘲讽系最厉害的武器 2016-07-06 09:32 采纳率: 14.3%
浏览 2277

有关导出excel表格的问题,代码如下,导出的excel表格里面没有数据,list集合不为空。

 @RequestMapping("export")
    public void export(BuchangAnzhiViewRequest req, HttpServletResponse response)
            throws IOException, InstantiationException, IllegalAccessException
    {
        List<BuchangAnzhiView> viewList = getBuchangAnzhiViews(req, req.getPage());

        Workbook wb = getWorkbook("/template/buchanganzhi.mingxi.export.xlsx");

        Sheet sheet = wb.getSheetAt(0);

        if(CollectionUtils.isNotEmpty(viewList)){

            for(int i=0; i < viewList.size(); i++){

                Row row = sheet.createRow(i+2);

                BuchangAnzhiView view = viewList.get(i);
                int column =  0;
                setCell(row, column++, view.getBatchNo());
                setCell(row, column++, view.getRelocateNo());
                setCell(row, column++, view.getRelocateName());
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getHouseMoney()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getDecorationMoney()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getAttachmentMoney()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getMoveMoney()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getTransitionCost()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getAgreementAward()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getSubmitAward()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getOtherCompensate()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getTotalCompensate()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getBuildingPrice()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getFloorBalance()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getSettlementPrice()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getGaragePrice()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getGarageMoney()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getTotalHouseMoney()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getMaintainMoney()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getSettlementBalance()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getOtherMoney()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getTotalMoney()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getTemporaryDeposit()));
                setCell(row, column++, wb, MoneyUtils.formatBigDecimalMoney2String(view.getTotalGetMoney()));
            }
        }

        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-Disposition", "attachment; filename=" + encodeFileName("拆迁项目补偿安置情况明细查询表-" + CzyszjUtil.getCurrentYYYYMMDD() +".xlsx"));
        ServletOutputStream out = response.getOutputStream();
        wb.write(out);
        out.flush();
    }
  • 写回答

1条回答 默认 最新

  • devmiao 2016-07-06 09:34
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 基于单片机数字电压表电路组成及框图
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line