dsoframer java_word在线编辑--------dsoframer.ocx 的使用(java 代码)

支持的浏览器:主要是IE浏览器,不支持谷歌  火狐

使用条件:需要安装微软的WPS(最好2007及以上的)

操作步骤:

下载dsoframer.ocx 控件

操作:将DSOFramer.ocx复制到C:\windows\system32目录下,

开始->运行->regsvr32 DSOFramer.ocx , 系统会提示DSOFramer.ocx中的DllRegisterServer成功

注册成功后就可以使用了

// dsoframer.ocx 的使用 JSP部分

classid="clsid:00460182-9E5E-11D5-B7C8-B8269041DD57" codebase="dsoframer.ocx#version=2.3.0.1">

//codebase="dsoframer.ocx#version=2.3.0.1" 这个是你的控件的版本:自己查看属性就可以看到

// dsoframer.ocx 的使用jq部分打开

//获得服务器的地址

function getRootPath(){

//获取当前网址,如: http://localhost:8083/proj/meun.jsp

var curWwwPath = window.document.location.href;

//获取主机地址之后的目录,如: proj/meun.jsp

var pathName = window.document.location.pathname;

var pos = curWwwPath.indexOf(pathName);

//获取主机地址,如: http://localhost:8083

var localhostPath = curWwwPath.substring(0, pos);

//获取带"/"的项目名,如:/proj

var projectName = pathName.substring(0, pathName.substr(1).indexOf('/')+1);

return localhostPath+projectName;

}

function getWord() {

try {

var serverPath=this.getRootPath()+"/AffixFiles/Offices/"+fileName;

//根据文件服务器路径判断服务器文件是否存在

$.ajax(serverPath, {

type: 'get',

timeout: 1000,

success: function() {

document.all.FramerControl1.Open(serverPath, false, "Word.Document");

},

error: function() {

document.all.FramerControl1.CreateNew("Word.Document");

}

});

}

// dsoframer.ocx 的使用jq部分 保存

function saveWord() {

document.all.FramerControl1.HttpInit();

document.all.FramerControl1.HttpAddPostCurrFile("files", fileName);

document.all.FramerControl1.HttpPost("../../../system/printReportAction_fileUploadOffice.do");

//这里参数是你的action的地址

}

//JAVA ACTTION 部分(action的配置我就不详细说了)

// 用户上传的文件 这里名字需document.all.FramerControl1.HttpAddPostCurrFile("files", fileName);

里面的第一参数相同

private File[] files;

// filesFileName 必须是前面files是与上面相同fileName是固定的

private String[] filesFileName; // 上传文件的文件名

private String[] filesContentType;// 上传文件的类型

/**

* fileUploadOffice Office文件在线保存

*/

public void fileUploadOffice(){

//判断是否有文件上传

if(getWriter() == false)return;

String exescmd = request.getParameter("execscmd");

String sSavePath = request.getRealPath("/AffixFiles\\Offices") + "/".replace("\\", "/");

FileUploadServer.fileUploadOffice(getFiles(),getFilesFileName(),sSavePath,

exescmd);

/*try {

out=response.getWriter();

out.write(outStr);

} catch (IOException e) {

e.printStackTrace();

}finally{

out.close();

}*/

}

/*属性的getter和setter办法 */

public File[] getFiles() {

return files;

}

public void setFiles(File[] files) {

this.files = files;

}

public String[] getFilesFileName() {

return filesFileName;

}

public void setFilesFileName(String[] filesFileName) {

this.filesFileName = filesFileName;

}

public String[] getFilesContentType() {

return filesContentType;

}

public void setFilesContentType(String[] filesContentType) {

this.filesContentType = filesContentType;

}

我在搞这个的时候主要遇到两个问题:一个是没法保存到服务器(没有跳转到action)可以保存到本地:我当时是因为使用的是WPS2003换成2010的就支持了,第二个是文件没传过去,原因主要是因为

// 用户上传的文件 这里名字需document.all.FramerControl1.HttpAddPostCurrFile("files", fileName);

里面的第一参数相同

private File[]   files;

// filesFileName  必须是前面files是与上面相同fileName是固定的

这两个参数对应问题的问题

这个方法document.all.FramerControl1.HttpAddPostCurrFile("files", fileName);  其实就是模拟一个form表单 里面有个

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值