pageoffice封装的js接口有限,某些比较复杂的设置用到的客户不多,所以没有提供直接的js方法,但是pageoffice提供了Document属性和RunMacro方法,可以调vba或直接运行宏指令实现比较小众的一些需求
document.getElementById("PageOfficeCtrl1").Document.Tables(1).Cell(1,1).Range.Text="插入文本"2、弹出word另存为所有格式的对话框
document.getElementById("PageOfficeCtrl1").Document.Application.Dialogs(84).Show();3、给word文件光标处插入文本(两种方法)
//插入的文本处于光标选中状态document.getElementById("PageOfficeCtrl1").Document.Application.Selection.Text="测试测试";//光标在行尾document.getElementById("PageOfficeCtrl1").Document.Application.Selection.TypeText("测试测试");4、给word中选中的文本设置颜色(2是WdColorIndex常量,表示设置的颜色)
document.getElementById("PageOfficeCtrl1").Document.Application.Selection.Range.Font.ColorIndex="2";5、光标定位到行尾
document.getElementById("PageOfficeCtrl1").Document.Application.Selection.EndKey();6、光标定位到word文件结尾(6是WdUnits参数,表示光标移动的位置)
document.getElementById("PageOfficeCtrl1").Document.Application.Selection.EndKey(6);7、插入换行符
document.getElementById("PageOfficeCtrl1").Document.Application.Selection.TypeParagraph();8、拒绝文档中所有的修订(必须在docAdmin模式下使用)
document.getElementById("PageOfficeCtrl1").Document.RejectAllRevisions();9、显示导航栏窗口
document.getElementById("PageOfficeCtrl1").Document.Application.ActiveWindow.DocumentMap=true;10、隐藏word中的修订格式(删除、添加内容这些不隐藏。改变字体样式或者大小这种格式会被隐藏)
document.getElementById("PageOfficeCtrl1").Document.Application.ActiveWindow.View.ShowFormatChanges=false;11、遍历删除当前word文档中所有的键盘批注
functiondeleteAllComments(){vardocObj=document.getElementById("PageOfficeCtrl1").Document;for(vari=docObj.Comments.Count;i>=1;i--){docObj.Comments(i).Delete();}}12、设置打开文件的页面的百分比为200%
document.getElementById("PageOfficeCtrl1").Document.Application.ActiveWindow.ActivePane.View.Zoom.Percentage=200;13、word中删除光标所在行
document.getElementById("PageOfficeCtrl1").Document.Application.Selection.TypeBackspace();14、根据用户名显示批注
varsMac='SubaddCom()\r\n'+'ActiveSheet.Application.Sheets("Sheet1").Range("A1").AddComment("批注信息")\r\n'+'EndSub';document.getElementById("PageOfficeCtrl1").RunMacro("addCom",sMac);2、获取excel当前活动的sheet的名称
varsheetName=document.getElementById("PageOfficeCtrl1").Document.ActiveSheet.Name;3、excel中光标选中某个单元格
document.getElementById("PageOfficeCtrl1").Document.Application.Sheets("Sheet1").Range("C1").Select();