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的信任设置:如下