import org.apache.commons.beanutils.PropertyUtilsBean;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import java.beans.PropertyDescriptor;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/***
* POI 多线程多sheet导出数据
*/
public class ThreadExcelUtils {
/**
* 定义每个 sheet 最多数量
*/
public static final Integer EXCEL_MAX_CNT = 50000;
private Workbook wb;
private String fileName;
private String filePath;
private String[] hearders;
private String[] fields;
public Workbook getWb() {
return wb;
}
public String getFileName() {
return fileName;
}
public String getFilePath() {
return filePath;
}
public String[] getHearders() {
return hearders;
}
public String[] getFields() {
return fields;
}
/**
* @param fileName
* 文件名称
* @param filePath
* 文件路径
* @param hearders
* 文件头
* @param fields
* 字段属性
*/
public ThreadExcelUtils(String fileName, String filePath,
String[] hearders, String[] fields) {
this.wb = new HSSFWorkbook();
this.fileName = fileName;
this.filePath = filePath;
this.hearders = hearders;
this.fields = fields;
}
public static void main(String[] args) throws Exception {
List<Map<String, Object>> lists = new ArrayList<Map<String, Object>>();
// 造数据
for (int i = 0; i < 10000; i++) {
Map<
POI 多线程多sheet导出数据
最新推荐文章于 2024-07-26 03:05:54 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)