本篇内容主要讲解“如何利用java在IE中打开Excel”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“如何利用java在IE中打开Excel”吧!
java 代码:
publicclass TestOpenExcel extends HttpServlet {
privatestaticfinal String url = "D:/test.xls";
protectedvoid doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "inline;filename="" + "test.xls"+ "";");
ServletOutputStream sos = response.getOutputStream();
FileInputStream fis = new FileInputStream(url);
BufferedOutputStream bos = new BufferedOutputStream(sos);
byte[] bytes = newbyte[8192];
bos.write(bytes, 0, fis.read(bytes));
fis.close();
sos.close();
bos.close();
}
protectedvoid doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
|
到此,相信大家对“如何利用java在IE中打开Excel”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!