Commit 7c64eda2 by Jbb

excel下载有问题 让前端解析

parent 1002e0cc
...@@ -48,18 +48,18 @@ public class TbStLayerDataController { ...@@ -48,18 +48,18 @@ public class TbStLayerDataController {
* @param lrr * @param lrr
* @param lrdwdm * @param lrdwdm
* @param lrdwdc * @param lrdwdc
* @param response
* @return * @return
*/ */
@RequestMapping("/uploadExcel") @RequestMapping("/uploadExcel")
public MapRestResult uploadDown(@RequestParam("excelFile") MultipartFile excelFile, public MapRestResult uploadDown(@RequestParam("excelFile") MultipartFile excelFile,
@RequestParam(required = false) String name,@RequestParam(required = false) Double threshold, @RequestParam(required = false) String name,@RequestParam(required = false) Double threshold,
@RequestParam(required = false) String lrr,@RequestParam(required = false) String lrdwdm, @RequestParam(required = false) String lrr,@RequestParam(required = false) String lrdwdm,
@RequestParam(required = false) String lrdwdc, HttpServletResponse response) { @RequestParam(required = false) String lrdwdc) {
TbStLayer tbStLayer = new TbStLayer(); TbStLayer tbStLayer = new TbStLayer();
String layerId = KeyUtil.getUUIDKey("L"); String layerId = KeyUtil.getUUIDKey("L");
ServletOutputStream outputStream = null; /*ServletOutputStream outputStream = null;
byte[] bytes = null; byte[] bytes = null;
Boolean flag = null;*/
try { try {
tbStLayer.setXxzjbh(layerId); tbStLayer.setXxzjbh(layerId);
tbStLayer.setName(name); tbStLayer.setName(name);
...@@ -175,7 +175,7 @@ public class TbStLayerDataController { ...@@ -175,7 +175,7 @@ public class TbStLayerDataController {
pointList.add(errorData); pointList.add(errorData);
} }
} }
XSSFWorkbook wb = new XSSFWorkbook(); /*XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet(); XSSFSheet sheet = wb.createSheet();
if(pointList != null && pointList.size() > 0){ if(pointList != null && pointList.size() > 0){
//输出流写入到excel中 //输出流写入到excel中
...@@ -196,9 +196,9 @@ public class TbStLayerDataController { ...@@ -196,9 +196,9 @@ public class TbStLayerDataController {
rowData.createCell(2).setCellValue(title); rowData.createCell(2).setCellValue(title);
rowData.createCell(3).setCellValue(timeFormat); rowData.createCell(3).setCellValue(timeFormat);
} }
} }*/
//通过输出流下载 //通过输出流下载
response.setContentType("application/vnd.ms-excel"); /*response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename=error.xlsx"); response.setHeader("Content-Disposition", "attachment;filename=error.xlsx");
outputStream = response.getOutputStream(); outputStream = response.getOutputStream();
//设置文件响应输出格式 //设置文件响应输出格式
...@@ -208,16 +208,19 @@ public class TbStLayerDataController { ...@@ -208,16 +208,19 @@ public class TbStLayerDataController {
response.setContentType("application/msexcel;charset=utf-8"); response.setContentType("application/msexcel;charset=utf-8");
bytes = os.toByteArray(); bytes = os.toByteArray();
outputStream.write(bytes); outputStream.write(bytes);
/*wb.write(outputStream); *//*wb.write(outputStream);
wb.close(); wb.close();
outputStream.flush(); outputStream.flush();
outputStream.close();*/ outputStream.close();*//*
return MapRestResult.build(200,"数据上传成功!",bytes); flag = true;*/
//return null;
return MapRestResult.build(200,"数据上传成功!",pointList);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
//如果保存数据、poi生成excel失败了就将之前的数据删除.... //如果保存数据、poi生成excel失败了就将之前的数据删除....
tbStLayerService.removeById(layerId); tbStLayerService.removeById(layerId);
accidentPointService.deleteByGlId(layerId); accidentPointService.deleteByGlId(layerId);
//flag = false;
return MapRestResult.build(500,"数据上传失败!",null); 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