zoukankan      html  css  js  c++  java
  • pageoffice 开发笔记

    开发环境:vs2015,mvc,razor

    pageoffice版本:Server-Version=3.2.0.1 OCX-Version=2,0,4,6

    开发模式:pageofficeLink方式

    选用这么种模式的原因是:插件“谷歌在2015.4.15做了一次比较大的升级,内容是禁止了所有的插件”

    1. 双击运行Setup.exe安装服务器组件。

    2. 第一次运行包含PageOfficeLink组件的网页时,会弹出注册对话框,请输入注册信息注册。

    3. 如果新建网站或集成PageOffice到您现有的网站里:
    1) 双击运行Setup.exe安装服务器组件;
    2) 拷贝“集成文件”目录下的“pageoffice”文件夹到您自己网站的根目录下;

    3)前台:

    第一种:<a href='@PageOffice.PageOfficeLink.OpenWindow("路径+参数", "width=1200px;height=1000px;")' ></a>

    第二种:实例化的时候将参数设置为属性,调用的时候,只需要将属性取出后,将当前文档链接设置为该属性即可,具体如下:

    <li url="@PageOffice.PageOfficeLink.OpenWindow("路径+参数", "width=1200px;height=1000px;")"  onclick="openDoc(this)"></li>

    js:document.location.href=$(obj).attr(url);

    第三种:可以通过在控制器里拼接好a标签,在前台直接调用

        后台:

    主要分为打开文档、保存文档

     1    public ActionResult Contact()
     2         {
     3 
     4             Page page = new Page(); 
     5             string controlOutput = string.Empty; 
     6             PageOffice.PageOfficeCtrl pc = new PageOffice.PageOfficeCtrl();
     7             pc.SaveFilePage = "/Home/SaveDoc";//设置保存时访问的路径
     8             pc.ServerPage="/pageoffice/server.aspx";//pageoffice服务器页面
     9             pc.WebOpen("/test.doc", PageOffice.OpenModeType.docAdmin,"s");//参数一:文档路径;参数二:文档打开模式;参数三:操作当前文档的用户名。一般来说,UserName 应该采用登录到您的Web应用程序的当前用户的名称
    10             page.Controls.Add(pc); 
    11             StringBuilder sb = new StringBuilder();
    12             using (StringWriter sw = new StringWriter(sb))
    13             {
    14                 using (HtmlTextWriter htw = new HtmlTextWriter(sw))
    15                 {
    16                     Server.Execute(page, htw, false); controlOutput = sb.ToString();
    17                 }
    18             } 
    19             ViewBag.EditorHtml = controlOutput;//控件字符串
    20             
    21             
    22             return View();
    23         }
    打开文档
    保存文档
    1   string filePath = Server.MapPath("/test.doc");
    2             PageOffice.FileSaver fs = new PageOffice.FileSaver();
    3             fs.SaveToFile(filePath);
    4             fs.Close();
    4)自定义按钮

    后台:在打开文档的时候设置    pc.AddCustomToolButton("我的自定义按钮", "前台javascript调用函数名称()", 1(按钮样式));

    前台:在打开文档的视图中定义好相应的js函数即可实现调用。

    需要特别说明的是:在前台调用的过程中需要PageOffice控件的iD时,需要在打开文档时设置控件的ID属性,见右侧代码: pc.ID = "PageOfficeCtrl1";

    插件属性见该插件的帮助文档即可。

  • 相关阅读:
    User Get 'Access Denied' with Excel Service WebPart
    How To Search and Restore files from Site Collection Recycle Bin
    How To Collect ULS Log from SharePoint Farm
    How To Restart timer service on all servers in farm
    How to Operate SharePoint User Alerts with PowerShell
    How to get Timer Job History
    Synchronization Service Manager
    SharePoint 2007 Full Text Searching PowerShell and CS file content with SharePoint Search
    0x80040E14 Caused by Max Url Length bug
    SharePoint 2007 User Re-created in AD with new SID issue on MySite
  • 原文地址:https://www.cnblogs.com/zinan/p/6065020.html
Copyright © 2011-2022 走看看