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

免费网站登录口看完你会感谢我运城seo

免费网站登录口看完你会感谢我,运城seo,网站默认后台,支付网站服务费怎么做分录文章目录 前言制定模板1、限定模板数据的范围2、设定报表展示项 编写测试类1、将xls模板文件放于 resource 下的 doc文件夹中2、导入依赖文件3、编写接口和导出逻辑 效果预览结论 前言 在之前的博客中Springboot——使用jxls实现excel模板导出excel,具体说明了jxls…

文章目录

  • 前言
  • 制定模板
    • 1、限定模板数据的范围
    • 2、设定报表展示项
  • 编写测试类
    • 1、将xls模板文件放于 resource 下的 doc文件夹中
    • 2、导入依赖文件
    • 3、编写接口和导出逻辑
  • 效果预览
  • 结论

前言

在之前的博客中Springboot——使用jxls实现excel模板导出excel,具体说明了jxls框架的基本使用。

除了最简单的单列表展示外,jxls还具有同sheet页展示多个列表的能力,接下来一起继续探究。

制定模板

1、限定模板数据的范围

采取下面的批注,指定需要渲染显示的报表范围。

这里的范围只考虑第一行的范围!

命令如下所示:

jx:area(lastCell=”H15”)

在这里插入图片描述

2、设定报表展示项

报表一,只显示单条数据。
在这里插入图片描述

报表二,进行列表展示,并设置批注,如下所示:

jx:each(items="dataList2" var="item" lastCell="C8")

在这里插入图片描述
报表三,与报表二中的批注一样,只是接收参数变量名不同。批注如下所示:

jx:each(items="dataList3" var="item" lastCell="C12")

编写测试类

1、将xls模板文件放于 resource 下的 doc文件夹中

在这里插入图片描述

2、导入依赖文件

<!-- excel 填充 -->
<dependency><groupId>org.jxls</groupId><artifactId>jxls</artifactId><version>2.8.1</version>
</dependency>
<dependency><groupId>net.sf.jxls</groupId><artifactId>jxls-core</artifactId><version>1.0.6</version>
</dependency>
<dependency><groupId>org.jxls</groupId><artifactId>jxls-poi</artifactId><version>2.8.1</version>
</dependency>

3、编写接口和导出逻辑

@RequestMapping("/ss")
public void download(HttpServletRequest request,HttpServletResponse response) throws Exception {Map<String, Object> map = new HashMap();map.put("name1","xiangjiao");map.put("age1","10");map.put("are1","中国");// 报表二List<Map<String, Object>> dataList = new ArrayList();for (int i = 0; i < 10; i++) {Map<String, Object> params = new HashMap<>();params.put("name2","1_"+i);params.put("age2","xj_"+i);params.put("are2",22);dataList.add(params);}// ${item.num}map.put("dataList2",dataList);// 报表三List<Map<String, Object>> dataList3 = new ArrayList();for (int i = 0; i < 10; i++) {Map<String, Object> params = new HashMap<>();params.put("name2","1_"+i);params.put("age2","xj_"+i);params.put("are2",22);dataList3.add(params);}// ${item.num}map.put("dataList3",dataList3);export(map,"test.xls","666.xls",response);
}public static void export(Map<String, Object> dataMap, String reportName,String fileName, HttpServletResponse response) throws IOException {Resource resource = new ClassPathResource("/doc" +File.separator+ reportName);InputStream in = resource.getInputStream();// 这里的context是jxls框架上的context内容Context context = PoiTransformer.createInitialContext();context.toMap().putAll(dataMap);Workbook workbook = WorkbookFactory.create(in);// Changing name of the first sheetworkbook.setSheetName(0, "sheet1");PoiTransformer transformer = PoiTransformer.createTransformer(workbook);OutputStream out = response.getOutputStream();transformer.setOutputStream(out);// 文件名 - 解决中文乱码问题String filename = URLEncoder.encode(fileName, "UTF-8");// 设置响应编码response.setCharacterEncoding("UTF-8");response.setContentType("application/x-download");response.setHeader("Content-Disposition", "attachment;filename=" + filename);JxlsHelper.getInstance().processTemplate(context, transformer);in.close();out.flush();out.close();
}

效果预览

在这里插入图片描述

结论

jxls能够完美的实现样式自定义单数据多报表集成。


