01.
<html>
02.
<head>
03.
<title>Hock An Tueng Groups</title>
04.
</head>
05.
<body>
06.
<?
07.
$objConnect
= mysql_connect(
"localhost"
,
"root"
,
"upxowffj"
)
or
die
(
"Not Connect to Database!!"
);
08.
$objDB
= mysql_select_db(
"isuzu_acc"
);
09.
$strSQL
=
"SELECT * FROM won_bo"
;
10.
mysql_query(
"set NAMES tis620"
);
11.
$objQuery
= mysql_query(
$strSQL
);
12.
if
(
$objQuery
)
13.
{
14.
15.
$strPath
=
realpath
(
basename
(
getenv
(
$_SERVER
[
"SCRIPT_NAME"
])));
16.
17.
18.
$strFileName
=
"MyXls/won_bo.xls"
;
19.
20.
21.
$xlApp
=
new
COM(
"Excel.Application"
);
22.
$xlBook
=
$xlApp
->Workbooks->Add();
23.
24.
25.
26.
$xlBook
->Worksheets(1)->Name =
"Customer from boc"
;
27.
$xlBook
->Worksheets(1)->Select;
28.
29.
30.
$xlApp
->ActiveSheet->Cells(1,1)->Value =
"boc_id"
;
31.
$xlApp
->ActiveSheet->Cells(1,2)->Value =
"date_boc"
;
32.
$xlApp
->ActiveSheet->Cells(1,3)->Value =
"ti_b"
;
33.
$xlApp
->ActiveSheet->Cells(1,4)->Value =
"name_b"
;
34.
$xlApp
->ActiveSheet->Cells(1,5)->Value =
"lastname_b"
;
35.
$xlApp
->ActiveSheet->Cells(1,6)->Value =
"gend_b"
;
36.
$xlApp
->ActiveSheet->Cells(1,7)->Value =
"add_b"
;
37.
$xlApp
->ActiveSheet->Cells(1,8)->Value =
"tum_b"
;
38.
$xlApp
->ActiveSheet->Cells(1,9)->Value =
"dis_b"
;
39.
$xlApp
->ActiveSheet->Cells(1,10)->Value =
"pro_b"
;
40.
$xlApp
->ActiveSheet->Cells(1,11)->Value =
"zip_b"
;
41.
$xlApp
->ActiveSheet->Cells(1,12)->Value =
"tell"
;
42.
$xlApp
->ActiveSheet->Cells(1,13)->Value =
"mobile"
;
43.
$xlApp
->ActiveSheet->Cells(1,14)->Value =
"mobile2"
;
44.
$xlApp
->ActiveSheet->Cells(1,15)->Value =
"office"
;
45.
$xlApp
->ActiveSheet->Cells(1,16)->Value =
"care_b"
;
46.
$xlApp
->ActiveSheet->Cells(1,17)->Value =
"caren_b"
;
47.
$xlApp
->ActiveSheet->Cells(1,18)->Value =
"email"
;
48.
$xlApp
->ActiveSheet->Cells(1,19)->Value =
"car"
;
49.
$xlApp
->ActiveSheet->Cells(1,20)->Value =
"type_c"
;
50.
$xlApp
->ActiveSheet->Cells(1,21)->Value =
"respond"
;
51.
52.
53.
$intRows
= 2;
54.
while
(
$objResult
= mysql_fetch_array(
$objQuery
))
55.
{
56.
57.
$xlApp
->ActiveSheet->Cells(
$intRows
,1)->Value =
$objResult
[
"boc_id"
];
58.
$xlApp
->ActiveSheet->Cells(
$intRows
,2)->Value =
$objResult
[
"date_boc"
];
59.
$xlApp
->ActiveSheet->Cells(
$intRows
,3)->Value =
$objResult
[
"ti_b"
];
60.
$xlApp
->ActiveSheet->Cells(
$intRows
,4)->Value =
$objResult
[
"name_b"
];
61.
$xlApp
->ActiveSheet->Cells(
$intRows
,5)->Value =
$objResult
[
"lastname_b"
];
62.
$xlApp
->ActiveSheet->Cells(
$intRows
,6)->Value =
$objResult
[
"gend_b"
];
63.
$xlApp
->ActiveSheet->Cells(
$intRows
,7)->Value =
$objResult
[
"add_b"
];
64.
$xlApp
->ActiveSheet->Cells(
$intRows
,8)->Value =
$objResult
[
"tum_b"
];
65.
$xlApp
->ActiveSheet->Cells(
$intRows
,9)->Value =
$objResult
[
"dis_b"
];
66.
$xlApp
->ActiveSheet->Cells(
$intRows
,10)->Value =
$objResult
[
"pro_b"
];
67.
$xlApp
->ActiveSheet->Cells(
$intRows
,11)->Value =
$objResult
[
"zip_b"
];
68.
$xlApp
->ActiveSheet->Cells(
$intRows
,12)->Value =
$objResult
[
"tell"
];
69.
$xlApp
->ActiveSheet->Cells(
$intRows
,13)->Value =
$objResult
[
"mobile"
];
70.
$xlApp
->ActiveSheet->Cells(
$intRows
,14)->Value =
$objResult
[
"mobile2"
];
71.
$xlApp
->ActiveSheet->Cells(
$intRows
,15)->Value =
$objResult
[
"office"
];
72.
$xlApp
->ActiveSheet->Cells(
$intRows
,16)->Value =
$objResult
[
"care_b"
];
73.
$xlApp
->ActiveSheet->Cells(
$intRows
,17)->Value =
$objResult
[
"caren_b"
];
74.
$xlApp
->ActiveSheet->Cells(
$intRows
,18)->Value =
$objResult
[
"email"
];
75.
$xlApp
->ActiveSheet->Cells(
$intRows
,19)->Value =
$objResult
[
"car_b"
];
76.
$xlApp
->ActiveSheet->Cells(
$intRows
,20)->Value =
$objResult
[
"type_c"
];
77.
$xlApp
->ActiveSheet->Cells(
$intRows
,21)->Value =
$objResult
[
"respond"
];
78.
$intRows
++;
79.
}
80.
81.
@unlink(
$strFileName
);
82.
83.
$xlBook
->SaveAs(
$strPath
.
"/"
.
$strFileName
);
84.
85.
86.
$xlApp
->Application->Quit();
87.
$xlApp
= null;
88.
$xlBook
= null;
89.
$xlSheet1
= null;
90.
91.
}
92.
93.
mysql_close(
$objConnect
);
94.
?>
95.
Excel Wonderful ใบปลิว <a href=
"<?=$strFileName?>"
>Click here</a> to Download.
96.
</body>
97.
</html>