客户端javasrcipt操作Word
<script>
var WordApp=new ActiveXObject("Word.Application"); //得到WORD对象
var wdCharacter=1
var wdOrientLandscape = 1
WordApp.Application.Visible=true;
var myDoc=WordApp.Documents.Add();
// WordApp.ActiveDocument.PageSetup.Orientation = wdOrientPortrait;
WordApp. Selection.ParagraphFormat.Alignment=0; //居中对齐
WordApp. Selection.Font.Bold=true;
WordApp. Selection.Font.Size=20;
WordApp. Selection.TypeText("云南电网公司标准化作业工单");
WordApp. Selection.MoveRight(wdCharacter); //光标右移字符
WordApp.Selection.TypeParagraph(); //插入段落
WordApp.Selection.TypeParagraph(); //插入段落
var myTable=myDoc.Tables.Add (WordApp.Selection.Range, 5,4); //五行4列的表格
var TableRange; //以下为给表格中的单元格赋值
for (i= 0;i<vzd.length;i++)
{
with (myTable.Cell(1,i+1).Range)
{font.Size = 12;
InsertAfter(vzd[i]);
}
}
for (i =0;i<row_count-1;i++)
{
vcontext = context.split("<纵标>")
for (n =0;n<col_count ;n++)
{
temp = vcontext[i];
vcontext1 = temp.split("<标记>")
with (myTable.Cell(i+2,n+1).Range)
{font.Size = 12;
InsertAfter(vcontext1[n]);
}
}
}
myDoc.Protect(1);
</script>