public static boolean list2Xls(ExcelConfig config, List<?> list, String filePath, String fileName) throws Exception {
        //创建目录
        File file = new File(filePath);
        if (!(file.exists())) {
            if (!file.mkdirs()) {
                throw new RuntimeException("创建导出目录失败!");
            }
        }
        OutputStream outputStream = null;
        try {
            if (!fileName.toLowerCase().endsWith(EXCEL)) {
                fileName += EXCEL;
            }
            File excelFile = new File(filePath + "/" + fileName);
            outputStream = new FileOutputStream(excelFile);
            return list2Xls(config, list, outputStream);
        } catch (Exception e1) {
            return false;
        } finally {
            if(outputStream != null){
                outputStream.close();
            }
        }
    }
public static boolean list2Xls ( ExcelConfig config , List < ? > list , String filePath , String fileName ) throws Exception { File file = new File ( filePath ) ; if ( ! ( file . exists ( ) ) ) { if ( ! file . mkdirs ( ) ) { throw new RuntimeException ( "创建导出目录失败!" ) ; } } OutputStream outputStream = null ; try { if ( ! fileName . toLowerCase ( ) . endsWith ( EXCEL ) ) { fileName += EXCEL ; } File excelFile = new File ( filePath + "/" + fileName ) ; outputStream = new FileOutputStream ( excelFile ) ; return list2Xls ( config , list , outputStream ) ; } catch ( Exception e1 ) { return false ; } finally { if ( outputStream != null ) { outputStream . close ( ) ; } } }
导出list对象到excel

@param config   配置
@param list     导出的list
@param filePath 保存xls路径
@param fileName 保存xls文件名
@return 处理结果，true成功，false失败
@throws Exception