ช่วยด้วย Error มันฟ้องตรง Exce.Application อ่าครับ 'Failed to create COM object `Excel.Application': Invalid syntax ' in
ไม่มีใครตอบเลยอ่าครับ
Date :
2012-07-24 13:35:05
By :
kritsana7
Code (PHP)
<html>
<head>
<title>Hock An Tueng Groups</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","upxowffj") or die("Not Connect to Database!!");
$objDB = mysql_select_db("isuzu_acc");
$strSQL = "SELECT * FROM won_bo";
mysql_query("set NAMES tis620");
$objQuery = mysql_query($strSQL);
if($objQuery)
{
//*** Get Document Path ***//
$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // D:/AppServ/www/myphp
//*** Excel Document Root ***//
$strFileName = "MyXls/won_bo.xls";
//*** Connect to Excel.Application ***//
$xlApp = new COM("Excel.Application");
$xlBook = $xlApp->Workbooks->Add();
//*** Create Sheet 1 ***//
$xlBook->Worksheets(1)->Name = "Customer from boc";
$xlBook->Worksheets(1)->Select;
//*** Header ***//
$xlApp->ActiveSheet->Cells(1,1)->Value = "boc_id";
$xlApp->ActiveSheet->Cells(1,2)->Value = "date_boc";
$xlApp->ActiveSheet->Cells(1,3)->Value = "ti_b";
$xlApp->ActiveSheet->Cells(1,4)->Value = "name_b";
$xlApp->ActiveSheet->Cells(1,5)->Value = "lastname_b";
$xlApp->ActiveSheet->Cells(1,6)->Value = "gend_b";
$xlApp->ActiveSheet->Cells(1,7)->Value = "add_b";
$xlApp->ActiveSheet->Cells(1,8)->Value = "tum_b";
$xlApp->ActiveSheet->Cells(1,9)->Value = "dis_b";
$xlApp->ActiveSheet->Cells(1,10)->Value = "pro_b";
$xlApp->ActiveSheet->Cells(1,11)->Value = "zip_b";
$xlApp->ActiveSheet->Cells(1,12)->Value = "tell";
$xlApp->ActiveSheet->Cells(1,13)->Value = "mobile";
$xlApp->ActiveSheet->Cells(1,14)->Value = "mobile2";
$xlApp->ActiveSheet->Cells(1,15)->Value = "office";
$xlApp->ActiveSheet->Cells(1,16)->Value = "care_b";
$xlApp->ActiveSheet->Cells(1,17)->Value = "caren_b";
$xlApp->ActiveSheet->Cells(1,18)->Value = "email";
$xlApp->ActiveSheet->Cells(1,19)->Value = "car";
$xlApp->ActiveSheet->Cells(1,20)->Value = "type_c";
$xlApp->ActiveSheet->Cells(1,21)->Value = "respond";
//***********//
$intRows = 2;
while($objResult = mysql_fetch_array($objQuery))
{
//*** Detail ***//
$xlApp->ActiveSheet->Cells($intRows,1)->Value = $objResult["boc_id"];
$xlApp->ActiveSheet->Cells($intRows,2)->Value = $objResult["date_boc"];
$xlApp->ActiveSheet->Cells($intRows,3)->Value = $objResult["ti_b"];
$xlApp->ActiveSheet->Cells($intRows,4)->Value = $objResult["name_b"];
$xlApp->ActiveSheet->Cells($intRows,5)->Value = $objResult["lastname_b"];
$xlApp->ActiveSheet->Cells($intRows,6)->Value = $objResult["gend_b"];
$xlApp->ActiveSheet->Cells($intRows,7)->Value = $objResult["add_b"];
$xlApp->ActiveSheet->Cells($intRows,8)->Value = $objResult["tum_b"];
$xlApp->ActiveSheet->Cells($intRows,9)->Value = $objResult["dis_b"];
$xlApp->ActiveSheet->Cells($intRows,10)->Value = $objResult["pro_b"];
$xlApp->ActiveSheet->Cells($intRows,11)->Value = $objResult["zip_b"];
$xlApp->ActiveSheet->Cells($intRows,12)->Value = $objResult["tell"];
$xlApp->ActiveSheet->Cells($intRows,13)->Value = $objResult["mobile"];
$xlApp->ActiveSheet->Cells($intRows,14)->Value = $objResult["mobile2"];
$xlApp->ActiveSheet->Cells($intRows,15)->Value = $objResult["office"];
$xlApp->ActiveSheet->Cells($intRows,16)->Value = $objResult["care_b"];
$xlApp->ActiveSheet->Cells($intRows,17)->Value = $objResult["caren_b"];
$xlApp->ActiveSheet->Cells($intRows,18)->Value = $objResult["email"];
$xlApp->ActiveSheet->Cells($intRows,19)->Value = $objResult["car_b"];
$xlApp->ActiveSheet->Cells($intRows,20)->Value = $objResult["type_c"];
$xlApp->ActiveSheet->Cells($intRows,21)->Value = $objResult["respond"];
$intRows++;
}
@unlink($strFileName); //*** Delete old files ***//
$xlBook->SaveAs($strPath."/".$strFileName); //*** Save to Path ***//
//*** Close & Quit ***//
$xlApp->Application->Quit();
$xlApp = null;
$xlBook = null;
$xlSheet1 = null;
}
mysql_close($objConnect);
?>
Excel Wonderful ใบปลิว <a href="<?=$strFileName?>">Click here</a> to Download.
</body>
</html>
อันนี้โค๊ชครับผม
Date :
2012-07-24 14:00:14
By :
kritsana7
ขอโทษครับ ตกม้าตายอย่างแรง
เพราะ server ไม่ได้ ms office ครับ
มิน่าไม่ได้ซะที T T
ขอขอบคุณนะครับ
Date :
2012-07-24 14:28:24
By :
kritsana7
Load balance : Server 05