easypoi入门<1

摘要:
学习自:http://www.afterturn.cn/doc/easypoi.html开源地址:https://gitee.com/lemur/easypoihttps://gitee.com/lemur/easypoi-spring-boot-startermaven项目,加入依赖cn.afterturnea

学习自:http://www.afterturn.cn/doc/easypoi.html

开源地址:https://gitee.com/lemur/easypoi

https://gitee.com/lemur/easypoi-spring-boot-starter

maven项目,加入依赖

easypoi入门<1第1张easypoi入门<1第2张
<dependency>
            <groupId>cn.afterturn</groupId>
            <artifactId>easypoi-base</artifactId>
            <version>3.2.0</version>
        </dependency>
        <dependency>
            <groupId>cn.afterturn</groupId>
            <artifactId>easypoi-web</artifactId>
            <version>3.2.0</version>
        </dependency>
        <dependency>
            <groupId>cn.afterturn</groupId>
            <artifactId>easypoi-annotation</artifactId>
            <version>3.2.0</version>
        </dependency>
View Code

需要导出的数据实体加上注解

/*** 名字
     */@Excel(name="名字")
    privateString name;
    /*** 生日
     */@Excel(name="生日",format="yyyy-MM-dd",databaseFormat="yyyyMMddHHmmss")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    privateDate birthday;
    /*** 性别(1:男 2:女)
     */@Excel(name="性别",replace= {"男_1","女_2"},suffix="生")
    privateInteger sex;
    /*** 电子邮件
     */@Excel(name="电子邮件")
    privateString email;
    /*** 电话
     */@Excel(name="电话")
    private String phone;
@RequestMapping("/loadExcel")
    public voiddownloadByPoiBaseView(ModelMap map, HttpServletRequest request,
            HttpServletResponse response) {
        //这个要考虑offic Excel 是2007还是2003.2007可以导百万数据; 2003只能导6万超过的是空白,数据量特别大建议分sheet导或者分条件导
        List<User> list = userService.excelList(null);//查询数据库数据
        //List<User> list = new ArrayList<>();
        //new ExportParams(String title,String sheet,String suffix);分别是表头,页名称,文件类型
        ExportParams params = new ExportParams("用户信息","用户信息",ExcelType.XSSF);
        params.setFreezeCol(10);//冻结列(分割线/无论有多少列,拖动左右滚动条一直显示的列.)
        params.setStyle(ExcelExportStylerColorImpl.class);//设置样式,自定义实现IExcelDataHandler<T>
        map.put(NormalExcelConstants.DATA_LIST, list);//数据
        map.put(NormalExcelConstants.CLASS, User.class);//类型
        map.put(NormalExcelConstants.PARAMS, params);//excel参数
        map.put(NormalExcelConstants.FILE_NAME, "用户信息");
        
        PoiBaseView.render(map, request, response, NormalExcelConstants.EASYPOI_EXCEL_VIEW);//无返回值下载
    }

免责声明:文章转载自《easypoi入门&amp;lt;1》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇layer弹窗在IOS上,被软键盘挤到上边的解决方法HTML5 video 详解 属性 事件 方法下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

EasyPoi 导入导出Excel时使用GroupName的踩坑解决过程

一、开发功能介绍: 简单的一个excel导入功能 二、Excel导入模板(大致模板没写全): 姓名 性别 生日 客户分类 联系人姓名 联系人部门  备注 材料 综合 采购 张三 男 1994/05/25 1 1 1 张三 开发部   李四 男 1994/05/25 1 1 1 张三 开发部   王五 男 1994/05/25 1 1 1...

EasyPoi导出问题

导出代码如下:Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), PriceExcelModel.class, priceExcelModelList); File file = FileUtil.createFile(PROCEED_DATA_SOURCE_PATH);...

vue springboot利用easypoi实现简单导出

vue springboot利用easypoi实现简单导出 前言 一、easypoi是什么? 二、使用步骤 1.传送门 2.前端vue 3.后端springboot 3.1编写实体类(我这里是dto,也一样) 3.2控制层 结尾 前言 今天玩了一下vue springboot利用easypoi实现excel的导出,以前没玩过导入导出,...

EasyPoi使用入门

咱们在开发的时候,总会遇到需要通过代码操作办公软件的情况,而excel与word的操作最为频繁。 当然我们Java程序员可以选择JXL或者POI来完成相应的Excel操作,但是大家用过都知道,有些地方感觉还是不够简单,不那么尽如人意。 今天给大家介绍一个EasyPoi,就算我们不会底层的POI,也可以非常轻松的完成Excel的操作。EasyPoi,主打简单...

阿里 EasyExcel 使用及避坑

github地址:https://github.com/alibaba/easyexcel 原本在项目中使用EasyPoi读取excel,后来为了统一技术方案,改用阿里的EasyExcel。EasyExcel和EasyPoi有一定的相似之处。 EasyExcel和EasyPoi效率对比: 因为数据量少,从效率上看几乎没有差别,EasyExcel略胜一筹...

EasyPoi导入验证功能

1准备好要导入的Excel,注意Excel的标题要和domain中的@Excel(name = "标题")一样 1 导入验证包支持 <!-- JSR 303 规范验证包 --> <dependency> <groupId>org.hibernate</groupId> <artifactId&...