📄 documentedit.aspx
字号:
//作用:签名印章
function WebOpenSignature(){
alert("如果你要更安全签章,建议采用金格iSignature电子签章软件进行签章:\r\n下载地址http://www.goldgrid.cn/iSignature/Download.asp\r\n\r\n该软件是支持文档完整性保护、CA证书和数字签名技术的,\r\n是通过了<国家公安部和国家保密局>双重认证的安全电子签章产品!");
try{
webform.WebOffice.WebOpenSignature(); //交互OfficeServer的 A签章列表OPTION="LOADMARKLIST" B签章调出OPTION="LOADMARKIMAGE" C确定签章OPTION="SAVESIGNATURE" <参考技术文档>
StatusMsg(webform.WebOffice.Status);
}catch(e){alert(e.description);}
}
//作用:验证印章A
function WebShowSignature(){
try{
webform.WebOffice.WebShowSignature(); //交互OfficeServer的OPTION="LOADSIGNATURE"
StatusMsg(webform.WebOffice.Status);
}catch(e){alert(e.description);}
}
//作用:验证印章B
function WebCheckSignature(){
try{
var i=webform.WebOffice.WebCheckSignature(); //交互OfficeServer的OPTION="LOADSIGNATURE"
alert("检测结果:"+i+"\r\n 注释: (=-1 有非法印章) (=0 没有任何印章) (>=1 有多个合法印章)");
StatusMsg(i);
}catch(e){alert(e.description);}
}
//作用:存为本地文件
function WebSaveLocal(){
try{
webform.WebOffice.WebSaveLocal();
StatusMsg(webform.WebOffice.Status);
}catch(e){alert(e.description);}
}
//作用:打开本地文件
function WebOpenLocal(){
try{
webform.WebOffice.WebOpenLocal();
StatusMsg(webform.WebOffice.Status);
}catch(e){alert(e.description);}
}
//作用:保存为HTML文档
function WebSaveAsHtml(){
try{
if (webform.WebOffice.WebSaveAsHtml()) //交互OfficeServer的OPTION="SAVEASHTML"
{
webform.HTMLPath.value="HTML/<%=mRecordID%>.htm";
window.open("<%=mHttpUrl%>"+ webform.HTMLPath.value);
}
StatusMsg(webform.WebOffice.Status);
}catch(e){alert(e.description);}
}
//作用:保存为文档图片
function WebSaveAsPage(){
try{
if (webform.WebOffice.WebSaveImage()) //交互OfficeServer的OPTION="SAVEIMAGE"
{
webform.HTMLPath.value="HTMLIMAGE/<%=mRecordID%>.htm";
window.open("<%=mHttpUrl%>"+ webform.HTMLPath.value);
}
StatusMsg(webform.WebOffice.Status);
}catch(e){alert(e.description);}
}
//作用:关闭或显示工具 参数1表示工具条名称 参数2为false时,表示关闭 (名称均可查找VBA帮助)
//参数2为true时,表示显示
function WebToolsVisible(ToolName,Visible){
try{
webform.WebOffice.WebToolsVisible(ToolName,Visible);
StatusMsg(webform.WebOffice.Status);
}catch(e){alert(e.description);}
}
//作用:禁止或启用工具 参数1表示工具条名称 参数2表示工具条铵钮的编号 (名称和编号均可查找VBA帮助)
//参数3为false时,表示禁止 参数3为true时,表示启用
function WebToolsEnable(ToolName,ToolIndex,Enable){
try{
webform.WebOffice.WebToolsEnable(ToolName,ToolIndex,Enable);
StatusMsg(webform.WebOffice.Status);
}catch(e){alert(e.description);}
}
//作用:保护与解除 参数1为true表示保护文档 false表示解除保护
function WebProtect(value){
try{
webform.WebOffice.WebSetProtect(value,""); //""表示密码为空
}catch(e){alert(e.description);}
}
//作用:允许与禁止拷贝功能 参数1为true表示允许拷贝 false表示禁止拷贝
function WebEnableCopy(value){
try{
webform.WebOffice.CopyType=value;
}catch(e){alert(e.description);}
}
//作用:插入远程服务器图片
function WebInsertImage(){
try{
webform.WebOffice.WebInsertImage('Image','GoldgridLogo.jpg',true,4); //交互OfficeServer的OPTION="INSERTIMAGE" 参数1表示标签名称 参数2表示图片文件名 参数3为true透明 false表示不透明 参数4为4表示浮于文字上方 5表示衬于文字下方
StatusMsg(webform.WebOffice.Status);
}catch(e){alert(e.description);}
}
//作用:下载服务器文件到本地
function WebGetFile(){
if (webform.WebOffice.WebGetFile("c:\\WebGetFile.doc","DownLoad.doc")){ //交互OfficeServer的OPTION="GETFILE" 参数1表示本地路径 参数2表示服务器文件名称
StatusMsg(webform.WebOffice.Status);
}else{
StatusMsg(webform.WebOffice.Status);
}
alert(webform.WebOffice.Status+"\r\n"+"文件放在c:\\WebGetFile.doc");
}
//作用:上传本地文件到服务器
function WebPutFile(){
var mLocalFile=webform.WebOffice.WebOpenLocalDialog();
if (mLocalFile!=""){
alert(mLocalFile);
if (webform.WebOffice.WebPutFile(mLocalFile,"Test.doc")){ //交互OfficeServer的OPTION="PUTFILE" 参数1表示本地路径,可以任何格式文件 参数2表示服务器文件名称
StatusMsg(webform.WebOffice.Status);
}else{
StatusMsg(webform.WebOffice.Status);
}
alert(webform.WebOffice.Status);
}
}
//作用:打开远程文件
function WebDownLoadFile(){
mResult=webform.WebOffice.WebDownLoadFile("http://www.goldgrid.com/Images/abc.doc","c:\\abc.doc");
if (mResult){
webform.WebOffice.WebOpenLocalFile("c:\\abc.doc");
alert("成功");
}else{
alert("失败");
}
}
//作用:取得服务器端时间,设置本地时间 [V6.0.1.5以上支持]
function WebDateTime(){
mResult=webform.WebOffice.WebDateTime(true); //交互OfficeServer的OPTION="DATETIME" true表示返回并设置本地时间为服务器时间;false表示仅返回服务器时间
alert("提示:已经设置本地时间为 "+mResult); //该功能主要用于在痕迹保留时读取服务器时间
}
//作用:表格生成及填充
function WebSetWordTable(){
var mText="",mName="",iColumns,iCells,iTable;
//设置COMMAND为WORDTABLE
webform.WebOffice.WebSetMsgByName("COMMAND","WORDTABLE"); //设置变量COMMAND="WORDTABLE",在WebSendMessage()时,一起提交到OfficeServer中
//发送到服务器上
//如果没有错误
if (webform.WebOffice.WebSendMessage()){ //交互OfficeServer的OPTION="SENDMESSAGE"
iColumns = webform.WebOffice.WebGetMsgByName("COLUMNS"); //取得列
iCells = webform.WebOffice.WebGetMsgByName("CELLS"); //取得行
iTable=webform.WebOffice.WebObject.Tables.Add(webform.WebOffice.WebObject.Application.Selection.Range,iCells,iColumns); //生成表格
for (var i=1; i<=iColumns; i++)
{
for (var j=1; j<=iCells; j++)
{
mName=i.toString()+j.toString();
mText=webform.WebOffice.WebGetMsgByName(mName); //取得OfficeServer中的表格内容
iTable.Columns(i).Cells(j).Range.Text=mText; //填充单元值
}
}
}
StatusMsg(webform.WebOffice.Status);
}
//作用:获取文档Txt正文
function WebGetWordContent(){
try{
alert(webform.WebOffice.WebObject.Content.Text);
}catch(e){alert(e.description);}
}
//作用:写Word内容
function WebSetWordContent(){
var mText=window.prompt("请输入内容:","测试内容");
if (mText==null){
return (false);
}
else
{
//下面为显示选中的文本
//alert(webform.WebOffice.WebObject.Application.Selection.Range.Text);
//下面为在当前光标出插入文本
webform.WebOffice.WebObject.Application.Selection.Range.Text= mText+"\n";
//下面为在第一段后插入文本
//webform.WebOffice.WebObject.Application.ActiveDocument.Range(1).Text=(mText);
}
}
//作用:打印黑白文档
function WebWordPrintBlackAndWhile(){
var i,n;
//图片变黑白
i=0;
n=webform.WebOffice.WebObject.Shapes.Count;
for (var i=1; i<=n; i++)
{
webform.WebOffice.WebObject.Shapes.Item(i).PictureFormat.ColorType=3;
}
i=0;
n=webform.WebOffice.WebObject.InlineShapes.Count;
for (var i=1; i<=n; i++)
{
webform.WebOffice.WebObject.InlineShapes.Item(i).PictureFormat.ColorType=3;
}
//文字变黑白
webform.WebOffice.WebObject.Application.Selection.WholeStory();
webform.WebOffice.WebObject.Application.Selection.Range.Font.Color = 0;
}
//作用:用Excel求和
function WebGetExcelContent(){
webform.WebOffice.WebObject.Application.Sheets(1).Select;
webform.WebOffice.WebObject.Application.Range("C5").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "126";
webform.WebOffice.WebObject.Application.Range("C6").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "446";
webform.WebOffice.WebObject.Application.Range("C7").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "556";
webform.WebOffice.WebObject.Application.Range("C5:C8").Select;
webform.WebOffice.WebObject.Application.Range("C8").Activate;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "=SUM(R[-3]C:R[-1]C)";
webform.WebOffice.WebObject.Application.Range("D8").Select;
alert(webform.WebOffice.WebObject.Application.Range("C8").Text);
}
//作用:保护工作表单元
function WebSheetsLock(){
webform.WebOffice.WebObject.Application.Sheets(1).Select;
webform.WebOffice.WebObject.Application.Range("A1").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "产品";
webform.WebOffice.WebObject.Application.Range("B1").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "价格";
webform.WebOffice.WebObject.Application.Range("C1").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "详细说明";
webform.WebOffice.WebObject.Application.Range("D1").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "库存";
webform.WebOffice.WebObject.Application.Range("A2").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "书签";
webform.WebOffice.WebObject.Application.Range("A3").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "毛笔";
webform.WebOffice.WebObject.Application.Range("A4").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "钢笔";
webform.WebOffice.WebObject.Application.Range("A5").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "尺子";
webform.WebOffice.WebObject.Application.Range("B2").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "0.5";
webform.WebOffice.WebObject.Application.Range("C2").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "樱花";
webform.WebOffice.WebObject.Application.Range("D2").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "300";
webform.WebOffice.WebObject.Application.Range("B3").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "2";
webform.WebOffice.WebObject.Application.Range("C3").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "狼毫";
webform.WebOffice.WebObject.Application.Range("D3").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "50";
webform.WebOffice.WebObject.Application.Range("B4").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "3";
webform.WebOffice.WebObject.Application.Range("C4").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "蓝色";
webform.WebOffice.WebObject.Application.Range("D4").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "90";
webform.WebOffice.WebObject.Application.Range("B5").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "1";
webform.WebOffice.WebObject.Application.Range("C5").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "20cm";
webform.WebOffice.WebObject.Application.Range("D5").Select;
webform.WebOffice.WebObject.Application.ActiveCell.FormulaR1C1 = "40";
//保护工作表
webform.WebOffice.WebObject.Application.Range("B2:D5").Select;
webform.WebOffice.WebObject.Application.Selection.Locked = false;
webform.WebOffice.WebObject.Application.Selection.FormulaHidden = false;
webform.WebOffice.WebObject.Application.ActiveSheet.Protect(true,true,true);
alert("已经保护工作表,只有B2-D5单元格可以修改。");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -