|
|
|
อัพโหลดรูป...จะอัพโหลดรูปลงในโฟร์เดอร์ที่สร้างไว้ค่ะ แต่ไม่รู้จะเขียนโค๊ดยังไง |
|
|
|
|
|
|
|
โค๊ดนี้ติด error แบบนี้อะค่ะ
Code
Parse error: parse error, unexpected T_OBJECT_OPERATOR in E:\AppServ\www\test\phpWordReport.php on line 37
Code (PHP)
<?php
<html>
<head>
<title>ThaiCreate.Com PHP Word.Application Tutorial</title>
</head>
<body>
<?
$wdAlignParagraphCenter = "1";
$wdAlignParagraphRight = "2";
$Wrd = new COM("Word.Application");
$DocName = "MyDoc/MyWord.doc";
$Wrd->Application->Visible = False;
//$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp
$WrdDoc = $Wrd->Documents->Open(realpath("thaicreate.dot"));
$MyRange1 = $WrdDoc->Paragraphs->Add->Range;
$MyRange1->ParagraphFormat->Alignment = $wdAlignParagraphCenter;
$MyRange1->Font->Name = "Verdana";
$MyRange1->Font->Size = "20";
$MyRange1->Font->Bold = True;
$MyRange1->InsertBefore("Customer Report".chr(13));
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL);
$intRows = mysql_num_rows($objQuery);
$MyRange2 = $WrdDoc->Paragraphs->Add->Range;
$MyRange2->Font->Size = "10";
$objTable = $Wrd->ActiveDocument->Tables->Add($MyRange2,$intRows+1,6,1,2); //** Range,Rows,Column **//
//*** Header ***//
$objTable->Cell(1,1)->Range->InsertAfter("CustomerID");
$objTable->Cell(1,1)->Range->Bold = True;
$objTable->Cell(1,1)->Range->ParagraphFormat->Alignment = 1;
$objTable->Cell(1,2)->Range->InsertAfter("Name");
$objTable->Cell(1,2)->Range->Bold = True;
$objTable->Cell(1,2)->Range->ParagraphFormat->Alignment = 1;
$objTable->Cell(1,3)->Range->InsertAfter("Email");
$objTable->Cell(1,3)->Range->Bold = True;
$objTable->Cell(1,3)->Range->ParagraphFormat->Alignment = 1;
$objTable->Cell(1,4)->Range->InsertAfter("CountryCode");
$objTable->Cell(1,4)->Range->Bold = True;
$objTable->Cell(1,4)->Range->ParagraphFormat->Alignment = 1;
$objTable->Cell(1,5)->Range->InsertAfter("Budget");
$objTable->Cell(1,5)->Range->Bold = True;
$objTable->Cell(1,5)->Range->ParagraphFormat->Alignment = 1;
$objTable->Cell(1,6)->Range->InsertAfter("Used");
$objTable->Cell(1,6)->Range->Bold = True;
$objTable->Cell(1,6)->Range->ParagraphFormat->Alignment = 1;
//*** Detail ***//
$intRows = 1;
while($result = mysql_fetch_array($objQuery))
{
$intRows++;
$objTable->Cell($intRows,1)->Range->InsertAfter($result["CustomerID"]);
$objTable->Cell($intRows,1)->Range->ParagraphFormat->Alignment = 1;
$objTable->Cell($intRows,2)->Range->InsertAfter($result["Name"]);
$objTable->Cell($intRows,2)->Range->ParagraphFormat->Alignment = 0;
$objTable->Cell($intRows,3)->Range->InsertAfter($result["Email"]);
$objTable->Cell($intRows,3)->Range->ParagraphFormat->Alignment = 0;
$objTable->Cell($intRows,4)->Range->InsertAfter($result["CountryCode"]);
$objTable->Cell($intRows,4)->Range->ParagraphFormat->Alignment = 1;
$objTable->Cell($intRows,5)->Range->InsertAfter(number_format($result["Budget"],2));
$objTable->Cell($intRows,5)->Range->ParagraphFormat->Alignment = 2;
$objTable->Cell($intRows,6)->Range->InsertAfter(number_format($result["Used"],2));
$objTable->Cell($intRows,6)->Range->ParagraphFormat->Alignment = 2;
}
$MyRange3 = $WrdDoc->Paragraphs->Add->Range;
$MyRange3->ParagraphFormat->Alignment = $wdAlignParagraphRight;
$MyRange3->Font->Name = "Verdana";
$MyRange3->Font->Size = "10";
$MyRange3->InsertBefore(chr(13).chr(13).chr(13).".......Manager".chr(13).date("Y-m-d H:i:s"));
//$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>
?>
แห่ะๆ ตั้งกระทู้อันเดียว แต่มีสองคำถาม
|
|
|
|
|
Date :
2009-05-11 15:42:31 |
By :
little_finger |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
$objTable = $Wrd->ActiveDocument->Tables->Add($MyRange2,($intRows+1),6,1,2);
?>
|
|
|
|
|
Date :
2009-05-11 15:56:01 |
By :
plakrim |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แห่ๆ มันคืออะไรหรอค่ะ ไม่เข้าใจโค๊ดอะค่ะ เพิ่งเคยทำ
|
|
|
|
|
Date :
2009-05-12 01:38:03 |
By :
little_finger |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
สร้างโฟลเดอร์ชื่อ upload ไว้ด้วยนะครับ หุหุ
|
|
|
|
|
Date :
2009-05-12 02:55:27 |
By :
melodyApinan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณนะค่ะ
|
|
|
|
|
Date :
2009-05-12 23:23:18 |
By :
little_finger |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่ได้อะคับ
|
|
|
|
|
Date :
2010-02-14 18:05:10 |
By :
loesuwan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
รูปไม่ขึ้นคะ
|
|
|
|
|
Date :
2010-09-06 00:58:14 |
By :
ใบม่อน |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|