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 > ช่วยดูโค้ตให้หน่อยครับเกี่ยวกับการออกรายงาน ผมโหลดโค้ตมาพอลองรันดูก็ Error ครับ รบกวนดูให้หน่อยครับ



 

ช่วยดูโค้ตให้หน่อยครับเกี่ยวกับการออกรายงาน ผมโหลดโค้ตมาพอลองรันดูก็ Error ครับ รบกวนดูให้หน่อยครับ

 



Topic : 040178



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



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




ผมโหลดโค้ตมาพอลองรันดูก็ Error ครับ รบกวนดูให้หน่อยครับ ขอบคุณมากครับ
Error ครับ : Parse error: parse error, unexpected T_OBJECT_OPERATOR in e:\appserv\www\phpexportdatabasetoexcelreportformat.php on line 25

Code ครับ
view source
print?
001.<html>
002.<head>
003.<title>ThaiCreate.Com PHP(COM) Excel.Application Tutorial</title>
004.</head>
005.<body>
006.<?
007. $objConnect = mysql_connect("localhost","mysql","") or die("Error Connect to Database");
008. $objDB = mysql_select_db("mydatabase");
009. $strSQL = "SELECT * FROM customer";
010. $objQuery = mysql_query($strSQL);
011. if($objQuery)
012. {
013. //*** Get Document Path ***//
014. $strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp
015.
016. //*** Excel Document Root ***//
017. $strFileName = "MyXls/MyExcel.xls";
018.
019. //*** Connect to Excel.Application ***//
020. $xlApp = new COM("Excel.Application");
021. $xlBook = $xlApp->Workbooks->Add();
022.
023.
024. //*** Create Sheet 1 ***//
025. $xlBook->Worksheets(1)->Name = "My Customer";
026. $xlBook->Worksheets(1)->Select;
027.
028. //*** Width & Height (A1:A1) ***//
029. $xlApp->ActiveSheet->Range("A1:A1")->ColumnWidth = 10.0;
030. $xlApp->ActiveSheet->Range("B1:B1")->ColumnWidth = 13.0;
031. $xlApp->ActiveSheet->Range("C1:C1")->ColumnWidth = 23.0;
032. $xlApp->ActiveSheet->Range("D1:D1")->ColumnWidth = 12.0;
033. $xlApp->ActiveSheet->Range("E1:E1")->ColumnWidth = 13.0;
034. $xlApp->ActiveSheet->Range("F1:F1")->ColumnWidth = 12.0;
035.
036. //*** Report Title ***//
037. $xlApp->ActiveSheet->Range("A1:F1")->BORDERS->Weight = 1;
038. $xlApp->ActiveSheet->Range("A1:F1")->MergeCells = True;
039. $xlApp->ActiveSheet->Range("A1:F1")->Font->Bold = True;
040. $xlApp->ActiveSheet->Range("A1:F1")->Font->Size = 20;
041. $xlApp->ActiveSheet->Range("A1:F1")->HorizontalAlignment = -4108;
042. $xlApp->ActiveSheet->Cells(1,1)->Value = "Customer Report";
043.
044. //*** Header ***//
045. $xlApp->ActiveSheet->Cells(3,1)->Value = "CustomerID";
046. $xlApp->ActiveSheet->Cells(3,1)->Font->Bold = True;
047. $xlApp->ActiveSheet->Cells(3,1)->VerticalAlignment = -4108;
048. $xlApp->ActiveSheet->Cells(3,1)->HorizontalAlignment = -4108;
049. $xlApp->ActiveSheet->Cells(3,1)->BORDERS->Weight = 1;
050.
051. $xlApp->ActiveSheet->Cells(3,2)->Value = "Name";
052. $xlApp->ActiveSheet->Cells(3,2)->Font->Bold = True;
053. $xlApp->ActiveSheet->Cells(3,2)->VerticalAlignment = -4108;
054. $xlApp->ActiveSheet->Cells(3,2)->HorizontalAlignment = -4108;
055. $xlApp->ActiveSheet->Cells(3,2)->BORDERS->Weight = 1;
056.
057. $xlApp->ActiveSheet->Cells(3,3)->Value = "Email";
058. $xlApp->ActiveSheet->Cells(3,3)->Font->Bold = True;
059. $xlApp->ActiveSheet->Cells(3,3)->VerticalAlignment = -4108;
060. $xlApp->ActiveSheet->Cells(3,3)->HorizontalAlignment = -4108;
061. $xlApp->ActiveSheet->Cells(3,3)->BORDERS->Weight = 1;
062.
063. $xlApp->ActiveSheet->Cells(3,4)->Value = "CountryCode";
064. $xlApp->ActiveSheet->Cells(3,4)->Font->Bold = True;
065. $xlApp->ActiveSheet->Cells(3,4)->VerticalAlignment = -4108;
066. $xlApp->ActiveSheet->Cells(3,4)->HorizontalAlignment = -4108;
067. $xlApp->ActiveSheet->Cells(3,4)->BORDERS->Weight = 1;
068.
069. $xlApp->ActiveSheet->Cells(3,5)->Value = "Budget";
070. $xlApp->ActiveSheet->Cells(3,5)->Font->Bold = True;
071. $xlApp->ActiveSheet->Cells(3,5)->VerticalAlignment = -4108;
072. $xlApp->ActiveSheet->Cells(3,5)->HorizontalAlignment = -4108;
073. $xlApp->ActiveSheet->Cells(3,5)->BORDERS->Weight = 1;
074.
075. $xlApp->ActiveSheet->Cells(3,6)->Value = "Used";
076. $xlApp->ActiveSheet->Cells(3,6)->Font->Bold = True;
077. $xlApp->ActiveSheet->Cells(3,6)->VerticalAlignment = -4108;
078. $xlApp->ActiveSheet->Cells(3,6)->HorizontalAlignment = -4108;
079. $xlApp->ActiveSheet->Cells(3,6)->BORDERS->Weight = 1;
080.
081. //***********//
082.
083. $intRows = 4;
084. while($objResult = mysql_fetch_array($objQuery))
085. {
086.
087. //*** Detail ***//
088. $xlApp->ActiveSheet->Cells($intRows,1)->Value = $objResult["CustomerID"];
089. $xlApp->ActiveSheet->Cells($intRows,1)->BORDERS->Weight = 1;
090. $xlApp->ActiveSheet->Cells($intRows,1)->HorizontalAlignment = -4108;
091.
092. $xlApp->ActiveSheet->Cells($intRows,2)->Value = $objResult["Name"];
093. $xlApp->ActiveSheet->Cells($intRows,2)->BORDERS->Weight = 1;
094.
095. $xlApp->ActiveSheet->Cells($intRows,3)->Value = $objResult["Email"];
096. $xlApp->ActiveSheet->Cells($intRows,3)->BORDERS->Weight = 1;
097.
098. $xlApp->ActiveSheet->Cells($intRows,4)->Value = $objResult["CountryCode"];
099. $xlApp->ActiveSheet->Cells($intRows,4)->HorizontalAlignment = -4108;
100. $xlApp->ActiveSheet->Cells($intRows,4)->BORDERS->Weight = 1;
101.
102. $xlApp->ActiveSheet->Cells($intRows,5)->Value = $objResult["Budget"];
103. $xlApp->ActiveSheet->Cells($intRows,5)->BORDERS->Weight = 1;
104. $xlApp->ActiveSheet->Cells($intRows,5)->NumberFormat = "$#,##0.00";
105.
106. $xlApp->ActiveSheet->Cells($intRows,6)->Value = $objResult["Used"];
107. $xlApp->ActiveSheet->Cells($intRows,6)->BORDERS->Weight = 1;
108.
109. $intRows++;
110. }
111.
112. @unlink($strFileName); //*** Delete old files ***//
113.
114. $xlBook->SaveAs($strPath."/".$strFileName); //*** Save to Path ***//
115.
116. //*** Close & Quit ***//
117. $xlApp->Application->Quit();
118. $xlApp = null;
119. $xlBook = null;
120. $xlSheet1 = null;
121.
122. }
123.
124. mysql_close($objConnect);
125.
126.?>
127.Excel Created <a href="<?=$strFileName?>">Click here</a> to Download.
128.</body>
129.</html>



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-03-11 01:11:11 By : เตาะแตะ View : 741 Reply : 0
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยดูโค้ตให้หน่อยครับเกี่ยวกับการออกรายงาน ผมโหลดโค้ตมาพอลองรันดูก็ Error ครับ รบกวนดูให้หน่อยครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 03
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 อัตราราคา คลิกที่นี่