|
|
|
ต้องการ Export word โดยมีรูปแทรกด้วย ต้องการ Export word โดยมีรูปแทรกด้วย ทำได้ไหมครับถ้าได้ขอ code ด้วยครับ |
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP Word.Application Tutorial</title>
</head>
<body>
<?
$wdColorDarkRed = "&H80";
$wdAlignParagraphCenter = "1";
$wdAlignParagraphLeft = "0";
$wdParagraph = "4";
$wdHorizontalPositionMargin = "0";
$wdTableLeft = "-999998";
$wdCollapseEnd = "0";
$Wrd = new COM("Word.Application");
$DocName = "MyDoc/MyWord.doc";
//$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp
$Wrd->Application->Visible = False;
$WrdDoc = $Wrd->Documents->Add();
$MyRange1 = $WrdDoc->Paragraphs->Add->Range;
$MyRange1->ParagraphFormat->Alignment = $wdAlignParagraphCenter;
$MyRange1->Font->Name = "Verdana";
$MyRange1->Font->Size = "30";
$MyRange1->Font->Bold = True;
$MyRange1->InsertBefore(chr(13).chr(13)."www.ThaiCreate.Com".chr(13)."Version 2009");
$MyRange1->InlineShapes->AddPicture(realpath("thaicreate-2009.gif"));
//$WrdDoc->InlineShapes->AddPicture(realpath("thaicreate-2009.gif"));
//$WrdDoc->Shapes->AddPicture(realpath("thaicreate-2009.gif"),0,0,MyRange1);
//$WrdDoc->Shapes->AddPicture(realpath("thaicreate-2009.gif"),0,0,Wrd->Selection->Range);
$MyRange2 = $WrdDoc->Paragraphs->Add->Range;
$MyRange2->ParagraphFormat->Alignment = $wdAlignParagraphCenter;
$MyRange2->Font->Name = "Verdana";
$MyRange2->Font->Size = "15";
$MyRange2->Font->Bold = True;
$MyRange2->InsertBefore(chr(13).chr(13)."PHP,ASP and ASP.NET Tutorial");
$MyRange2->InlineShapes->AddPicture(realpath("doc.gif"));
$MyRange3 = $WrdDoc->Paragraphs->Add->Range;
$MyRange3->ParagraphFormat->Alignment = $wdAlignParagraphCenter;
$MyRange3->Font->Name = "Verdana";
$MyRange3->Font->Size = "10";
$MyRange3->Font->Bold = True;
$MyRange3->Font->Color = $wdColorDarkRed;
$MyRange3->Underline = True;
$MyRange3->InsertBefore(chr(13).chr(13).chr(13).chr(13)."All Rights Reserved");
//$WrdDoc->SaveAs($strPath."/".$DocName);
$WrdDoc->SaveAs(realpath($DocName));
$Wrd->Application->Quit;
$Wrd = null;
?>
Word Created <a href="<?=$DocName?>">Click here</a> to Download.
</body>
</html>
Go to : PHP and Word (Word.Application) - Add/Insert Picture (AddPicture)
|
|
|
|
|
Date :
2011-06-05 22:04:40 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|