Commit 7c64eda2 by Jbb

excel下载有问题 让前端解析

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