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 > ช่วยเช็คโค๊ตด้วยค่ะ จะ export เป็น excel แต่มันฟ้อง Fatal error: Uncaught exception ค่ะ



 

ช่วยเช็คโค๊ตด้วยค่ะ จะ export เป็น excel แต่มันฟ้อง Fatal error: Uncaught exception ค่ะ

 



Topic : 039263



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



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




Code (PHP)
<?
		include "conn.inc.php";
		$objDB = mysql_select_db("Fishery_db");
		$strSQL = $sqlgetarea;
		$objQuery = mysql_query($strSQL);
		if($objQuery)
		{			
				//*** Get Document Path ***//
				$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp

				//*** Excel Document Root ***//
				$strFileName = "MyXls/landarea.xls";

				//*** Connect to Excel.Application ***//
				$xlApp = new COM("Excel.Application");
				$xlBook = $xlApp->Workbooks->Add();


				//*** Create Sheet 1 ***//
				$xlBook->Worksheets(1)->Name = "Land Area";							
				$xlBook->Worksheets(1)->Select;

				//*** Width & Height (A1:A1) ***//
				$xlApp->ActiveSheet->Range("A2")->ColumnWidth = 8.38;
				$xlApp->ActiveSheet->Range("B4")->ColumnWidth = 8.38;
				$xlApp->ActiveSheet->Range("C4")->ColumnWidth = 8.38;
				$xlApp->ActiveSheet->Range("B7")->ColumnWidth = 8.38;
				$xlApp->ActiveSheet->Range("C7")->ColumnWidth = 8.38;
				$xlApp->ActiveSheet->Range("D7")->ColumnWidth = 8.38;
				$xlApp->ActiveSheet->Range("E4")->ColumnWidth = 8.38;
				$xlApp->ActiveSheet->Range("F6")->ColumnWidth = 8.38;
				$xlApp->ActiveSheet->Range("F7")->ColumnWidth = 8.38;
				$xlApp->ActiveSheet->Range("G7")->ColumnWidth = 8.38;
				$xlApp->ActiveSheet->Range("H7")->ColumnWidth = 8.38;
				$xlApp->ActiveSheet->Range("I7")->ColumnWidth = 8.38;

				//*** Report Title ***//
				$xlApp->ActiveSheet->Range("B2:I2")->BORDERS->Weight = 1;
				$xlApp->ActiveSheet->Range("B2:I2")->MergeCells = True;
				$xlApp->ActiveSheet->Range("B2:I2")->Font->Bold = True;
				$xlApp->ActiveSheet->Range("B2:I2")->Font->Size = 10;
				$xlApp->ActiveSheet->Range("B2:I2")->HorizontalAlignment = -4108;				
				$xlApp->ActiveSheet->Cells(1,1)->Value = "Land Area, Length of Coastline and Inland Water Area";

				//*** Header ***//				
				$xlApp->ActiveSheet->Cells(7,1)->Value = "Country, Sub-area";
				$xlApp->ActiveSheet->Cells(7,1)->Font->Bold = True;
				$xlApp->ActiveSheet->Cells(7,1)->VerticalAlignment = -4108; 
				$xlApp->ActiveSheet->Cells(7,1)->HorizontalAlignment = -4108; 
				$xlApp->ActiveSheet->Cells(7,1)->BORDERS->Weight = 1;
				
				$xlApp->ActiveSheet->Cells(7,2)->Value = "Year";
				$xlApp->ActiveSheet->Cells(7,2)->Font->Bold = True;
				$xlApp->ActiveSheet->Cells(7,2)->VerticalAlignment = -4108; 
				$xlApp->ActiveSheet->Cells(7,2)->HorizontalAlignment = -4108;
				$xlApp->ActiveSheet->Cells(7,2)->BORDERS->Weight = 1;
					
				$xlApp->ActiveSheet->Cells(7,3)->Value = "Total land area (Km<sup>2</sup>)";
				$xlApp->ActiveSheet->Cells(7,3)->Font->Bold = True;
				$xlApp->ActiveSheet->Cells(7,3)->VerticalAlignment = -4108;
				$xlApp->ActiveSheet->Cells(7,3)->HorizontalAlignment = -4108; 
				$xlApp->ActiveSheet->Cells(7,3)->BORDERS->Weight = 1;
				
				$xlApp->ActiveSheet->Cells(7,4)->Value = "Length of coastline (Km)";
				$xlApp->ActiveSheet->Cells(7,4)->Font->Bold = True;
				$xlApp->ActiveSheet->Cells(7,4)->VerticalAlignment = -4108; 
				$xlApp->ActiveSheet->Cells(7,4)->HorizontalAlignment = -4108; 
				$xlApp->ActiveSheet->Cells(7,4)->BORDERS->Weight = 1;
				
				$xlApp->ActiveSheet->Cells(7,5)->Value = "Reservoir";
				$xlApp->ActiveSheet->Cells(7,5)->Font->Bold = True;
				$xlApp->ActiveSheet->Cells(7,5)->VerticalAlignment = -4108; 
				$xlApp->ActiveSheet->Cells(7,5)->HorizontalAlignment = -4108; 
				$xlApp->ActiveSheet->Cells(7,5)->BORDERS->Weight = 1;
				
				$xlApp->ActiveSheet->Cells(7,6)->Value = "Lake";
				$xlApp->ActiveSheet->Cells(7,6)->Font->Bold = True;
				$xlApp->ActiveSheet->Cells(7,6)->VerticalAlignment = -4108; 
				$xlApp->ActiveSheet->Cells(7,6)->HorizontalAlignment = -4108;
				$xlApp->ActiveSheet->Cells(7,6)->BORDERS->Weight = 1;
				
								
				$xlApp->ActiveSheet->Cells(7,7)->Value = "River";
				$xlApp->ActiveSheet->Cells(7,7)->Font->Bold = True;
				$xlApp->ActiveSheet->Cells(7,7)->VerticalAlignment = -4108; 
				$xlApp->ActiveSheet->Cells(7,7)->HorizontalAlignment = -4108; 
				$xlApp->ActiveSheet->Cells(7,7)->BORDERS->Weight = 1;
				
				$xlApp->ActiveSheet->Cells(7,8)->Value = "Other";
				$xlApp->ActiveSheet->Cells(7,8)->Font->Bold = True;
				$xlApp->ActiveSheet->Cells(7,8)->VerticalAlignment = -4108; 
				$xlApp->ActiveSheet->Cells(7,8)->HorizontalAlignment = -4108;
				$xlApp->ActiveSheet->Cells(7,8)->BORDERS->Weight = 1;

				//***********//
			
				$intRows = 8;
				while($objResult = mysql_fetch_array($objQuery))
				{
				
				//*** Detail ***//
				$xlApp->ActiveSheet->Cells($intRows,1)->Value = $objResult["Country, Sub-area"];
				$xlApp->ActiveSheet->Cells($intRows,1)->BORDERS->Weight = 1;
				$xlApp->ActiveSheet->Cells($intRows,1)->HorizontalAlignment = -4108;
				
				$xlApp->ActiveSheet->Cells($intRows,2)->Value = $objResult["Year"];
				$xlApp->ActiveSheet->Cells($intRows,2)->BORDERS->Weight = 1;
				
				$xlApp->ActiveSheet->Cells($intRows,3)->Value = $objResult["Total land area (Km2)"];
				$xlApp->ActiveSheet->Cells($intRows,3)->BORDERS->Weight = 1;
				
				$xlApp->ActiveSheet->Cells($intRows,4)->Value = $objResult["Length of coastline (Km)"];
				$xlApp->ActiveSheet->Cells($intRows,4)->HorizontalAlignment = -4108;
				$xlApp->ActiveSheet->Cells($intRows,4)->BORDERS->Weight = 1;
				
				$xlApp->ActiveSheet->Cells($intRows,5)->Value = $objResult["Reservoir"];
				$xlApp->ActiveSheet->Cells($intRows,5)->BORDERS->Weight = 1;
				$xlApp->ActiveSheet->Cells($intRows,5)->NumberFormat = "$#,##0.00";
				
				$xlApp->ActiveSheet->Cells($intRows,6)->Value = $objResult["Lake"];
				$xlApp->ActiveSheet->Cells($intRows,6)->BORDERS->Weight = 1;
				$xlApp->ActiveSheet->Cells($intRows,6)->NumberFormat = "$#,##0.00";
				
				$xlApp->ActiveSheet->Cells($intRows,7)->Value = $objResult["River"];
				$xlApp->ActiveSheet->Cells($intRows,7)->BORDERS->Weight = 1;
				$xlApp->ActiveSheet->Cells($intRows,7)->NumberFormat = "$#,##0.00";
				
				$xlApp->ActiveSheet->Cells($intRows,8)->Value = $objResult["Other"];
				$xlApp->ActiveSheet->Cells($intRows,8)->BORDERS->Weight = 1;
				$xlApp->ActiveSheet->Cells($intRows,8)->NumberFormat = "$#,##0.00";

				$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($objConnect);		

?>



Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft Office Excel<br/><b>Description:</b> Microsoft Office Excel cannot access the file 'C:\AppServ\www\statistical_bulletin\MyXls\202F6100'. There are several possible reasons: � The file name or path does not exist. � The file is being used by another program. � The workbook you are trying to save has the same name as a currently open workbook.' in C:\AppServ\www\statistical_bulletin\gen_length_action.php:520 Stack trace: #0 C:\AppServ\www\statistical_bulletin\gen_length_action.php(520): variant->SaveAs('C:\AppServ\www\...') #1 {main} thrown in C:\AppServ\www\statistical_bulletin\gen_length_action.php on line 520

นี่คือบรรทัด 520 ค่ะ
//*** Close & Quit ***//
$xlApp->Application->Quit();
$xlApp = null;
$xlBook = null;
$xlSheet1 = null;
ช่วยดูให้ด้วยนะคะขอบคุณค่ะ



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-02-19 14:50:15 By : Aea View : 1452 Reply : 5
 

 

No. 1



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

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

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

Quote:
There are several possible reasons: � The file name or path does not exist. � The file is being used by another program. � The workbook you are trying to save has the same name as a currently open workbook


คือ Path ไม่ถูกต้องครับ หรือลองแปลจากความหมายที่โปรแกรมแจ้งครับ






Date : 2010-02-19 15:50:47 By : webmaster
 


 

No. 2

Guest


ขอโทษนะคะที่เข้ามาดูช้าแต่ยังงัยคะไม่ค่อยเข้าใจค่ะ แล้วเราจะแก้ยังงัยพยายามแก้มาหลายวันแล้วก็ยังแก้ไม่ได้เลยค่ะ
Date : 2010-02-26 10:47:27 By : Aea
 

 

No. 3



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



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

แก้ไม่ได้เหมือนกัน TT
Date : 2011-03-07 09:54:36 By : emozerorise
 


 

No. 4



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



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


ของผมก็เป็นเหมือนกันครับ จะexport sql เป็น Excel แบบว่า ถ้า run ในเครื่องผมมันทำได้ไม่มี ERROR แต่ถ้าขึ้น SV. แล้วมันจะฟ้อง ERROR

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\AppServ\www\repair\rpexcel.php on line 45

ไม่เข้าใจเหมือนกัน ปัจจุบันก็ยังแก้ไม่ได้

https://www.thaicreate.com/php/forum/055349.html
Date : 2011-03-07 10:50:20 By : yutthanagorn
 


 

No. 5



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

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

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

Quote:
There are several possible reasons: • The file name or path does not exist. • The file is being used by another program. • The workbook you are trying to save has the same name as a currently open workbook.'


จัดไปตามนี้ครับ

ให้สร้างโฟเดอร์ตามนี้

・Windows 2008 Server x64
C:\Windows\SysWOW64\config\systemprofile\Desktop

・Windows 2008 Server x86
C:\Windows\System32\config\systemprofile\Desktop


อย่าลืมกำหนด Permission ให้โฟเดอร์ด้วย โดย User จะชื่อว่า IUSR หรือ IWAM เลือก Full Control

Go to : Unable to get the Open property of the Workbooks class (Excel 2003, 2007 Automation on Windows 2008 Server)
Date : 2012-11-28 14:28:26 By : mr.win
 

   

ค้นหาข้อมูล


   
 

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