java直接输出Excel 页面实现下载
2024-08-23 21:31:05
public String excelDomnload() throws Exception{
try{
/*
String path = GlobalKeys.getFunctionConfig("user_attach_save","/opt/tmp/");
RegUser ru = ((RegUserLoginInfo) request.getSession().getAttribute(GlobalKeys.REG_USER_IN_SESSION_NAME)).getRegUser();
String tmpPath = File.separator + "import" + File.separator
+ ru.getName() + File.separator;
File targetFolder = new File(path, tmpPath);//合并两个路经
String fName = request.getParameter("fName");
*/
response.setContentType("application/msexcel;");
response.setHeader("Content-Disposition", new String(("attachment;filename="+"error.xls").getBytes("GB2312"), "UTF-8")); File f = new File("d:/20121211165820140_err.xls");
//File f = new File(targetFolder.getPath()+File.separator+fName);
FileInputStream in = new FileInputStream(f);
byte b[] = new byte[1024];
int i = 0;
ServletOutputStream out = response.getOutputStream();
while((i=in.read(b))!= -1){
out.write(b, 0, i);
}
out.flush();
out.close();
in.close();
}catch(Exception e){
e.printStackTrace();
}
return null;
}
最新文章
- C语言 第六章 多重循环
- 嵌套div中margin-top转移问题的解决办法
- Xcode 字体 设置-- Xcode family没有显示的字体
- nginx添加模块 (非覆盖安装)
- 027医疗项目-模块二:药品目录的导入导出-导入功能的Action的编写
- java 面向对象编程--第十章 接口
- Design Mode 之 结构模式
- Java为什么只能单继承?
- vs2010 未能正确加载方案中的一个或多个项目
- LoadRunner如何在注册业务脚本中设置参数化唯一性
- react redux 相关技术
- spring xsd
- CDbConnection failed to open the DB connection: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
- Java中对整数格式化
- 总结的Javascript插件
- 轮播效果/cursor
- MB SD Connect 5 vs 2017 FVDI2 Commander
- 【LOJ#2542】[PKUWC2018]随机游走(min-max容斥,动态规划)
- Java SDK夯住(Hang)问题排查
- SQL Server中判断字符串出现的位置及字符串截取
热门文章
- Java中权限修饰符public、private、protected和default的区别
- 转:windows下使用gvim搭建简单的IDE编译环境(支持C/C++/Python等)
- Javascript Framework Scenario
- SVN简明使用方法 .
- Ferry Loading||
- C# 绘图对象 流对象 响应对象关系
- VS2010安装Visual Assist
- ZOJ-1508Intervals(差分约束)
- workflow4.0学习资料
- kafka-简单事例