没有合适的资源?快使用搜索试试~ 我知道了~
有效的纠正了下载时出现的文件类型未知或没有扩展名的情况,也处理了spring下载的情况下文件名以@RequestMapping的value值为下载文件名称的情况
资源推荐
资源详情
资源评论
@RequestMapping(value = "dzd", method = {RequestMethod.GET, RequestMethod.POST})
public void t1Statements(HttpServletRequest request, HttpServletResponse response,MinShengSettleInDto) throws WriteException, IOException {
try {
String downlaodFilename = "文件名称.xls"
HttpHeaders headers = new HttpHeaders();
headers.setContentDispositionFormData("attachment", downlaodFilename);
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
response.setHeader("Content-Disposition", "attachment;fileName=" + downlaodFilename);
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
response.setContentType("application/vnd.ms-excel");
//此处获取将要处理的数据 我用的数组
//你可以用任意类型集合来处理,需要改变的是oneExcel内的数据处理
String[] vals = minShengService.findT1Dzd(null,serialNo);
String name="合作方标识,户入驻返回的商户编号,状态,响应码,响应描述,对账类型";//逗号分割每一列的名称
Workbook workbook = ExcelUtil.oneExcel(vals,name);
workbook.write(out);
out.flush();
logger.info(“”);
}catch (Exception e){
logger.error("系统异常",e);
}finally {
out.close();
}
}
public class ExcelUtil {
public static Workbook oneExcel(String[] val, String name) throws WriteException, IOException {
public void t1Statements(HttpServletRequest request, HttpServletResponse response,MinShengSettleInDto) throws WriteException, IOException {
try {
String downlaodFilename = "文件名称.xls"
HttpHeaders headers = new HttpHeaders();
headers.setContentDispositionFormData("attachment", downlaodFilename);
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
response.setHeader("Content-Disposition", "attachment;fileName=" + downlaodFilename);
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
response.setContentType("application/vnd.ms-excel");
//此处获取将要处理的数据 我用的数组
//你可以用任意类型集合来处理,需要改变的是oneExcel内的数据处理
String[] vals = minShengService.findT1Dzd(null,serialNo);
String name="合作方标识,户入驻返回的商户编号,状态,响应码,响应描述,对账类型";//逗号分割每一列的名称
Workbook workbook = ExcelUtil.oneExcel(vals,name);
workbook.write(out);
out.flush();
logger.info(“”);
}catch (Exception e){
logger.error("系统异常",e);
}finally {
out.close();
}
}
public class ExcelUtil {
public static Workbook oneExcel(String[] val, String name) throws WriteException, IOException {
资源评论
梦天城
- 粉丝: 219
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功