• easyexcel导出导入


    https://programmer.group/easyexcel-java-api-usage.html

    public class ExcelEasyWrite {
        public static void main(String[] args) {
            /**
             * pathName File path to write
             * head Encapsulates the type of entity written
             * return Written workbook object
             */
            // Workbook object
            ExcelWriterBuilder writerBuilder = EasyExcel.write("/Users/hudu/Documents/Study/EasyExcel/write.xlsx", Student.class);
            // Worksheet object
            ExcelWriterSheetBuilder sheet = writerBuilder.sheet();
            // Prepare data
            List<Student> students = initData();
            // write
            sheet.doWrite(students);
        }
    
        private static List<Student> initData() {
            ArrayList<Student> students = new ArrayList<>();
            for (int i = 10; i < 20; i++) {
                Student student = new Student();
                student.setName("test"+i);
                student.setBirthday(new Date());
                student.setGender("male");
                students.add(student);
            }
            return students;
        }
    }
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    // Globally define column width
    @ColumnWidth(10)
    // Content line height
    //@ContentRowHeight(10)
    // Header row height
    @HeadRowHeight(20)
    public class Student {
        /**
         * value Field name
         * index Column order
         */
        @ExcelProperty(value = {"Student information sheet","full name"},index = 0)
        private String name;
        @ExcelProperty(value = {"Student information sheet","date of birth"},index = 2)
        @DateTimeFormat("YYYY-MM-dd")
        @ColumnWidth(20)
        private Date birthday;
        @ExcelProperty(value = {"Student information sheet","Gender"},index = 1)
        private String gender;
        /**
         * Ignore field
         */
        @ExcelIgnore
        private String id;

  • 相关阅读:
    Postfix 邮件服务器搭建
    DER、CRT、CER、PEM格式的证书及转换
    Apache SSL 服务搭建
    scapy 中的ARP
    关于linux特殊含义的转义符33
    关于javascript中defineProperty的学习
    python QT 编程之路
    python socket编程制作后门木马(原创)
    mybatis学习——映射器(mappers)
    mybatis学习——properties属性实现引用配置文件
  • 原文地址:https://www.cnblogs.com/springcloud/p/16085169.html
Copyright © 2020-2023  润新知