admin管理员组文章数量:1644567
上午经过讨论后,页面和数据库表结构可以暂时定下来了。其中草稿箱中发布信息会用到在线编辑Word和Excel文档功能。下午看来一下pageOfiice的一些功能,在页面上实现了一些简单的功能。其中一种想法是读取文档内容,以word数据的格式保存到数据库,取出数据通过pageoffice查看。另一种是直接保存成word本地文件,将地址存入数据库,查看是再取出。
下面一些代码是实现了word文件的读取编辑和保存。
Word.jsp
<%@ page language="java"
import="com.zhuozhengsoft.pageoffice.*,java.util.*,java.io.*,javax.servlet.*,javax.servlet.http.*;"
pageEncoding="gb2312"%>
<%@ taglib uri="http://java.pageoffice" prefix="po" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String filePath = request.getSession().getServletContext().getRealPath("SimpleWord/doc/test.doc");
//out.print(filePath);// 查看filePath 的值
//******************************PageOffice组件的使用*******************************
PageOfficeCtrl poCtrl1 = new PageOfficeCtrl(request);
poCtrl1.setServerPage(request.getContextPath()+"/poserver.zz"); //此行必须
poCtrl1.setSaveFilePage("SaveFile.jsp");//如要保存文件,此行必须
poCtrl1.addCustomToolButton("保存", "Save()", 1);//添加自定义工具栏按钮
//打开文件
poCtrl1.webOpen(filePath, OpenModeType.docNormalEdit, "张三");
poCtrl1.setTagId("PageOfficeCtrl1"); //此行必须
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
打开服务器上指定磁盘路径下的文件<br/>
<script type="text/javascript">
function Save() {
document.getElementById("PageOfficeCtrl1").WebSave();
}
</script>
<po:PageOfficeCtrl id="PageOfficeCtrl1" />
</body>
</html>
Savefile.jsp
<%@ page language="java" import="java.util.*,com.zhuozhengsoft.pageoffice.*" pageEncoding="gb2312"%>
<%
FileSaver fs=new FileSaver(request,response);
fs.saveToFile(request.getSession().getServletContext().getRealPath("SimpleWord/doc/")+"/"+fs.getFileName());
fs.close();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'SaveFile.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
</body>
</html>
本文标签: 在线编辑功能PageOfficeword
版权声明:本文标题:pageOffice实现word在线编辑保存功能 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1729394071a1199684.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论