1.增加导出模板下拉框设置
2.支持台区导入和发电用户导入模板 3.添加灿能云远程监测点接口,流量信息
This commit is contained in:
@@ -2,6 +2,8 @@ package com.njcn.poi.excel;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.export.ExcelExportService;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import com.njcn.web.utils.HttpServletUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -20,6 +22,8 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -54,13 +58,28 @@ public class ExcelUtil {
|
||||
* @param fileName 文件名
|
||||
*/
|
||||
public static void exportExcel(ExportParams exportParams,String fileName, Class<?> pojoClass, Collection<?> dataSet) {
|
||||
exportExcelPullDown(exportParams,fileName,null ,pojoClass, dataSet);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 指定名称、数据下载报表(带指定标题将*显示比必填信息),带有下拉信息
|
||||
*
|
||||
* @param fileName 文件名
|
||||
*/
|
||||
public static void exportExcelPullDown(ExportParams exportParams, String fileName, List<PullDown> pullDowns, Class<?> pojoClass, Collection<?> dataSet) {
|
||||
HttpServletResponse response = HttpServletUtil.getResponse();
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
fileName = URLEncoder.encode(fileName, CharsetUtil.UTF_8);
|
||||
response.reset();
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + fileName );
|
||||
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, dataSet);
|
||||
if(CollUtil.isNotEmpty(pullDowns)){
|
||||
for (PullDown pullDown : pullDowns) {
|
||||
ExcelUtil.selectList(workbook, pullDown.getFirstCol(), pullDown.getLastCol(), pullDown.getStrings().toArray(new String[]{}));
|
||||
}
|
||||
}
|
||||
Sheet sheetAt = workbook.getSheetAt(0);
|
||||
//获取列数
|
||||
int physicalNumberOfCells = sheetAt.getRow(0).getPhysicalNumberOfCells();
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.poi.excel;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wr 设置下拉
|
||||
* @description
|
||||
* @date 2023/11/23 11:38
|
||||
*/
|
||||
@Data
|
||||
public class PullDown {
|
||||
|
||||
//起始列
|
||||
private Integer firstCol;
|
||||
//结束列
|
||||
private Integer lastCol;
|
||||
//属性值
|
||||
private List<String> strings;
|
||||
}
|
||||
Reference in New Issue
Block a user