如何在jsp页面里打开word或excel? 我的意思是直接在jsp页面中嵌入word,而不是有提示框弹出问“打开”或“保存”!!!
我曾经这样就可以做到!我先打开word文件,然后点“另存为页面”,保存名为“***.htm”,然后在jsp页面中用<jsp:include page="****.htm"/>!这样就可以做到了!
可是我不想把word文件另存为页面格式,我想直接在jsp页面中打开,怎么办?给个简单的例子好吗?
给了50分!多谢了!
我曾经这样就可以做到!我先打开word文件,然后点“另存为页面”,保存名为“***.htm”,然后在jsp页面中用<jsp:include page="****.htm"/>!这样就可以做到了!
可是我不想把word文件另存为页面格式,我想直接在jsp页面中打开,怎么办?给个简单的例子好吗?
给了50分!多谢了!
在servlet中 response.setContentType("application/vnd.ms-execel")
在jsp中 <%@ page contentType="application/vnd.ms-execel;charset=gb2312"%>
File file = new File(entireFileName);
FileInputStream fileInputStream = new FileInputStream(file);
long fLength = file.length();
int cuttentBytes = 0;
int totalBytes = 0;
int bufferSize = 1024;
byte buffer[] = new byte[bufferSize];response.setContentLength((int)fLength);
response.setHeader("Content-Disposition", "attachment; filename=\"" + file.getAbsolutePath() + "\"");
while((long)totalBytes < fLength)
{
cuttentBytes = fileInputStream.read(buffer, 0, bufferSize);
totalBytes += cuttentBytes;
response.getOutputStream().write(buffer, 0, cuttentBytes);
}fileInputStream.close();
SOAOFFICE--微软office文档中间件,专业处理这个问题的
这个应该是你需要的,只需要编写几行代码就可以了
不用再找了,不可能有比我推荐的这个控件最好的了 ,呵呵 先看看效果 ,
http://www.kehansoft.com/soaoffice/doclist.asp
下载一个试试
下载地址:http://www.kehansoft.com/web/down.htm