forked from github/dataease
perf: 导出Excel时,XSSFWorkbook -> SXSSFWorkbook
This commit is contained in:
parent
00a3da756e
commit
f16cb738d1
@ -15,6 +15,7 @@ import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
|
||||
@ -24,7 +25,7 @@ public class ExcelUtils {
|
||||
|
||||
public static File exportExcel(List<ExcelSheetModel> sheets, String fileName, String folderId) throws Exception {
|
||||
AtomicReference<String> realFileName = new AtomicReference<>(fileName);
|
||||
Workbook wb = new XSSFWorkbook();
|
||||
Workbook wb = new SXSSFWorkbook();
|
||||
|
||||
sheets.forEach(sheet -> {
|
||||
|
||||
|
@ -7,6 +7,7 @@ import org.apache.poi.hssf.eventusermodel.*;
|
||||
import org.apache.poi.hssf.eventusermodel.dummyrecord.LastCellOfRowDummyRecord;
|
||||
import org.apache.poi.hssf.eventusermodel.dummyrecord.MissingCellDummyRecord;
|
||||
import org.apache.poi.hssf.record.*;
|
||||
import org.apache.poi.hssf.record.Record;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDataFormatter;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
|
@ -67,6 +67,7 @@ import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -2964,7 +2965,7 @@ public class DataSetTableService {
|
||||
details.add(row);
|
||||
}
|
||||
// 操作Excel
|
||||
Workbook wb = new XSSFWorkbook();
|
||||
Workbook wb = new SXSSFWorkbook();
|
||||
// Sheet
|
||||
Sheet detailsSheet = wb.createSheet("数据");
|
||||
//给单元格设置样式
|
||||
|
@ -45,6 +45,7 @@ import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.pentaho.di.core.util.UUIDUtil;
|
||||
import org.slf4j.Logger;
|
||||
@ -660,7 +661,7 @@ public class PanelGroupService {
|
||||
Integer[] excelTypes = request.getExcelTypes();
|
||||
details.add(0, request.getHeader());
|
||||
|
||||
Workbook wb = new XSSFWorkbook();
|
||||
Workbook wb = new SXSSFWorkbook();
|
||||
//明细sheet
|
||||
Sheet detailsSheet = wb.createSheet("数据");
|
||||
|
||||
|
@ -27,9 +27,8 @@ import io.dataease.service.system.SystemParameterService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.*;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -384,13 +383,13 @@ public class LogService {
|
||||
details.add(0, headArr);
|
||||
|
||||
|
||||
XSSFWorkbook wb = new XSSFWorkbook();
|
||||
Workbook wb = new SXSSFWorkbook();
|
||||
//明细sheet
|
||||
XSSFSheet detailsSheet = wb.createSheet("数据");
|
||||
Sheet detailsSheet = wb.createSheet("数据");
|
||||
|
||||
//给单元格设置样式
|
||||
XSSFCellStyle cellStyle = wb.createCellStyle();
|
||||
XSSFFont font = wb.createFont();
|
||||
CellStyle cellStyle = wb.createCellStyle();
|
||||
Font font = wb.createFont();
|
||||
//设置字体大小
|
||||
font.setFontHeightInPoints((short) 12);
|
||||
//设置字体加粗
|
||||
@ -404,11 +403,11 @@ public class LogService {
|
||||
|
||||
if (CollectionUtils.isNotEmpty(details)) {
|
||||
for (int i = 0; i < details.size(); i++) {
|
||||
XSSFRow row = detailsSheet.createRow(i);
|
||||
Row row = detailsSheet.createRow(i);
|
||||
String[] rowData = details.get(i);
|
||||
if (rowData != null) {
|
||||
for (int j = 0; j < rowData.length; j++) {
|
||||
XSSFCell cell = row.createCell(j);
|
||||
Cell cell = row.createCell(j);
|
||||
cell.setCellValue(rowData[j]);
|
||||
if (i == 0) {// 头部
|
||||
cell.setCellStyle(cellStyle);
|
||||
|
Loading…
Reference in New Issue
Block a user