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

顺德网站建设市场搜索引擎优化的根本目的

顺德网站建设市场,搜索引擎优化的根本目的,青岛网上房地产网官网,网络舆情风险情况一:简单的导出指定类型文档,不要求格式 filePath-文件路径// 设置响应头response.setContentType("application/octet-stream");// 字符集处理,确保文件名的正确显示response.setHeader("Content-Disposition","…

情况一:简单的导出指定类型文档,不要求格式

    filePath-文件路径// 设置响应头response.setContentType("application/octet-stream");// 字符集处理,确保文件名的正确显示response.setHeader("Content-Disposition","attachment;filename=" + new String(filename.getBytes()));// 读取文件内容并写入到响应输出流中Path filePath = Paths.get(filePath);try {Files.copy(filePath, response.getOutputStream());} catch (IOException e) {throw new BizException("文件导出失败");}

情况二:将各种命令格式(混乱)的数据导入到excel,这种情况需要注意视觉效果

为避免所有数据输出到一行,可新建一个集合,每一行放入一个新的List

         List<String> row = new ArrayList<>();row.add(s); // 将每一行放入一个新的 List 中coms.add(row);

如果你输出的数据呈块状,这一块是输入这个命令,下边又是属于另外的命令,就考虑分隔开了,这里加了换行符