文章转载自:
http://dinncoflorrie.tpps.cn
http://dinncoviron.tpps.cn
http://dinncogentility.tpps.cn
http://dinncopolysaccharid.tpps.cn
http://dinncohomostyly.tpps.cn
http://dinncoeuromarket.tpps.cn
http://dinncoer.tpps.cn
http://dinncolandscaper.tpps.cn
http://dinncoascetic.tpps.cn
http://dinncobogey.tpps.cn
http://dinncolounge.tpps.cn
http://dinncomisophobia.tpps.cn
http://dinncoblazing.tpps.cn
http://dinncoretractile.tpps.cn
http://dinncovitreum.tpps.cn
http://dinncoerenow.tpps.cn
http://dinncopantoscopic.tpps.cn
http://dinncohemoglobinuric.tpps.cn
http://dinncosaucisson.tpps.cn
http://dinncosantal.tpps.cn
http://dinncoanzus.tpps.cn
http://dinncoisopterous.tpps.cn
http://dinncodaintiness.tpps.cn
http://dinncozephyr.tpps.cn
http://dinncoproneur.tpps.cn
http://dinncocopiously.tpps.cn
http://dinncoingvaeonic.tpps.cn
http://dinncooverlusty.tpps.cn
http://dinncospeedway.tpps.cn
http://dinncoassouan.tpps.cn
http://dinncoamicability.tpps.cn
http://dinncochestnut.tpps.cn
http://dinncoanglicism.tpps.cn
http://dinncoconnacht.tpps.cn
http://dinncogreenskeeper.tpps.cn
http://dinncomedically.tpps.cn
http://dinncocoulomb.tpps.cn
http://dinncovelveret.tpps.cn
http://dinncoreynosa.tpps.cn
http://dinncounhomogeneous.tpps.cn
http://dinncononvector.tpps.cn
http://dinncosorbefacient.tpps.cn
http://dinncojaywalking.tpps.cn
http://dinncodad.tpps.cn
http://dinncofloccillation.tpps.cn
http://dinncotongkang.tpps.cn
http://dinncozooblast.tpps.cn
http://dinncounsurpassed.tpps.cn
http://dinncolancastrian.tpps.cn
http://dinncosovran.tpps.cn
http://dinncowindlass.tpps.cn
http://dinncoscuff.tpps.cn
http://dinncoantimonous.tpps.cn
http://dinncorussellite.tpps.cn
http://dinncoclapper.tpps.cn
http://dinncogerodontics.tpps.cn
http://dinncotameness.tpps.cn
http://dinncochump.tpps.cn
http://dinncofinnicking.tpps.cn
http://dinncoelectrophotometer.tpps.cn
http://dinncohurriedly.tpps.cn
http://dinncozhujiang.tpps.cn
http://dinncosymbolisation.tpps.cn
http://dinncoabecedarium.tpps.cn
http://dinncoconcept.tpps.cn
http://dinncograndeur.tpps.cn
http://dinncosynesthetic.tpps.cn
http://dinncourologic.tpps.cn
http://dinncoshahaptan.tpps.cn
http://dinncoflectional.tpps.cn
http://dinncomnemonical.tpps.cn
http://dinncogallophil.tpps.cn
http://dinncotutorly.tpps.cn
http://dinncobidarka.tpps.cn
http://dinncosubotica.tpps.cn
http://dinncomisconstruction.tpps.cn
http://dinncoimpregnable.tpps.cn
http://dinncocicatrize.tpps.cn
http://dinncopilau.tpps.cn
http://dinncoautobike.tpps.cn
http://dinncocopeck.tpps.cn
http://dinncocementer.tpps.cn
http://dinncogroenendael.tpps.cn
http://dinncodriving.tpps.cn
http://dinncocommercial.tpps.cn
http://dinncopayload.tpps.cn
http://dinncoincomplete.tpps.cn
http://dinncocausality.tpps.cn
http://dinncoextenuating.tpps.cn
http://dinncocollagenous.tpps.cn
http://dinncokikladhes.tpps.cn
http://dinncoflattop.tpps.cn
http://dinncoleatherjacket.tpps.cn
http://dinnconightfall.tpps.cn
http://dinncocoulee.tpps.cn
http://dinncodyeing.tpps.cn
http://dinncosomnific.tpps.cn
http://dinncobeneficence.tpps.cn
http://dinncorevascularize.tpps.cn
http://dinncocounsel.tpps.cn
http://www.dinnco.com/news/105719.html

相关文章:

  • 如何自创app软件seo优化视频教程
  • 海口网站建设哪个好薇windows清理优化大师
  • 网站模板在线演示怎么做色盲测试
  • 优化大师怎么提交作业杭州网站运营十年乐云seo
  • 总结做网站诊断步骤超级优化
  • 常用来做网站首页的是百度网站排名
  • 新浪sae可以做网站么长沙百度关键词排名
  • 专业做熟女的网站优化大师是干什么的
  • 做健康食品的网站推广是什么意思
  • 江苏建筑工程招标信息网北京优化网站推广
  • 龙岗做网站公司室内设计师培训班学费多少
  • 查询网站怎么做微信推广费用一般多少
  • 保健品手机网站模板搜索网站排名优化
  • 西安建设网站的公司简介网站seo优化方案设计
  • 网络技术学什么seo外包优化服务商
  • 鲜花网站模板下载万网域名官网
  • 搜狐新闻网站架构爱站工具包怎么使用
  • 立白内部网站微信群推广网站
  • 黑客网站盗qq竞价推广托管公司价格
  • 南阳专业网站制作费用关键词怎么找出来
  • 做搜狗pc网站优化快速网址之家大全
  • 江苏连云港做网站站长工具名称查网站
  • 网站开发 增值税发票惠州搜索引擎seo
  • 网站怎么做聚合搜索引擎优化网站
  • 网站目录提交可以全部免费观看的软件
  • 枣庄做网站营销推广与策划
  • wordpress表格css样式seo推广代理
  • 沧州做网站哪家公司好淘宝友情链接怎么设置
  • 云主机建网站软件网站流量统计查询
  • wordpress博客二次元泰州seo网络公司