Commit 908e4b7e authored by 付培阳's avatar 付培阳

值班导入导出

parent 7d1f1741
...@@ -120,7 +120,8 @@ public class ExcelUtil { ...@@ -120,7 +120,8 @@ public class ExcelUtil {
} }
} }
} }
// String s = new String(fileName.getBytes(), "UTF-8");
// response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(s, "UTF-8"));
ExcelWriterSheetBuilder excelWriterSheetBuilder = EasyExcel.write(getOutputStream(fileName, response, ExcelWriterSheetBuilder excelWriterSheetBuilder = EasyExcel.write(getOutputStream(fileName, response,
ExcelTypeEnum.XLSX)).head(dutyCarTitleList).excelType(ExcelTypeEnum.XLSX) ExcelTypeEnum.XLSX)).head(dutyCarTitleList).excelType(ExcelTypeEnum.XLSX)
.sheet(sheetName).registerWriteHandler(new TemplateCellWriteHandlerDate(explicitListConstraintMap)) .sheet(sheetName).registerWriteHandler(new TemplateCellWriteHandlerDate(explicitListConstraintMap))
...@@ -251,10 +252,12 @@ public class ExcelUtil { ...@@ -251,10 +252,12 @@ public class ExcelUtil {
//创建本地文件 //创建本地文件
String filePath = fileName + excelTypeEnum.getValue(); String filePath = fileName + excelTypeEnum.getValue();
try { try {
fileName = new String(filePath.getBytes(), StandardCharsets.ISO_8859_1); fileName = new String(filePath.getBytes(),"UTF-8");
response.setCharacterEncoding(StandardCharsets.UTF_8.name()); response.setCharacterEncoding(StandardCharsets.UTF_8.name());
response.setContentType("application/vnd.ms-excel"); response.setContentType("application/vnd.ms-excel");
response.addHeader("Content-Disposition", "filename=" + fileName); response.addHeader("Content-Disposition", "filename=" + fileName);
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName,
StandardCharsets.UTF_8.name()));
return response.getOutputStream(); return response.getOutputStream();
} catch (IOException e) { } catch (IOException e) {
throw new Exception("系统异常"); throw new Exception("系统异常");
......
...@@ -159,7 +159,7 @@ public class ExcelController extends BaseController { ...@@ -159,7 +159,7 @@ public class ExcelController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "上传文件数据-") @ApiOperation(value = "上传文件数据-")
@PostMapping("/upload") @PostMapping("/upload")
public void template2(MultipartFile multipartFile, ExcelDto excelDto) { public void template2(@RequestPart("file") MultipartFile multipartFile, ExcelDto excelDto) {
try { try {
switch (excelDto.getType()) { switch (excelDto.getType()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment