This repository was archived by the owner on Apr 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed
src/main/java/io/github/biezhi/excel/plus/writer Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 1
1
package io .github .biezhi .excel .plus .writer ;
2
2
3
3
import io .github .biezhi .excel .plus .Constant ;
4
- import io .github .biezhi .excel .plus .enums .ExcelType ;
5
4
import io .github .biezhi .excel .plus .exception .ExcelException ;
6
5
import io .github .biezhi .excel .plus .utils .ExcelUtils ;
7
6
import io .github .biezhi .excel .plus .utils .Pair ;
8
- import org .apache .poi .hssf .usermodel .HSSFWorkbook ;
9
- import org .apache .poi .ss .usermodel .*;
7
+
8
+ import org .apache .poi .ss .usermodel .Cell ;
9
+ import org .apache .poi .ss .usermodel .CellStyle ;
10
+ import org .apache .poi .ss .usermodel .Row ;
11
+ import org .apache .poi .ss .usermodel .Sheet ;
12
+ import org .apache .poi .ss .usermodel .Workbook ;
13
+ import org .apache .poi .ss .usermodel .WorkbookFactory ;
10
14
import org .apache .poi .ss .util .CellRangeAddress ;
11
- import org .apache .poi .xssf .usermodel .XSSFWorkbook ;
12
15
13
16
import java .io .InputStream ;
14
17
import java .io .OutputStream ;
Original file line number Diff line number Diff line change 1
1
package io .github .biezhi .excel .plus .writer ;
2
2
3
3
import io .github .biezhi .excel .plus .enums .ExcelType ;
4
+
5
+ import org .apache .poi .hssf .usermodel .HSSFWorkbook ;
4
6
import org .apache .poi .ss .usermodel .CellStyle ;
5
7
import org .apache .poi .ss .usermodel .Workbook ;
8
+ import org .apache .poi .xssf .streaming .SXSSFWorkbook ;
9
+ import org .apache .poi .xssf .usermodel .XSSFWorkbook ;
6
10
7
11
import java .util .Collection ;
8
12
import java .util .function .Function ;
15
19
*/
16
20
public class Exporter <T > {
17
21
22
+ private static final Integer BIG_DATA_EXCEL_BOUNDARY = 10000 ;
23
+
18
24
private String headerTitle ;
19
25
private String templatePath ;
20
26
private ExcelType excelType ;
@@ -100,4 +106,12 @@ public ExcelType getExcelType() {
100
106
return excelType ;
101
107
}
102
108
109
+
110
+ Workbook createWorkbook () {
111
+ if (getExcelType () == ExcelType .XLSX ) {
112
+ return getData ().size () > BIG_DATA_EXCEL_BOUNDARY ? new SXSSFWorkbook (): new XSSFWorkbook ();
113
+ }
114
+ return new HSSFWorkbook ();
115
+ }
116
+
103
117
}
You can’t perform that action at this time.
0 commit comments