|
|
|
ติดปัญหา mysql ไป excel Fatal error: Uncaught exception 'com_exception' with message |
|
|
|
|
|
|
|
นีครับติด error
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft Office Excel<br/><b>Description:</b> ไม่สามารถเรียกคุณสมบัติ Add ของคลาส Workbooks ได้' in D:\AppServ\www\utcc\777.php:23 Stack trace: #0 D:\AppServ\www\utcc\777.php(23): variant->Add() #1 {main} thrown in D:\AppServ\www\utcc\777.php on line 23
Code
Code (PHP)
<?php
include "connect.php";
//$strFileName = "/point/point.xls";
$sql="select * from point_lab order by id_num ";
$result=mysql_db_query($dbname,$sql);
if($result){
$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp
// Excel Document Root //
$strFileName = "/point/point.xls";
// Connect to Excel.Application //
$xlApp = new COM("Excel.Application");
$xlBook = $xlApp->Workbooks->Add();
// Create Sheet 1 //
$xlBook->Worksheets(1)->Name = "My Customer";
$xlBook->Worksheets(1)->Select;
// Header //
$xlApp->ActiveSheet->Cells(1,1)->Value = "CustomerID";
$xlApp->ActiveSheet->Cells(1,2)->Value = "UserID";
$xlApp->ActiveSheet->Cells(1,3)->Value = "Name";
$xlApp->ActiveSheet->Cells(1,4)->Value = "group";
$xlApp->ActiveSheet->Cells(1,5)->Value = "week1";
$xlApp->ActiveSheet->Cells(1,6)->Value = "week2";
////
$intRows = 2;
while($row = mysql_fetch_array($result))
{
// Detail //
$xlApp->ActiveSheet->Cells($intRows,1)->Value = $row["id_num"];
$xlApp->ActiveSheet->Cells($intRows,2)->Value = $row["id_st"];
$xlApp->ActiveSheet->Cells($intRows,3)->Value = $row["tea_name"];
$xlApp->ActiveSheet->Cells($intRows,4)->Value = $row["group"];
$xlApp->ActiveSheet->Cells($intRows,5)->Value = $row["week1"];
$xlApp->ActiveSheet->Cells($intRows,6)->Value = $row["week2"];
$intRows++;
}
@unlink($strFileName); // Delete old files //
$xlBook->SaveAs($strPath."/".$strFileName); //*** Save to Path //
$xlBook->SaveAs(realpath($strFileName)); //*** Save to Path //
// Close & Quit //
$xlApp->Application->Quit();
$xlApp = null;
$xlBook = null;
$xlSheet1 = null;
}
mysql_close();
?>
Tag : - - - -
|
|
|
|
|
|
Date :
2009-09-15 12:06:21 |
By :
raikajman |
View :
1705 |
Reply :
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$xlApp = new COM("Excel.Application");
$xlBook = $xlApp->Workbooks->Add();
สองตัวนี้ครับ บรรทัด 13
|
|
|
|
|
Date :
2009-09-15 12:12:12 |
By :
raikajman |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมใช้ appserv config ยังไงครับ
|
|
|
|
|
Date :
2009-09-15 12:55:10 |
By :
raikajman |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คลิกเข้าไปแล้วลองทำตามลิงค์ที่พี่วินให้มาอะครับ
|
|
|
|
|
Date :
2009-09-15 13:02:27 |
By :
plakrim |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมก็ติด แต่ลองทำแล้วแต่มันไม่ได้ครับ
|
|
|
|
|
Date :
2011-03-07 09:45:27 |
By :
emozerorise |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|