Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > report excel ไม่ขึ้นครับ ช่วยดูให้ผมที ผมรันแล้วมันไม่ขึ้นอะไรเลยอ่ะครับ



 

report excel ไม่ขึ้นครับ ช่วยดูให้ผมที ผมรันแล้วมันไม่ขึ้นอะไรเลยอ่ะครับ

 



Topic : 111832



โพสกระทู้ ( 36 )
บทความ ( 0 )



สถานะออฟไลน์




Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$conn = mysql_connect("localhost", "root", "1234");
mysql_query("SET NAMES tis620", $conn);
mysql_query("USE num_new");
$sql = "SELECT * FROM student";
$result = mysql_query($sql);
if($result){         
//*** Get Document Path ***//
$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp
//*** Excel Document Root ***//
$strFileName = "MyXls/MyExcel.xls";
//*** Connect to Excel.Application ***//
$xlApp = new COM("Excel.Application");
$xlBook = $xlApp->Workbooks->Add();
//*** Create Sheet 1 ***//
$xlBook->Worksheets(1)->Name = "My Student";                         
$xlBook->Worksheets(1)->Select;
//*** Width & Height (A1:A1) ***//
$xlApp->ActiveSheet->Range("A1:A1")->ColumnWidth = 13.0;
$xlApp->ActiveSheet->Range("B1:B1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("C1:C1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("D1:D1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("E1:E1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("F1:F1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("G1:G1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("H1:H1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("I1:I1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("J1:J1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("K1:K1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("L1:L1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("M1:M1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("N1:N1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("O1:O1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("P1:P1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("Q1:Q1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("R1:R1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("S1:S1")->ColumnWidth = 20.0;
$xlApp->ActiveSheet->Range("T1:T1")->ColumnWidth = 20.0;

//*** Report Title ***//
$xlApp->ActiveSheet->Range("F1:J1")->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Range("F1:J1")->MergeCells = True;
$xlApp->ActiveSheet->Range("F1:J1")->Font->Bold = True;
$xlApp->ActiveSheet->Range("F1:J1")->Font->Size = 20;
$xlApp->ActiveSheet->Range("F1:J1")->HorizontalAlignment = -4108;             
$xlApp->ActiveSheet->Cells(1,1)->Value = "ภูมิลำเนาทหาร";

$xlApp->ActiveSheet->Range("M1:Q1")->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Range("M1:Q1")->MergeCells = True;
$xlApp->ActiveSheet->Range("M1:Q1")->Font->Bold = True;
$xlApp->ActiveSheet->Range("M1:Q1")->Font->Size = 20;
$xlApp->ActiveSheet->Range("M1:Q1")->HorizontalAlignment = -4108;             
$xlApp->ActiveSheet->Cells(1,1)->Value = "ภูมิลำเนาปัจจุบัน";
//*** Header ***//             
$xlApp->ActiveSheet->Cells(3,1)->Value = "ลำดับที่";
$xlApp->ActiveSheet->Cells(3,1)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,1)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,1)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,1)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,2)->Value = "รหัสนักศึกษา";
$xlApp->ActiveSheet->Cells(3,2)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,2)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,2)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,2)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,3)->Value = "ชื่อ-นามสกุล";
$xlApp->ActiveSheet->Cells(3,3)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,3)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,3)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,3)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,4)->Value = "หมายเลขบัตรประชาชน";
$xlApp->ActiveSheet->Cells(3,4)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,4)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,4)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,4)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,5)->Value = "พ.ศ.เกิด";
$xlApp->ActiveSheet->Cells(3,5)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,5)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,5)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,5)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,6)->Value = "ที่อยู่";
$xlApp->ActiveSheet->Cells(3,6)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,6)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,6)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,6)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,7)->Value = "หมู่";
$xlApp->ActiveSheet->Cells(3,7)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,7)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,7)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,7)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,8)->Value = "ตำบล";
$xlApp->ActiveSheet->Cells(3,8)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,8)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,8)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,8)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,9)->Value = "อำเภอ";
$xlApp->ActiveSheet->Cells(3,9)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,9)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,9)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,9)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,10)->Value = "จังหวัด";
$xlApp->ActiveSheet->Cells(3,10)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,10)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,10)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,10)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,11)->Value = "ชื่อบิดา";
$xlApp->ActiveSheet->Cells(3,11)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,11)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,11)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,11)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,12)->Value = "ชื่อมารดา";
$xlApp->ActiveSheet->Cells(3,12)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,12)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,12)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,12)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,13)->Value = "ที่อยู่";
$xlApp->ActiveSheet->Cells(3,13)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,13)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,13)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,13)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,14)->Value = "หมู่";
$xlApp->ActiveSheet->Cells(3,14)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,14)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,14)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,14)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,15)->Value = "ตำบล";
$xlApp->ActiveSheet->Cells(3,15)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,15)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,15)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,15)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,16)->Value = "อำเภอ";
$xlApp->ActiveSheet->Cells(3,16)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,16)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,16)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,16)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,17)->Value = "จังหวัด";
$xlApp->ActiveSheet->Cells(3,17)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,17)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,17)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,17)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,18)->Value = "ใบสำคัญที่/พ.ศ.";
$xlApp->ActiveSheet->Cells(3,18)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,18)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,18)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,18)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,19)->Value = "เบอร์โทรศัพท์";
$xlApp->ActiveSheet->Cells(3,19)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,19)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,19)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,19)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells(3,20)->Value = "ส่งข้อมูลวันที่";
$xlApp->ActiveSheet->Cells(3,20)->Font->Bold = True;
$xlApp->ActiveSheet->Cells(3,20)->VerticalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,20)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells(3,20)->BORDERS->Weight = 1;


