首页>代码>spring mvc导出excel、csv、access、sql等文件格式>/com.excel/src/main/java/com/chen/controller/ExcelController.java
package com.chen.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.chen.util.ExcelUtil;
/**
*
* @author chenguoji
* @qq 375136957
*/
@Controller
public class ExcelController {
/**
* 跳转页面
*
* @return
*/
@RequestMapping("/toExcel")
public String toExcel() {
return "excel";
}
/**
* 导出Excel 并下载
*/
@RequestMapping("/exportExcel")
public void exportExcel(HttpServletRequest request,HttpServletResponse response) {
String fileName = "students.xls";
// 得到保存文件的保存目录
String savePath = request.getServletContext().getRealPath("/excel");
// 创建excel
ExcelUtil.createExcel(savePath,fileName);
//下载
ExcelUtil.exportFile(request, response, savePath, fileName);
}
}
最近下载更多
abc4980 LV1
2024年12月17日
maojianyun LV30
2024年1月8日
lironggang LV38
2023年6月14日
菜鸟666 LV2
2022年8月28日
ewan007 LV30
2022年6月23日
vicgong LV4
2022年5月23日
ma小跳 LV5
2022年4月2日
汤汤汤要学编程 LV11
2022年3月9日
blackcat123 LV7
2021年8月26日
elephant_xiang LV2
2021年8月23日
最近浏览更多
abc4980 LV1
2024年12月17日
uni-code_0123 LV1
2023年11月21日
lironggang LV38
2023年6月14日
lilily1119 LV4
2023年4月29日
徐鹏飞
2023年3月18日
暂无贡献等级
微信网友_6145740972576768 LV2
2022年12月21日
菜鸟666 LV2
2022年8月28日
ewan007 LV30
2022年6月23日
vicgong LV4
2022年5月23日
ma小跳 LV5
2022年4月2日

