**數據量大超過5W,還在100W以內的數據導出處理**
>[info] 1.3.8+ 支持
[TOC]
## 方法介紹
1.注解方式
~~~
ExcelExportUtil.exportBigExcel(ExportParams entity, Class<?> pojoClass,IExcelExportServer server, Object queryParams)
~~~
2.自定義方式
~~~
ExcelExportUtil.exportBigExcel(ExportParams entity, List<ExcelExportEntity> excelParams,IExcelExportServer server, Object queryParams)
~~~
## 傳參介紹
| 參數 | 含義|
|------|------|
| ExportParams entity | 導出參數屬性,例如表格標題、名稱等等 |
| Class<?> pojoClass | Excel對象Class(注解方式) |
| List<ExcelExportEntity> excelParams | 導出工具類集合,對cell做處理(自定義) |
| IExcelExportServer server | 查詢數據的接口 |
|Object queryParams | 查詢數據的參數 |
## 使用示例(注解)
~~~
import org.apache.poi.ss.usermodel.Workbook;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.handler.inter.IExcelExportServer;
import org.junit.Test;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class ExcelExportBigData {
@Test
public void bigDataExport() throws Exception {
Workbook workbook = null;
Date start = new Date();
//設置表格標題
ExportParams params = new ExportParams("大數據測試","測試");
/**
* params:(表格標題屬性)篩選條件,sheet值
* TestEntity:表格的實體類
* IExcelExportServer:查詢數據接口
*/
workbook = ExcelExportUtil.exportBigExcel(params, TestEntity.class, new IExcelExportServer() {
/**
* obj 就是下面的10,限制條件
* page 是頁數,他是在分頁進行文件轉換,page每次+1
*/
@Override
public List<Object> selectListForExcelExport(Object obj, int page) {
//page每次加一,當等于obj的值時返回空,代碼結束;
//特別注意,最好每次10000條,否則,可能有內存溢出風險
if (((int) obj) == page) {
return null;
}
//不是空時:一直循環運行selectListForExcelExport。每次返回1萬條數據。
List<Object> list = new ArrayList<Object>();
for (int i = 0; i < 10000; i++) {
TestEntity client = new TestEntity();
client.setName("小明" + i);
client.setAge(i);
list.add(client);
}
return list;
}
}, 10);
System.out.println(new Date().getTime() - start.getTime());
File savefile = new File("D:/excel/");
if (!savefile.exists()) {
savefile.mkdirs();
}
FileOutputStream fos = new FileOutputStream("D:/excel/bigDataExport.xlsx");
workbook.write(fos);
fos.close();
}
}
~~~
TestEntity :
~~~
import org.jeecgframework.poi.excel.annotation.Excel;
public class TestEntity implements java.io.Serializable {
@Excel(name = "姓名", width = 15)
private String name;
@Excel(name = "年齡", width = 15)
private Integer age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
~~~
## 導出效果

- 1.前傳
- 1.1前言
- 1.2 Autopoi 介紹
- 1.3 使用
- 1.4 測試項目
- 1.5 快速文檔
- 1.6 示例
- 1.6.1 單表數據導出多表頭示例
- 單表數據多表頭導入注意bak
- 1.6.2 單表數據導出多sheet示例
- 1.6.3 excel根據模板導出
- 1.6.4 一對多導出needMerge示例
- 1.6.5 大數據導出示例
- 1.7 導出自定義選擇列導出
- 2. Excel 注解版
- 2.0 @excel注解的使用
- 2.1 Excel導入導出
- 2.2 注解
- 2.3 注解導出,導入
- 2.3.1 對象定義
- 2.3.2 集合定義
- 2.3.3 圖片的導出
- 2.3.4 Excel導入介紹
- 2.3.5 Excel導入小功能
- 2.3.6 圖片的導入
- 2.3.7 Excel多Sheet導出
- 2.4 注解變種-更自由的導出
- 2.5 Map導入,自由發揮
- 2.6 Excel的樣式自定義
- 2.7 如何自定義數據處理
- 2.8 Excel導入校驗(暫不支持)
- 2.9 Excel 大批量讀取
- 2.10 Excel大數據導出
- 2.11 groupname和ExcelEntity的name屬性
- 3. Excel 模板版
- 3.1 模板 指令介紹
- 3.2 基本導出
- 3.3 模板當中使用注解
- 3.4 圖片導出
- 3.5 橫向遍歷
- 4. Excel<->Html
- 4.1 Excel 的Html預覽
- 4.2 html轉Excel更神奇的導出
- 5. Word
- 5.1 word模板導出
- 6. PDF
- 7. Spring MVC
- 7.1 View 介紹
- 7.2 大數據導出View的用法
- 7.3 注解導出View用法
- 7.4 注解變種Map類型的導出View
- 7.5Excel模板導出View
- 7.6 PoiBaseView.render view的補救
- 8.問題歸檔
- 9.大數據量處理
- 10.autopoi升級4.0版本修改記錄