//***********//
$intRows = 20;
while($objResult = mysql_fetch_array($objQuery))
{
//*** Detail ***//
$xlApp->ActiveSheet->Cells($intRows,1)->Value = $objResult["stdnum"];
$xlApp->ActiveSheet->Cells($intRows,1)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,1)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,2)->Value = $objResult["stdid"];
$xlApp->ActiveSheet->Cells($intRows,2)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,1)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,3)->Value = $objResult["name"];
$xlApp->ActiveSheet->Cells($intRows,3)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,1)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,4)->Value = $objResult["number"];
$xlApp->ActiveSheet->Cells($intRows,4)->HorizontalAlignment = -4108;
$xlApp->ActiveSheet->Cells($intRows,4)->BORDERS->Weight = 1;

$xlApp->ActiveSheet->Cells($intRows,5)->Value = $objResult["date"];
$xlApp->ActiveSheet->Cells($intRows,5)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,5)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,6)->Value = $objResult["adr"];
$xlApp->ActiveSheet->Cells($intRows,6)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,6)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,7)->Value = $objResult["type"];
$xlApp->ActiveSheet->Cells($intRows,7)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,7)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,8)->Value = $objResult["place"];
$xlApp->ActiveSheet->Cells($intRows,8)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,8)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,9)->Value = $objResult["district"];
$xlApp->ActiveSheet->Cells($intRows,9)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,9)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,10)->Value = $objResult["provide"];
$xlApp->ActiveSheet->Cells($intRows,10)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,10)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,11)->Value = $objResult["named"];
$xlApp->ActiveSheet->Cells($intRows,11)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,11)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,12)->Value = $objResult["namem"];
$xlApp->ActiveSheet->Cells($intRows,12)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,12)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,13)->Value = $objResult["adr1"];
$xlApp->ActiveSheet->Cells($intRows,13)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,13)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,14)->Value = $objResult["type1"];
$xlApp->ActiveSheet->Cells($intRows,14)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,14)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,15)->Value = $objResult["place1"];
$xlApp->ActiveSheet->Cells($intRows,15)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,15)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,16)->Value = $objResult["district1"];
$xlApp->ActiveSheet->Cells($intRows,16)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,16)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,17)->Value = $objResult["provide1"];
$xlApp->ActiveSheet->Cells($intRows,17)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,17)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,18)->Value = $objResult["numsd9"];
$xlApp->ActiveSheet->Cells($intRows,18)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,18)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,19)->Value = $objResult["tel"];
$xlApp->ActiveSheet->Cells($intRows,19)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,19)->HorizontalAlignment = -4108;

$xlApp->ActiveSheet->Cells($intRows,20)->Value = $objResult["time"];
$xlApp->ActiveSheet->Cells($intRows,20)->BORDERS->Weight = 1;
$xlApp->ActiveSheet->Cells($intRows,20)->HorizontalAlignment = -4108;

$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($conn);    
?>
</body>
</html>


นี่โค๊ดครับ



Tag : PHP, Excel (Excel.Application)







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-10-09 17:59:34 By : jakkrapop View : 625 Reply : 1
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ตัวนี้จะต้องใช้ Engine ของ Microsoft Office Excel ครับ และอาจจะติดปัญหาเรื่องสิทธิ์ในการใช้งานครับ แนะนำให้ไปใช้ PHPExcel แทนครับ

สร้าง Excel (xls,xlsx) ไฟล์ด้วย PHPExcel และการส่งออก Export







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-10-10 09:33:55 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : report excel ไม่ขึ้นครับ ช่วยดูให้ผมที ผมรันแล้วมันไม่ขึ้นอะไรเลยอ่ะครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่