javascript動態給word doc文檔增加表格

來源:互聯網
上載者:User
關鍵字 網頁製作 Ajax JavaScript

javascript教程動態給word doc文檔增加表格

<script>
function wordcontorl(){
alert("小孟佳的寶貝");
var WordApp=new ActiveXObject("Word.Application");
var wdCharacter=1
var wdOrientLandscape = 1
WordApp.Application.Visible=true; //執行完成之後是否彈出已經生成的word
va r myDoc=WordApp.Documents.Add();//創建新的空文檔
WordApp.ActiveDocument.PageSetup.Orientation = wdOrientLandscape// 頁面方向設置為橫向
WordApp. Selection.ParagraphFormat.Alignment=1 //1居中對齊,0為居右
WordApp. Selection.Font.Bold=true
WordApp. Selection.Font.Size=20
WordApp. Selection.TypeText("孟佳燒香");
WordApp. Selection.MoveRight(wdCharacter);    游標右移字元
WordApp.Selection.TypeParagraph()         //插入段落
WordApp. Selection.Font.Size=12
WordApp. Selection.TypeText("-----朱漪編寫"); 分行插入日期
WordApp.Selection.TypeParagraph()         //插入段落
var myTable=myDoc.Tables.Add (WordApp.Selection.Range, 8,7) //8行7列的表格
//myTable.Style="網格型"
var aa = "孟佳標題"
var TableRange; //以下為給表格中的儲存格賦值
for (i= 0;i<7 ;i++)
{
with (myTable.Cell(1,i+1). Range)
{
font. Size = 12;
InsertAfter(aa);
ColumnWidth =4
}
}
for (n =0;n<7;n++)
{
for (i =0;i<7 ;i++)
{
with (myTable. Cell(i+2,n+1). Range)
{font. Size = 12;
InsertAfter(www.jzread.com);
}
}
}
row_count = 0;
col_count = 0
myDoc.Protect(1)
}
wordcontorl()
</script>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.