流程

image.png

测试写:

image.png
实体类注解,不需要第二个参数!
image.png
最后一行是核心:
三个方法:

  • write():

参数1:路径名/流
参数2:表头实体类名

  • sheet():

参数1:sheet名称(就是表格下面的类似标题的东西)

  • doWrite():

参数1:数据集合

测试读:

读和写相比,读更难操作一点!!!

  1. 写实体类,加注解(和写不一样的是,读需要在注解上多加一个参数)
  2. 写监听器
  3. 调用方法

image.png
第二个注解必须写
image.png
三个方法
第二个方法不是必须的!
image.png
三个方法:

  • read():
    • 参数1:读取路径
    • 参数2:表头实体类.class
    • 参数3:监听器
  • sheet():无参
  • doRead():无参

    测试:

    情况1:
    image.png image.png
    情况2:
    表头实体类注解不写第二个参数的情况:
    感觉写不写没啥区别
    image.png
    情况3:
    不写监听器的第二个方法的情况:
    不写这个方法,就不打印表头信息
    image.png