Draw a table in Word

Source: Internet
Author: User
Tags chr range
Word gets the reader's questions early in the morning. So it's conveniently included here.
The example is to use Word to draw a 5x10 form through COM and to cram some data one by one into each area.

? PHP
$word = new COM("Word.Application") or Die ("Unable to start Word program!") ");

$word->Visible = 1 ;
$doc = $word->Documents->Add ();

$doc->Sections->Add($word ->Selection->Range,0); Add a section
$Section = $doc->Sections(1); //Get the first bar object
$Range = $Section->Range; //  produce  Range  objects
=  $doc -> tables -> add $Range   5 ,  10 Forms that produce 5x10

Plug data into a table
for ($i=1; $i <= Ten ;  $i ++) {
For ($j=1; $j <= 5 ;  $j ++) {
$Cell = $Table->Cell($j, $i /c10>);
$CellRange = $Cell->Range          $CellRange -> insertbefore CHR + $j CHR 0x40 + ));
}
}

$word->Documents[1]->SaveAs( "C:\\word.doc" );
$word->Quit ();
$word-> Release();
$word = null ;
?>


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.