使用easyexcel匯出excel檔案

2021-09-10 09:43:57 字數 1896 閱讀 3456

這裡是匯出乙個excel檔案,裡面有兩個sheet

分別是稅賦**表和發票彙總表

controller層

public resultexportexcel(string uid, string accountcodelist, date startdate, date enddate, httpservletresponse response) ,開始時間{},結束時間{},uid:{}",, accountcodelist, startdate, enddate, uid);

try );

map> map = new hashmap<>();

map.put("稅賦**表", taxforeeolist);

map.put("發票彙總表", invoicetaxforeeos);

easyexcelutils.createexcelstreammutilbyeay***cel(response, map, exceltypeenum.xlsx);

} catch (exception e)

return result.success("匯出成功");

}資料模型 exceldate

/**

* @classname taxforecastdto

* @author laixiaoxing

* @date 2019/1/26 下午2:09

* @description 發票彙總表

* @version 1.0

*/@data

@tostring

public class invoicetaxforeeo extends baserowmodel

/** * @classname taxforecastdto

* @author laixiaoxing

* @date 2019/1/26 下午2:09

* @description 稅賦**表dto

* @version 1.0

*/@data

@tostring

public class taxforeeo extends baserowmodel

封裝的工具類

/**

* @classname easyexcelutils

* @author laixiaoxing

* @date 2019/1/30 下午11:59

* @description 封裝的easyexcel匯出工具類

* @version 1.0

*/@slf4j

public class easyexcelutils catch (ioexception e)

}/**

* @author laixiaoxing

* @description //setsheet資料

* @date 上午12:39 2019/1/31

*/private static void setsheet(map> sheetnameanddatelist, excelwriter writer)

}/**

* @author laixiaoxing

* @description 校驗引數

* @date 上午12:39 2019/1/31

*/private static boolean checkparam(map> sheetnameanddatelist, exceltypeenum type) else if (type == null)

return false;}}

匯出結果如下

使用easyexcel完成匯出功能

先在pom檔案裡面匯入jar包 版本號根據你專案而定 com.alibaba groupid easyexcel artifactid 2.2.6 version dependency 2.可以開始寫 邏輯了 設定檔名稱 這裡urlencoder.encode可以防止中文亂碼 當然和easyexce...

EasyExcel匯入匯出

註解 匯出 匯出 excel 乙個 sheet,帶表頭 param list 資料 list,每個元素為乙個 baserowmodel param filename 匯出的檔名 param sheetname 匯入檔案的 sheet 名 param model 對映實體類,excel 模型 匯出檔案...

利用easyexcel匯出檔案

1.這裡首先展示一下需要匯出的資料庫資料 2.首先pom檔案引入jar包 com.alibaba easyexcel 2.1.6 3.建立實體類 data public class testexcelinfo select t.name,t.id,t.text from t export info ...