excel多sheet导出

   /**
     * excel多sheet导出
     */
    public void exportSheetUsers () {
  
        List <GysuserAndagentVo> users=new ArrayList <> ();

        List <GysexcelAgents> agents=new ArrayList <> ();
        //功能描述:把同一个表格多个sheet测试结果重新输出,
        Workbook workBook=null;
        try {
            // 创建参数对象(用来设定excel的sheet1内容等信息)
            ExportParams userExportParams=new ExportParams ( );
            // 设置sheet得名称
            userExportParams.setSheetName ( "用户表" );
            // 设置sheet表头名称
            userExportParams.setTitle ( "用户列表" );
            // 创建sheet1使用得map
            Map <String, Object> userExportMap=new HashMap <> ( );
            // title的参数为ExportParams类型,目前仅仅在ExportParams中设置了sheetName
            userExportMap.put ( "title", userExportParams );
            // 模版导出对应得实体类型
            userExportMap.put ( "entity", GysuserAndagentVo.class );
            // sheet1中要填充得数据
            userExportMap.put ( "data", users );
            // 创建参数对象(用来设定excel的sheet2内容等信息)
            ExportParams logInfoExportParams=new ExportParams ( );
            logInfoExportParams.setTitle ( "关系表" );
            logInfoExportParams.setSheetName ( "关系" );
            // 创建sheet2使用的map
            Map <String, Object> logInfoExportMap=new HashMap <> ( );
            logInfoExportMap.put ( "title", logInfoExportParams );
            logInfoExportMap.put ( "entity", GysexcelAgents.class );
            // sheet2中要填充得数据
            logInfoExportMap.put ( "data", agents );
            // 将sheet1、sheet2使用得map进行包装
            List <Map <String, Object>> sheetsList=new ArrayList <> ( );
            //后续增加sheet组,则后面继续追加即可;
            sheetsList.add ( userExportMap );
            sheetsList.add ( logInfoExportMap );
            // 执行方法
            workBook=ExcelExportUtil.exportExcel ( sheetsList, ExcelType.HSSF );
            String path1=path + "/excel/" ;
            String fillname=userCode + euuid + ".xlsx";
            File myPath = new File(path1);
            log.info ( "文件夹路径:"+path1+fillname );
            if ( !myPath.exists()){//若此目录不存在,则创建之// 这个东西只能简历一级文件夹,两级是无法建立的。。。。。
                boolean mkdir=myPath.mkdir ( );
                log.info("创建文件夹路径为:"+ path1+fillname);
            }
            FileOutputStream out=new FileOutputStream ( path1+fillname );
            workBook.write ( out );
            workBook.close ( );
        } catch (Exception e) {
            e.printStackTrace ( );
        } finally {
            if (workBook != null) {
                try {
                    //强行关流
                    workBook.close ( );
                } catch (IOException e) {
                    e.printStackTrace ( );
                }
            }
        }
    }

        <dependency>
            <groupId>cn.afterturn</groupId>
            <artifactId>easypoi-spring-boot-starter</artifactId>
            <version>4.4.0</version>
        </dependency>