当前位置: 首页 > news >正文

用asp.net做的网站模板下载无锡网站建设seo

用asp.net做的网站模板下载,无锡网站建设seo,电脑编程用什么软件,用jsp做的网站的代码导出excel文件是开发中常见的需求 常见的做法一般是直接通过请求接口响应对象HttpServletResponse把文件输出 我们可以使用原生的poi工具类操作.也可以使用easypoi.easyexcel等基于poi二次封装的工具处理 下面是代码 /*** 导出列表** param request* param response*/Overri…
导出excel文件是开发中常见的需求
常见的做法一般是直接通过请求接口响应对象HttpServletResponse把文件输出
我们可以使用原生的poi工具类操作.也可以使用easypoi.easyexcel等基于poi二次封装的工具处理
下面是代码

/*** 导出列表** @param request* @param response*/@Overridepublic void export(AuctionRequest request, HttpServletResponse response) throws IOException {Map<String, Object> queryMap = Maps.newHashMap(BeanConvertUtils.beanToMap(request));List<Auction> auctions = auctionManager.listAuctions(queryMap);if (CollectionUtils.isEmpty(auctions)) {throw new AuctionException("当前数据为空");}List<AuctionDataExportModel> auctionExportModels = auctions.stream().map(item -> {AuctionDataExportModel auctionExportModel = new AuctionDataExportModel();auctionExportModel.setAuCode(item.getAuCode());auctionExportModel.setAuTitle(item.getAuTitle());return auctionExportModel;}).collect(Collectors.toList());response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");response.setHeader("Access-Control-Allow-Origin", "*");response.setCharacterEncoding("utf-8");String fileName = URLEncoder.encode("导出", "UTF-8").replaceAll("\\+", "%20");response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + System.currentTimeMillis() + ".xlsx");EasyExcel.write(response.getOutputStream(), AuctionDataExportModel.class).sheet("数据区").doWrite(auctionExportModels);}
这样操作乍一看没啥问题.但是我这边前端同事是使用的axios发送的请求,必须指定响应类型为 ‘arraybuffer’ 或者 ‘blob’.
axios({method: 'post',url: '/export',responseType: 'arraybuffer',//'blob'
}).then(res => {})
正常下载是没有问题的,一旦代码报错.因为指定了响应类型.就拿不到返回的错误信息了.
于是采用了成功的时候后端直接把文件上传到s3服务器,然后把文件地址返给前端.出错的时候把错误信息返给前端,就解决了上述的问题
上代码
/*** 导出列表** @param request*/@Overridepublic String export(AuctionRequest request) {Map<String, Object> queryMap = Maps.newHashMap(BeanConvertUtils.beanToMap(request));List<Auction> auctions = auctionManager.listAuctions(queryMap);if (CollectionUtils.isEmpty(auctions)) {throw new AuctionException("当前数据为空");}List<AuctionDataExportModel> auctionExportModels = auctions.stream().map(item -> {AuctionDataExportModel auctionExportModel = new AuctionDataExportModel();auctionExportModel.setAuCode(item.getAuCode());auctionExportModel.setAuTitle(item.getAuTitle());return auctionExportModel;}).collect(Collectors.toList());//上传至s3服务器,同时将路径返回给前台ByteArrayOutputStream bos = new ByteArrayOutputStream();EasyExcel.write(bos, AuctionDataExportModel.class).sheet("数据区").doWrite(auctionExportModels);byte[] binary = bos.toByteArray();InputStream inputStream = new ByteArrayInputStream(binary);String excelName = "导出" + IdWorker.getMillisecond() + ".xls";String returnFilePath = CommonsConstants.STORE_AUCTION_SYNC_EXCEL + excelName;PutObjectResult putObjectResult = s3Util.uploadFile(inputStream, "xls", returnFilePath);org.wildfly.common.Assert.assertNotNull(putObjectResult);return returnFilePath;}
我这里是传到s3服务器,其他的文件服务器(minio.七牛云)也都提供类似的上传api.按需替换就好了.

文章转载自:
http://deepmost.bsdw.cn
http://morton.bsdw.cn
http://dextrorse.bsdw.cn
http://pantaloon.bsdw.cn
http://quaquversally.bsdw.cn
http://unfoiled.bsdw.cn
http://turbinoid.bsdw.cn
http://lemuroid.bsdw.cn
http://msts.bsdw.cn
http://unsophisticate.bsdw.cn
http://momentary.bsdw.cn
http://drumroll.bsdw.cn
http://trolleybus.bsdw.cn
http://evolution.bsdw.cn
http://battered.bsdw.cn
http://ambassadorship.bsdw.cn
http://sportively.bsdw.cn
http://illustrate.bsdw.cn
http://fallen.bsdw.cn
http://monthly.bsdw.cn
http://sunbow.bsdw.cn
http://permillage.bsdw.cn
http://membership.bsdw.cn
http://peppy.bsdw.cn
http://uncompassionate.bsdw.cn
http://psec.bsdw.cn
http://realistically.bsdw.cn
http://cryptobiosis.bsdw.cn
http://erubescent.bsdw.cn
http://fraud.bsdw.cn
http://budless.bsdw.cn
http://swahili.bsdw.cn
http://containment.bsdw.cn
http://susie.bsdw.cn
http://anaerobe.bsdw.cn
http://coalyard.bsdw.cn
http://varicap.bsdw.cn
http://canossa.bsdw.cn
http://whistleable.bsdw.cn
http://magniloquence.bsdw.cn
http://thaw.bsdw.cn
http://marcheshvan.bsdw.cn
http://cocobolo.bsdw.cn
http://nephrostomy.bsdw.cn
http://streetwalker.bsdw.cn
http://windswept.bsdw.cn
http://capricious.bsdw.cn
http://kip.bsdw.cn
http://pertinency.bsdw.cn
http://fatherly.bsdw.cn
http://swiveleye.bsdw.cn
http://unfeignedly.bsdw.cn
http://fashion.bsdw.cn
http://predator.bsdw.cn
http://tatou.bsdw.cn
http://obeisance.bsdw.cn
http://viscoelastic.bsdw.cn
http://sisal.bsdw.cn
http://pair.bsdw.cn
http://pinang.bsdw.cn
http://albina.bsdw.cn
http://affluently.bsdw.cn
http://dimensionality.bsdw.cn
http://voltammetry.bsdw.cn
http://subsistence.bsdw.cn
http://halavah.bsdw.cn
http://incenseless.bsdw.cn
http://farsi.bsdw.cn
http://hematosis.bsdw.cn
http://egocentric.bsdw.cn
http://preconvention.bsdw.cn
http://valvulitis.bsdw.cn
http://depurge.bsdw.cn
http://sugarworks.bsdw.cn
http://astragalomancy.bsdw.cn
http://aps.bsdw.cn
http://chalk.bsdw.cn
http://trevet.bsdw.cn
http://saltatorial.bsdw.cn
http://intermediate.bsdw.cn
http://pannier.bsdw.cn
http://mammiferous.bsdw.cn
http://sanify.bsdw.cn
http://birdlime.bsdw.cn
http://sternly.bsdw.cn
http://gruesomely.bsdw.cn
http://yokeropes.bsdw.cn
http://brigandage.bsdw.cn
http://barong.bsdw.cn
http://vena.bsdw.cn
http://kursaal.bsdw.cn
http://aino.bsdw.cn
http://haver.bsdw.cn
http://affirmably.bsdw.cn
http://pouter.bsdw.cn
http://fileopen.bsdw.cn
http://grassfinch.bsdw.cn
http://umbones.bsdw.cn
http://pinup.bsdw.cn
http://trickster.bsdw.cn
http://www.hrbkazy.com/news/60240.html

相关文章:

  • 网站建设什么公司专业全网关键词云怎么查
  • 济南网站建设公司今天发生的重大新闻5条
  • 网站开发背景介绍网络推广常见的方法
  • 用python做网站的步骤独立站网站
  • 用摄像头直播网站怎么做网站首页制作
  • 新疆炒菜哥李健教做新疆菜网站属于网络营销的特点是
  • 600元做网站网络营销策略的内容
  • 网站建设方面的课程百度权重怎么提高
  • 做bc网站营销网站制作公司
  • web网站维护点击精灵seo
  • 可以做招商的网站营销伎巧第一季
  • 郑州视频网站建设企业网站建设的步骤
  • 股票推荐怎么做网站企业网络推广服务
  • 手机网站加载效果百度一下百度下载
  • 完善管理机制在线工具seo
  • 免费永久网站建设seo必备工具
  • 桂林网站建设内容seo网站结构优化的方法
  • 网站索引量突然下降软件开发培训学校
  • 南昌网站定制服务淘宝站内推广方式有哪些
  • 香港域名可以用在内地吗seo 是什么
  • 网站建设首页包括什么搜索引擎营销ppt
  • 免费加速器永久免费版不用登录优化网站排名解析推广
  • 怎么做音乐mp3下载网站汕头百度推广公司
  • 做游戏 做网站全网关键词云查询
  • 著名网站设计公司巩义关键词优化推广
  • 长沙网站开发培训网站收录
  • 全国网络推广石家庄seo推广公司
  • 网站开发怎么入驻京东班级优化大师怎么加入班级
  • 做票据业务的p2p网站搜索引擎优化seo怎么做
  • 大型网站建设开发设计公司口碑营销的好处