• poi导出excle测试类


    package poiexcel;
    
    import java.util.ArrayList;
    import java.util.List;
    
    public class Test {
    
        public static void main(String[] args) {
            PoiExcelExport pee = new PoiExcelExport("/Users/tusm/work/test.xls","renyuan");
            //数据
            List<Man> dataList = new ArrayList<>();
            Man man1 = new Man("张三",20,"男",(float)10000.8);
            Man man2 = new Man("李四",21,"男",(float)11000.8);
            Man man3 = new Man("王五",22,"女",(float)1200.8);
            Man man4 = new Man("赵六",23,"男",(float)13000.8);
            Man man5 = new Man("田七",24,"男",(float)14000.8);
            Man man6 = new Man();
            man6.setName("老八");
            dataList.add(man1);dataList.add(man2);dataList.add(man3);dataList.add(man4);dataList.add(man5);
            dataList.add(man6);
            //调用
            String titleColumn[] = {"name","sex","idCard","salary",""};
            String titleName[] = {"姓名","性别","身份证号","月薪","年薪"};
            int titleSize[] = {13,13,13,13,13};
            //其他设置 set方法可全不调用
            String colFormula[] = new String[5];
            colFormula[4] = "D@*12";   //设置第5列的公式
            pee.setColFormula(colFormula);
            pee.setAddress("A:D");  //自动筛选 
            
            pee.wirteExcel(titleColumn, titleName, titleSize, dataList);
        }
    
    }

    实体类

    package poiexcel;
    
    public class Man {
        private String name;
        private int sex;
        private String idCard;
        private float salary;
        public Man(String name, int sex, String idCard, float salary) {
            super();
            this.name = name;
            this.sex = sex;
            this.idCard = idCard;
            this.salary = salary;
        }
        
        public Man() {
            super();
        }
    
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public int getSex() {
            return sex;
        }
        public void setSex(int sex) {
            this.sex = sex;
        }
        public String getIdCard() {
            return idCard;
        }
        public void setIdCard(String idCard) {
            this.idCard = idCard;
        }
        public float getSalary() {
            return salary;
        }
        public void setSalary(float salary) {
            this.salary = salary;
        }
        
    
    }
  • 相关阅读:
    跨域请求
    django数据模型中关于on_delete, db_constraint的使用
    rest-framework之分页器
    跨域请求
    相对路径与绝对路径
    html常用标签
    ES6中字符串扩展
    javascript中startswith和endsWidth 与 es6中的 startswith 和 endsWidth
    Angular6 组件树结构优化
    docker限制容器内存使用上限
  • 原文地址:https://www.cnblogs.com/lambertwe/p/5730683.html
Copyright © 2020-2023  润新知