pageoffice自动显示所有批注

pageoffice有api可以直接调用, 显示所有批注,但目前只支持word.对于excel.可以使用编写宏,直接调用office的功能.直接上代码

//POB打开窗口后事件
function AfterDocumentOpened() {
    document.getElementById("PageOfficeCtrl1").ShowRevisions = true;//word显示批注
    if(fileType && "excel" == fileType){
       showComments();
    }
}

/**
* excel显示所有批注
* pageoffice目前没有可以直接调用的接口.这里使用宏调用office的功能
*/
function showComments(){
   var mac = "Sub showComments()" + " \r\n"
               + "Dim count As Integer" + " \r\n"
               + "count = ActiveSheet.Comments.count" + " \r\n"
               + "If count > 0 Then" + " \r\n"
               +  "    Dim cmt As Comment" + " \r\n"
               +  "     For Each cmt In ActiveSheet.Comments" + " \r\n"
               +  "         cmt.Visible = True" + " \r\n"
               +  "     Next cmt" + " \r\n"
               + "End If" + " \r\n"
               +  "End Sub" + " \r\n";
               document.getElementById("PageOfficeCtrl1").RunMacro("showComments", mac);
}

另外要注意的是,由于这里是应用写宏脚本调用office.故要调整office的信任设置:如下

设置信任

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值