@RequestMapping(params = "exportXlsByT")
@ResponseBody
public void exportXlsByT(HrContractEntity hrContract,HttpServletRequest request,HttpServletResponse response
, DataGrid dataGrid,ModelMap modelMap) throws IOException {
String filename ="XXX.xls";
String path =ResourceUtil.getConfigByName("downloadexceltemplatepath"); //读取配置文件
ValidateUtils.downloadFile(response,request,path, filename);//主要在这一步调用下载的那个方法就可以了
}
public static HttpServletResponse downloadFile(HttpServletResponse response,HttpServletRequest request,String pathUrl, String name)
{
try
{
if ((pathUrl == null) && ("".equals(pathUrl))) {
return null;
}
File file = new File(pathUrl);
//文件下载路径
String filePath= "";
InputStream fis = new BufferedInputStream(new FileInputStream(pathUrl));
byte[] buffer = new byte[fis.available()];
fis.read(buffer);
JEECG 下载Excel模板 并解决IE下载的Excel只读
最新推荐文章于 2022-02-10 16:26:58 发布