如何导出java工程项目里面的excel文件 20
web项目,比如在java工程下有一个table的文件夹里面有demo1.xls文件,我想要通过在web页面上点击下载按钮,实现下载demo1.xls文件到计算机本地求大...
web项目,比如在java工程下有一个table的文件夹里面有demo1.xls文件,我想要通过在web页面上点击下载按钮,实现下载demo1.xls文件到计算机本地
求大神帮忙 展开
求大神帮忙 展开
3个回答
2015-03-25
展开全部
request.setCharacterEncoding("utf-8");
String title = request.getParameter("title");
//title = URLDecoder.decode(title,"utf-8");
int maid = Integer.parseInt(request.getParameter("maid"));
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition" ,"attachment;filename="+new String((title+".xls").getBytes(),"ISO-8859-1"));
//ManuscriptAction down=new ManuscriptAction();
WebApplicationContext webAppContext = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());//得到WebApplicationContext 。
ManuscriptDaoImp cocAutoService = (ManuscriptDaoImp) webAppContext.getBean("manuscriptDaoImp");
cocAutoService.exportMan(maid,title,response.getOutputStream());
out.clear();
out = pageContext.pushBody();
我的下载代码 提供你参考
String title = request.getParameter("title");
//title = URLDecoder.decode(title,"utf-8");
int maid = Integer.parseInt(request.getParameter("maid"));
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition" ,"attachment;filename="+new String((title+".xls").getBytes(),"ISO-8859-1"));
//ManuscriptAction down=new ManuscriptAction();
WebApplicationContext webAppContext = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());//得到WebApplicationContext 。
ManuscriptDaoImp cocAutoService = (ManuscriptDaoImp) webAppContext.getBean("manuscriptDaoImp");
cocAutoService.exportMan(maid,title,response.getOutputStream());
out.clear();
out = pageContext.pushBody();
我的下载代码 提供你参考
展开全部
request.setCharacterEncoding("utf-8");
String title = request.getParameter("title");
//title = URLDecoder.decode(title,"utf-8");
int maid = Integer.parseInt(request.getParameter("maid"));
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition" ,"attachment;filename="+new String((title+".xls").getBytes(),"ISO-8859-1"));
//ManuscriptAction down=new ManuscriptAction();
WebApplicationContext webAppContext = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());//得到WebApplicationContext 。
ManuscriptDaoImp cocAutoService = (ManuscriptDaoImp) webAppContext.getBean("manuscriptDaoImp");
cocAutoService.exportMan(maid,title,response.getOutputStream());
out.clear();
out = pageContext.pushBody();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
poi 或者jxl 进行读写,直接用io流输出即可.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询