Commit 10a5f283 by Jbb

下载excel 乱码问题

parent d9d21b1d
......@@ -55,6 +55,7 @@ public class TbStLayerDataController {
@RequestParam(required = false) String lrdwdc, HttpServletResponse response) {
TbStLayer tbStLayer = new TbStLayer();
String layerId = KeyUtil.getUUIDKey("L");
ServletOutputStream outputStream = null;
try {
tbStLayer.setXxzjbh(layerId);
tbStLayer.setName(name);
......@@ -192,18 +193,19 @@ public class TbStLayerDataController {
rowData.createCell(3).setCellValue(timeFormat);
}
//通过输出流下载
ServletOutputStream outputStream = response.getOutputStream();
//设置文件响应输出格式
response.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename=error.xlsx");
wb.write(outputStream);
outputStream = response.getOutputStream();
//设置文件响应输出格式
//wb.write(outputStream);
outputStream.flush();
outputStream.close();
}
return MapRestResult.build(200,"数据上传成功!",null);
return MapRestResult.build(200,"数据上传成功!",outputStream);
} catch (Exception e) {
e.printStackTrace();
//如果失败了就将之前的数据删除....
//如果保存数据、poi生成excel失败了就将之前的数据删除....
tbStLayerService.removeById(layerId);
accidentPointService.deleteByGlId(layerId);
return MapRestResult.build(500,"数据上传失败!",null);
......
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