JAVA 将json 或object 转换为实体

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ruiguang21/article/details/80319706
response.setContentType("application/octet-stream");
        response.setContentType("application/OCTET-STREAM;charset=UTF-8");
        response.setHeader("Content-Disposition", "attachment;filename=TbizPortfolioPositionVo.xls" );
        String[] header= {"持仓日期","产品名称","资产名称",
        "资产代码","资产类型","持仓数","全价市值","净价值","收盘全价","久值"};
        List<Object> dataset =tbizPortfolioPositionService.selectComdNameExcal("2017-05-23");
    List<TbizPortfolioPositionVo> tbizportfoliopositionvo=new ArrayList<>();
        for(int i=0;i<dataset.size();i++)
    {
        TbizPortfolioPositionVo tbizportfolioposition=new TbizPortfolioPositionVo();
        //System.out.println(dataset.get(1));
        JSONObject  obj = JSONObject.fromObject(dataset.get(i));
        tbizportfolioposition =(TbizPortfolioPositionVo) JSONObject.toBean(obj,TbizPortfolioPositionVo.class);
        System.out.println("tbizportfolioposition---->>>"+tbizportfolioposition);
        tbizportfoliopositionvo.add(tbizportfolioposition);


       
    }
        System.out.println("dataset---->>"+dataset.toString());
        ExportExcel<TbizPortfolioPositionVo> ex = new ExportExcel<TbizPortfolioPositionVo>();
        OutputStream  out = new BufferedOutputStream(response.getOutputStream());
        


        ex.exportExcel(header, tbizportfoliopositionvo, out);  //title是excel表中底部显示的表格名,如Sheet
        out.close();
        
        
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页