JavaScript dynamically adds a table to Word doc documents

Source: Internet
Author: User
Keywords Web page production Ajax javascript
Tags ajax application function javascript script selection web web page

JavaScript Tutorials dynamically add a table to Word doc documents

<script>
Function Wordcontorl () {
alert ("Baby Meng Jia");
var wordapp=new activexobject ("Word.Application");
var wdcharacter=1
var wdorientlandscape = 1
wordapp.application.visible=true;//Eject the generated word after execution is completed
var mydoc=wordapp.documents.add ()//Create a new empty document
WordApp.ActiveDocument.PageSetup.Orientation = wdorientlandscape// The page orientation is set to landscape
WordApp. Selection.paragraphformat.alignment=1//1 is centered, 0 is the right
WordApp. Selection.font.bold=true
WordApp. Selection.font.size=20
WordApp. Selection.TypeText ("Meng Jia incense");
WordApp.    Selection.MoveRight (wdcharacter); The cursor moves the character to the right
WordApp.Selection.TypeParagraph ()//Insert paragraph
WordApp. Selection.font.size=12
WordApp. Selection.TypeText ("written-----Zhu Yu"); Branch Insert date
WordApp.Selection.TypeParagraph ()//Insert paragraph
var mytable=mydoc.tables.add (WordApp.Selection.Range, 8,7 //8 Row 7 Column table
//mytable.style= grid
var aa = "Meng Jia title"
var Tablerange;//The following is assigned to cells in a table
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++)
{
to (I =0;i<7; i++)
{
with (Mytable.cell +1). Range)
{font. Size = 12;
InsertAfter (www.jzread.com);
}
}
}
Row_count = 0;
Col_count = 0
Mydoc.protect (1)
}
Wordcontorl ()
</script>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.