@RequestMapping("/downloadTemplate")
public void downloadTemplate(HttpServletResponse response) {
try {
response.setContentType("application/msexcel");
response.setHeader("Content-disposition",
new String("attachment;filename=批量导入模板.xlsx".getBytes("UTF-8"), "ISO-8859-1"));
ClassPathResource source = new ClassPathResource("templates/student_registration_form.xlsx");
InputStream input = null;
try {
input = source.getInputStream();
IOUtils.copy(input, response.getOutputStream());
} finally {
IOUtils.closeQuietly(input);
}
input.close();
} catch (Exception e) {
e.printStackTrace();
}
}
spring接口下载excel文件
最新推荐文章于 2024-05-06 18:19:26 发布