java导入导出excel表格

java导入导出excel表格

一.导出

    public void poiExport(Long[] ids, HttpServletRequest request, HttpServletResponse response) {
   
        String orderBatchSn = "";
        // 创建HSSFWorkbook对象(excel的文档对象)
        HSSFWorkbook wb = new HSSFWorkbook();
        // 建立新的sheet对象(excel的表单)
        HSSFSheet sheet = wb.createSheet("身份信息");
        // 输出Excel文件
        FileOutputStream output = null;
            // 在sheet里创建第一行,参数为行索引(excel的行),可以是0~65535之间的任何一个
            HSSFRow rowTitle = sheet.createRow(0);
            // 创建单元格并设置单元格内容
            rowTitle.createCell(0).setCellValue("客户单号");
            rowTitle.createCell(1).setCellValue("姓名");
            rowTitle.createCell(2).setCellValue("地区");
            rowTitle.createCell(3).setCellValue("地址");
            rowTitle.createCell(4).setCellValue("手机号");
            rowTitle.createCell(5).setCellValue("身份证号");
            rowTitle.createCell(6).setCellValue("订单编号");
            //表格行数
            int i = 1;
            if (ids == null || ids.length < 0) {
   
                logger.info("{} requestParam = {} message = {}", method, ids, "主键id为空");
                return;
            }
            //根据具体情况去自己的数据访问层查询需要导出的信息
            List<PcOrderDetailResponse> pcOrderListResponse = pcOrderService.findlist(ids);
            for (PcOrderDetailResponse order : pcOrderListResponse) {
   
                try {
   
                    if (order == null) {
   
                        logger.debug("未查到此订单");
                        continue;
                    }
                    String authenticationRealName = order.getAuthenticationRealName();
                    Long isAuthenticationRealName = order.getIsAuthenticationRealName();
                    if (authenticationRealName == null) {
   
                        logger.debug("订单未做认证处理!");
                        continue;
                    }
                    if (isAuthenticationRealName == 1) {
   
                        logger.debug("订单已经鉴权过 ,并且通过!");
                        continue;
                    }

                    // 在sheet里创建第i行
                    //客户单号customerOrderSn   姓名(收货人)consignee  地区area  地址address  手机号phone  身份证号 card_id    订单编号sn
                    HSSFRow row = sheet.createRow(i);
                    row.createCell(0).setCellValue(
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值