如何把服务器上的word文档下载到客户端,然后再调用客户端的word程序进行显示?
请高手指教!
请高手指教!
解决方案 »
- 【求教】通过线程中的某一值触发弹窗程序
- 在web项目中 用poi操作excel action中的代码怎么写
- JSP页面中的日期 减法问题
- weblogic 9 密码忘了怎么办 ---- 高手进
- 请问在Struts的Action中如何判断当前请求是否为第一次请求?类似ASP.NET的IsPostBack~~
- sql注入攻击?
- intra-mart救急救急
- 刚学JAVA,需要帮助!!!!!!!!
- 請問怎麼通過google訂單號查詢google訂單的詳細信息
- 求助,spring boot打war包,没有主清单属性
- 关于Jsp中处理Word文档实现修改痕迹保留的问题
- 怎样在Jsp中从客户端对Web服务器中的Word文档进行修改
<extension>doc</extension>
<mime-type>application/msword</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xls</extension>
<mime-type>application/msexcel</mime-type>
</mime-mapping> File file = new File("G:\\9602.xls");
FileInputStream inStream = new FileInputStream(file);
String to = request.getRealPath("")+"/test.xls";
String path = request.getContextPath();
FileOutputStream outStream = new FileOutputStream(to);
int bytesRead = 0;
byte[] b = new byte[8192];
while ((bytesRead = inStream.read(b, 0, 8192)) != -1) {
outStream.write(b, 0, bytesRead);
}
inStream.close();
outStream.close();
response.sendRedirect(path+"/test.xls");显示的
BufferedReader br = new BufferedReader(new FileReader("G:\\123456.txt"));
String line = "";
while((line=br.readLine()) != null) {
parse(line);
}
private static void parse(String line) {
Pattern p = Pattern.compile("根据需要写正则");
Matcher m = p.matcher(line);
while(m.find()) {
System.out.println(m.group());
}
}给你个例子你借鉴下吧。
服务器上存放有word文档,当用户点击相关链接的时候直接调用客户端的word程序来显示相关的内容,能不能说得详细一些具体怎么做呢?
File file = new File("G:\\9602.xls"); //你文件地址(存放位置) WORD和XLS一样的
FileInputStream inStream = new FileInputStream(file);
String to = request.getRealPath("")+"/test.xls";
String path = request.getContextPath();
FileOutputStream outStream = new FileOutputStream(to);
int bytesRead = 0;
byte[] b = new byte[8192];
while ((bytesRead = inStream.read(b, 0, 8192)) != -1) {
outStream.write(b, 0, bytesRead);
}
inStream.close();
outStream.close();
response.sendRedirect(path+"/test.xls");以上代码写在SERVLET里面
File f = new File("G:/9602.doc");
FileInputStream fin = new FileInputStream(f); OutputStream output = response.getOutputStream();
byte[] buf = new byte[1024];
int r = 0;
response.setContentType("application/vnd.ms-word;charset=GB2312");
while((r = fin.read(buf, 0, buf.length))!= -1)
{
output.write(buf, 0, r); //response.getOutputStream()
}
fin.close();
output.close();
然后再调用客户端的word程序进行显示??????
LZ您要做什么 WORD已经下载到客户端了 还要在读去里面数据
你想控制客户机???我可以负责的告诉你 安全机制不允许这么做
SOAOFFICE--微软office文档中间件,专业处理这个问题的
这个应该是你需要的,只需要编写几行代码就可以了
不用再找了,不可能有比我推荐的这个控件最好的了 ,呵呵先看看效果 ,
http://www.kehansoft.com/soaoffice/doclist.asp
下载一个试试
下载地址:http://www.kehansoft.com/web/down.htm