Giter VIP home page Giter VIP logo

easypoidemo's Introduction

easypoiDemo

easypoiDemo EasyPoi的几个入口工具类

1.ExcelExportUtil Excel导出(普通导出,模板导出)
2.ExcelImportUtil Excel导入
3.WordExportUtil Word导出(只支持docx ,doc版本poi存在图片的bug,暂不支持)

关于Excel导出XLS和XLSX区别

1.导出时间XLS比XLSX快2-3倍
2.导出大小XLS是XLSX的2-3倍或者更多
3.导出需要综合网速和本地速度做考虑

注解

###Excel

  • @ExcelTarget:设置到导出实体类上作为实体类的唯一标识

      @ExcelTarget("student")
      public class Student extends BaseEntity {
      
      }
    
  • @Excel:导出基础注解-->设置到普通属性上

  • @ExcelEntity:设置到导出实体类中的复合属性上

  • @ExcelCollection: 标示集合

  • @ExcelIgnore: 忽略字段--->去除迭代循环进入死循环

  • ExportParams:导出参数设置,title(表的标题)


EasyPoi 模板 表达式支持

  • 空格分割
  • 三目运算 {{test ? obj:obj2}}
  • n: 表示 这个cell是数值类型 {{n:}}
  • le: 代表长度{{le:()}} 在if/else 运用{{le:() > 8 ? obj1 : obj2}}
  • fd: 格式化时间 {{fd:(obj;yyyy-MM-dd)}}
  • fn: 格式化数字 {{fn:(obj;###.00)}}
  • fe: 遍历数据,创建row
  • !fe: 遍历数据不创建row
  • $fe: 下移插入,把当前行,下面的行全部下移.size()行,然后插入
  • !if: 删除当前列 {{!if:(test)}}
  • 单引号表示常量值 '' 比如'1' 那么输出的就是 1
  • &NULL& 控制
  • ]] 换行符
  1. 模板导出

    1. ExcelExportUtil.exportExcel(params, map);//第二个参数为模板参数,key为模板中定义的名称 value为赋予的值
    2. {{!fe:list t.name 其中list标识在excle模板中定义的名称,将作为map传值时使用的key
    3. 注意事项:
      1. {{--->用于表示循环迭代数据开始
      2. }}--->用于表示结束
  2. 导入:

    1. 使用ExcelImportUtil进行导入:通过实体类添加注解的方式,在导入数据中表头需要对应实体类注解的name属性

    2. 设置导入参数的起始行无效,需要通过设置表头的位置来标识读取数据的位置

       ImportParams params=new ImportParams();
       //设置表头的位置
       params.setTitleRows(1);
      

easypoidemo's People

Contributors

tlhhup avatar

Stargazers

moocstudent avatar  avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.