1. SPRING MVC 生成EXCEL
@RequestMapping(value = "/requestFileByJson", method = RequestMethod.POST)
public void getListByCallFunction(
@RequestBody String data,
HttpServletRequest request,
HttpServletResponse response, HttpSession session) throws Exception {
response.setContentType("application/ms-excel;charset=UTF-8");
response.setHeader("Content-Disposition","attachment;filename=".concat(String.valueOf(URLEncoder.encode(systemID + "_"+JName+".xls", "UTF-8"))));
OutputStream out = response.getOutputStream();
String sheetName = "导出WEBEDI";
String titleNames = null;
resultMapList = new ArrayList();
HSSFWorkbook excel = excelWordService.getExcelByDataMap(resultMapList,sheetName,titleNames);
excel.write(out);
out.flush();
}
2. 使用MockMvc 进行测试生成的EXCEL
@Test
public void testInserOneLine() throws Ex

本文介绍如何利用Spring MockMvc框架来测试Spring MVC应用程序中生成的Excel文件。通过对控制器方法的模拟调用,确保Excel数据的正确性和格式的一致性。
最低0.47元/天 解锁文章
1038





