PageOffice 开发者中心 PageOffice 开发者中心
首页
文档
  • 后端Java手册 (opens new window)
  • 后端.netcore手册 (opens new window)
  • 前端JavaScript手册 (opens new window)
下载
购买 (opens new window)
首页
文档
  • 后端Java手册 (opens new window)
  • 后端.netcore手册 (opens new window)
  • 前端JavaScript手册 (opens new window)
下载
购买 (opens new window)
  • 开始

    • 介绍
    • 快速上手

      • PageOffice最简集成代码(VUE+Springboot)
      • PageOffice最简集成(VUE3+Springboot2/3)
      • PageOffice最简集成代码(SpringMVC)
      • PageOffice最简集成代码(Springboot)
      • PageOffice最简集成代码(Asp.Net)
      • PageOffice最简集成代码(.NetCore)
    • 升级步骤

    • 项目部署

  • 通用控制

  • Word

  • Excel

  • PDF

  • FileMaker

  • PPT

  • 更多

PageOffice最简集成代码(Asp.Net)

# PageOffice最简单的集成代码(Asp.Net)

本文描述了PageOffice产品在普通的Asp.Net项目中如何集成调用。

  1. 新建Asp.Net项目:PageOffice6-Net-Simple
  2. 在您的web项目的“依赖项-包-管理NuGet程序包”中搜索到“Zhuozhengsoft.PageOfficeNet"程序后安装最新版本。
  3. 拷贝pageoffice客户端安装程序到项目的bin文件夹下。
    • 客户端是windows环境:拷贝posetup_6.x.x.x.exe到bin文件夹下;
    • 客户端是国产操作系统环境:拷贝对应芯片的PageOffice客户端deb安装包到bin文件夹下;

PageOffice客户端安装程序下载地址:https://www.zhuozhengsoft.com/dowm/ (opens new window)

  1. 配置Web.Config文件,添加PageOffice相关的handler
<system.webServer>
  <handlers>
    <add name="poserver" path="/poserver.zz" verb="*" type="PageOffice.POServer.ServerHandler"/>
    <add name="poclient" path="/poclient" verb="GET" type="PageOffice.POServer.ServerHandler"/>
    <add name="sealsetup" path="/sealsetup.exe" verb="GET" type="PageOffice.POServer.ServerHandler"/>
    <add name="pageoffice" path="/pageoffice.js" verb="GET" type="PageOffice.POServer.ServerHandler"/>
    <add name="adminseal" path="/adminseal.zz" verb="*" type="PageOffice.POServer.AdminSealHandler"/>
    <add name="loginseal" path="/loginseal.zz" verb="*" type="PageOffice.POServer.AdminSealHandler"/>
  </handlers>
</system.webServer>
  1. 在D盘根目录下准备一个有内容的test.docx文件,新建Word.aspx并调用PageOffice在线打开此文件。

    Word.aspx.cs代码如下:

namespace PageOffice6_Net_Simple
{
    public partial class Word : System.Web.UI.Page
    {
        public PageOffice.PageOfficeCtrl poCtrl = new PageOffice.PageOfficeCtrl();
        protected void Page_Load(object sender, EventArgs e)
        {
            poCtrl.SaveFilePage = "SaveFile.aspx";// 设置处理文件保存的页面
            poCtrl.WebOpen("D:\\test.docx", PageOffice.OpenModeType.docNormalEdit, "Tom");
        }
    }
}

Word.aspx中的html代码如下:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title></title>
  <script type="text/javascript">
      function Save() {
          pageofficectrl.WebSave();
      }
      function OnPageOfficeCtrlInit() {
          pageofficectrl.AddCustomToolButton("保存", "Save", 1);
      }
  </script>
</head>
<body>
  <div style="width:auto;height:98vh;">
    <%=poCtrl.getHtml()%> 
  </div>
</body>
</html>
  1. 新建SaveFile.aspx处理客户端保存上传的文件流。SaveFile.aspx.cs文件的代码如下:
namespace PageOffice6_Net_Simple
{
    public partial class SaveFile : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            PageOffice.FileSaver fs = new PageOffice.FileSaver();
            fs.SaveToFile("D:\\" + fs.FileName);
            fs.Close();
        }
    }
}
  1. 在需要点击超链接实现在线打开文件的页面(比如:index.html)中添加pageoffice.js文件的引用。
<script type="text/javascript" src="/pageoffice.js"></script>

注意

pageoffice.js文件来自于Web.Config配置的handler。

  1. 然后在页面中添加一个超链接,点击超链接调用POBrowser对象的openWindow方法,弹出新浏览器窗口访问Word.aspx在线打开文件,代码如下:
<a href="javascript:POBrowser.openWindow('Word.aspx','width=1150px;height=900px;');">
    在线打开文档
</a>
  1. 启动项目,点击“在线打开文档”超链接,查看在线打开编辑保存Office文件的效果。
上次更新: 2025/12/12, 09:47:21
PageOffice | Copyright © 2013-2026 卓正软件 京ICP备12010902号-2 京公网安备 11010502019270号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式