ExcelUtil 3.1.0 发布,新增模板导出功能

栏目: 软件资讯 · 发布时间: 4年前

内容简介:更新内容如下: 1.新增模板导出。 【说明】现在很多工具类,为了设计为工具,其本身有学习成本在里面,ExcelUtil作为一个工具类,其一开始就为了开发者能够迅速上手 ,所以我们的一贯宗旨就是极简的代码上手,对入...

更新内容如下:

1.新增模板导出。

【说明】现在很多 工具 类,为了设计为工具,其本身有学习成本在里面,ExcelUtil作为一个工具类,其一开始就为了开发者能够迅速上手

,所以我们的一贯宗旨就是极简的代码上手,对入门者来说十分简单就能使用。

更多用法请参见官网: http://www.likaixuan.top/excelUtil/doc/v3
以下用例都是3.x用法:

//浏览器中直接下载
/**
 *
 * 参数说明:1.response 没什么好说的   2.模板地址  3.类对象  4.文件导出名称
 */
@GetMapping(value = "/exportTemplate")
public void exportTemplate(HttpServletResponse response) throws Exception{

   PhoneModel model = new PhoneModel();
   model.setColor("金色");
   model.setPhoneName("苹果12 S");
   model.setPrice(9999);
   model.setSj(new Date());

   ExcelUtil.templateWrite(response,"E:\\新建XLSX 工作表.xlsx",model,"ce测试时");
}

//导出带文件名称但不带表头,文件名称用当前时间,年月日时分秒命名
@GetMapping(value = "/export")
public void testExport(HttpServletResponse response) throws Exception{
   List<PhoneModel> list = new ArrayList<>();
   PhoneModel model = null;
   for(int i=0;i<10;i++){
      model = new PhoneModel();
      model.setNum((i+1));
      model.setColor("金色"+i);
      model.setPhoneName("苹果"+i+"S");
      model.setPrice(i);
      model.setSj(new Date());
      list.add(model);
   }
   ExcelUtil.exportExcelOutputStream(response,list,PhoneModel.class);
}

 

//导出带文件名和表头,文件名称和表头保持一致
@GetMapping(value = "/exportHeader")
public void testExportHeader(HttpServletResponse response) throws Exception{
   List<PhoneModel> list = new ArrayList<>();
   PhoneModel model = null;
   for(int i=0;i<10;i++){
      model = new PhoneModel();
      model.setNum((i+1));
      model.setColor("金色"+i);
      model.setPhoneName("苹果"+i+"S");
      model.setPrice(i);
      model.setSj(new Date());
      list.add(model);
   }
   ExcelUtil.exportExcelOutputStream(response,list,PhoneModel.class,"文件名后面参数true标识表头也是同样名称",true);
}

 

引入pom

<!-- https://mvnrepository.com/artifact/net.oschina.likaixuan/excelutil -->
<dependency>
    <groupId>net.oschina.likaixuan</groupId>
    <artifactId>excelutil</artifactId>
    <version>3.1.0</version>
</dependency>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

How to Think About Algorithms

How to Think About Algorithms

Jeff Edmonds / Cambridge University Press / 2008-05-19 / USD 38.99

HOW TO THINK ABOUT ALGORITHMS There are many algorithm texts that provide lots of well-polished code and proofs of correctness. Instead, this one presents insights, notations, and analogies t......一起来看看 《How to Think About Algorithms》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具