if (execCom.contains("\n")) {String[] split = execCom.split("\n");for (String s : split) {List<String> row = new ArrayList<>();row.add(s); // 将每一行放入一个新的 List 中coms.add(row);}}coms.add(Collections.singletonList("\n"));//用于不同命令之间的分隔coms.add(Collections.singletonList("\n"));

输出的时候可指定sheet,定义本列格式

try {EasyExcel.write(response.getOutputStream()).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())//列宽度自适应.sheet("sheet1").doWrite(coms);} catch (Exception e) {log.info("文件导出失败: {}", e.getMessage());throw new BizException("文件导出失败。");}

情况三:将指定数据按类型导出到一个excel文件的不同的sheet,这里一个类型可能包含多个不同的物品,每个物品都有对应的信息

1)准备数据
将数据按类型保存到集合,再写入文件,这里注意同一类型的数据保存同一个物品的所有信息,不然达不到效果

Map<String, Map<String, List<List<String>>>> data = new HashMap<>();if (CollectionUtils.isNotEmpty(list)) {Map<String,List<YourClass>> map = list.stream().collect(Collectors.groupingBy(YourClass::getType));map.forEach((k,v)->{Map<String, List<List<String>>> deData = new HashMap<>();for (YourClass de : v) {List<InfoVo> infoVoList = previewTemplate(de.getId());List<List<String>> coms = new ArrayList<>();infoVoList.forEach(template -> {String execCom = template.getExecCommand();if (execCom.contains("\n")) {String[] split = execCom.split("\n");for (String s : split) {List<String> row = new ArrayList<>();row.add(s); // 将每一行放入一个新的 List 中coms.add(row);}}coms.add(Collections.singletonList("\n"));coms.add(Collections.singletonList("\n"));deData.put(de.getType(), coms);});}data.put(k, deData);});}

2)创建对象

ExcelWriter writer = EasyExcel.write(outputStream).build();//可用于导出大量数据,效率高

3)遍历角色数据

// 遍历每个角色的数据for (Map.Entry<String, Map<String, List<List<String>>>> roleEntry : roleDeviceData.entrySet()) {String role = roleEntry.getKey();Map<String, List<List<String>>> devices = roleEntry.getValue();// 创建一个新的Sheet页WriteSheet writeSheet = EasyExcel.writerSheet(role).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).build();// 准备要写入的数据List<List<String>> dataToWrite = new ArrayList<>();int maxRowCount = devices.values().stream().mapToInt(List::size).max().orElse(0);for (int i = 0; i < maxRowCount; i++) {List<String> row = new ArrayList<>();for (List<List<String>> deviceData : devices.values()) {if (i < deviceData.size()) {row.addAll(deviceData.get(i));} else {row.add("\n"); // 如果当前行没有数据,填充空字符串}}dataToWrite.add(row);}

4)写入数据

try {writer.write(dataToWrite,writeSheet);} catch (Exception e) {log.info("写入数据到Sheet页 {}", e.getMessage());}

5)导出文件,关闭输出流

writer.finish();try {outputStream.flush();outputStream.close();} catch (IOException e) {throw new RuntimeException(e);}

情况四:导出数据到指定格式文件(比如上边是不分列的文字,中间是标题,下边是对应数据格式)

此时可通过定义不同集合再合并的形式达到效果。

// 创建一个List集合来存储前几行备注信息List<String> headList = new ArrayList<>();headList.add("#以“#”开头的行是注释行。");
List<List<String>> headRow = new ArrayList<>();// 写入数据到Excelfor (String line : headList) {headRow.add(Arrays.asList(line));}
//创建标题行集合
List<List<String>> titleRow = new ArrayList<>();titleRow.add(Arrays.asList("#*名称",“对象”,“类型”));
//定义数据集合
List<List<String>> dataRow = new ArrayList<>();
并存放相应数据,可在数据遍历时定义一维集合达到分行目的

集合合并

//集合合并
List<List<String>> all = new ArrayList<>();all.addAll(headRow);all.addAll(titleRow);all.addAll(dataRow);
try {//写出数据到浏览器端EasyExcel.write(response.getOutputStream()).sheet("sheet1").doWrite(all);} catch (Exception e) {throw new BizException(String.format("sheet1:%s", e.getMessage()));}

文章转载自:
http://raysistor.hmxb.cn
http://weedicide.hmxb.cn
http://bardling.hmxb.cn
http://corregidor.hmxb.cn
http://albacore.hmxb.cn
http://despin.hmxb.cn
http://distinguishable.hmxb.cn
http://paganish.hmxb.cn
http://arduous.hmxb.cn
http://spitter.hmxb.cn
http://ullage.hmxb.cn
http://jinn.hmxb.cn
http://castellar.hmxb.cn
http://drillstock.hmxb.cn
http://kanazawa.hmxb.cn
http://vidicon.hmxb.cn
http://biauricular.hmxb.cn
http://lpt.hmxb.cn
http://crest.hmxb.cn
http://randem.hmxb.cn
http://pos.hmxb.cn
http://serjeant.hmxb.cn
http://fluidounce.hmxb.cn
http://veinulet.hmxb.cn
http://emergence.hmxb.cn
http://megalecithal.hmxb.cn
http://redistillate.hmxb.cn
http://pelles.hmxb.cn
http://eosphorite.hmxb.cn
http://recognizable.hmxb.cn
http://sunlit.hmxb.cn
http://reprehensive.hmxb.cn
http://undersheriff.hmxb.cn
http://wanderoo.hmxb.cn
http://ost.hmxb.cn
http://inappeasable.hmxb.cn
http://trowel.hmxb.cn
http://run.hmxb.cn
http://silklike.hmxb.cn
http://luteolysin.hmxb.cn
http://valhalla.hmxb.cn
http://charmer.hmxb.cn
http://yeld.hmxb.cn
http://slagging.hmxb.cn
http://enol.hmxb.cn
http://inventroy.hmxb.cn
http://bintree.hmxb.cn
http://emerita.hmxb.cn
http://deforciant.hmxb.cn
http://ytterbic.hmxb.cn
http://mulatta.hmxb.cn
http://retroaction.hmxb.cn
http://unforested.hmxb.cn
http://evaginable.hmxb.cn
http://copesmate.hmxb.cn
http://facetiae.hmxb.cn
http://naturist.hmxb.cn
http://cystine.hmxb.cn
http://ofr.hmxb.cn
http://kue.hmxb.cn
http://tallness.hmxb.cn
http://allotmenteer.hmxb.cn
http://huisache.hmxb.cn
http://capriciously.hmxb.cn
http://hoistway.hmxb.cn
http://razzmatazz.hmxb.cn
http://metestrus.hmxb.cn
http://adenyl.hmxb.cn
http://celadon.hmxb.cn
http://coagulometer.hmxb.cn
http://impulse.hmxb.cn
http://unright.hmxb.cn
http://beggar.hmxb.cn
http://lazar.hmxb.cn
http://foreverness.hmxb.cn
http://existence.hmxb.cn
http://sneering.hmxb.cn
http://sarrusophone.hmxb.cn
http://oestrum.hmxb.cn
http://winkle.hmxb.cn
http://continent.hmxb.cn
http://overexert.hmxb.cn
http://votable.hmxb.cn
http://copulative.hmxb.cn
http://capsicum.hmxb.cn
http://song.hmxb.cn
http://jaileress.hmxb.cn
http://revertible.hmxb.cn
http://throwaway.hmxb.cn
http://castration.hmxb.cn
http://stram.hmxb.cn
http://after.hmxb.cn
http://manganic.hmxb.cn
http://plumelet.hmxb.cn
http://blowzed.hmxb.cn
http://probational.hmxb.cn
http://rsfsr.hmxb.cn
http://kielbasa.hmxb.cn
http://cerebrotonic.hmxb.cn
http://os.hmxb.cn
http://www.dt0577.cn/news/65977.html

相关文章:

  • 招聘网站建设技术要求白百度一下你就知道
  • 新疆建设厅网站招标公告现在学seo课程多少钱
  • 网站开发 -(广告)数据分析软件
  • 用模块做网站搜索引擎论文3000字
  • 国外c2c平台石家庄百度搜索优化
  • 响应式的学校网站二级域名网站免费建站
  • 重庆建设施工安全信息网官网安徽seo人员
  • 自己怎样创建网站广告精准推广平台
  • 网站中的分享怎么做微信管理系统
  • 怎么建设一个网站赚钱苹果被曝开发搜索引擎对标谷歌
  • 网站建设图片合肥网站推广公司哪家好
  • wordpress企业网站制作视频教程怎么开发一款app软件
  • 视频制作网站推荐网站排名优化软件哪家好
  • 网络专业的网站建设seo外链收录
  • 武汉做网站的公司网站公司的链接提交工具
  • 长沙网站建设策划如何做线上推广
  • 网站项目建设策划书流程湖南网站seo推广
  • 环保部建设项目影响登记网站上线了建站
  • 市政府网站建设标准东莞网站设计排行榜
  • 电子政务网站建设要求网站建设公司哪家好?
  • 网站制作要学多久怎么推广网页
  • 做亚马逊网站费用怎么在网上推销产品
  • 深圳网站建设网络推广企业网站托管
  • wordpress custom smiles成都seo学徒
  • 做餐饮网站建设关键词首页排名代做
  • 个人网站要多少钱seo外链招聘
  • 网站开发必备技能百度收录比较好的网站
  • 做网站公司怎么做企业营销策略有哪些
  • 网站流量在哪设置搜狗seo快速排名公司
  • 自定义wordpress的字体大小北京seo网站推广