上传者: xuesongtan
|
上传时间:2024/12/12 19:46:39
|
文件大小:6KB
|
文件类型:rar
Java实现Excel导入导出
Excel源代码,导入导出各种工具类org.apache.poipoiorg.apache.poipoi-scratchpad代码实例:Stringpath="";byte[]bytes;vo.setCurrentPage(0);vo.setPageSize(Integer.MAX_VALUE);Listlist=stockOrderController.exportShOutOrderDetail(vo);Mapempinfo=newTreeMap();intindex=1;empinfo.put(index++,newObject[]{"销售单号","销售时间","会员","商品总额","来源","商品名称/属性","数量","单价"});for(ShOutOrderDetailitem:list){empinfo.put(index++,newObject[]{item.getOutOrderNo(),DateUtil.SDF.format(item.getOutTime()),item.getNickName()+"/"+item.getMobile(),String.valueOf(item.getStockPrice().multiply(newBigDecimal(item.getStockAmount()))),"01".equals(item.getSalesSource())?"线上订单":"线下订单",item.getGoodsNameAttrs(),String.valueOf(item.getStockAmount()),String.valueOf(item.getStockPrice())});}try{bytes=ExcelUtils.simpleExcel(empinfo,"销售单信息");MultipartFilemultipartFile=newMultipartFile();multipartFile.setData(bytes);multipartFile.setOriginalFilename("ShOutOrderDetailExport.xls");path=fastDFSClientController.uploadFile(multipartFile);}catch(Exceptione){logger.error("出库单信息导出失败:{}",e.getMessage(),e);return"fail";}logger.info("出库单信息导出结束,path:{}",path);returnpath;
本软件ID:2317681