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 แล้วมี textbox และ button ติดมาด้วยครับ



 

มีปัญหาการ export ข้อมูลเป็น excel แล้วมี textbox และ button ติดมาด้วยครับ

 



Topic : 086708



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



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




Code (PHP)
<?
header("Content-Type: application/x-msexcel"); 
header("content-disposition: attachment;filename=Data_bill.xls");
echo "<meta http-equiv='Content-Type' content='text/html; charset='utf-8'>";
?> 
<html>
<head>
<meta charset="utf-8">
<title> SMART EYES::The e-Commerce </title>
<meta name="description" content="SMAET EYES">
<meta name="author" content="SMAET EYES">
<link rel="stylesheet" href="sellin.css" type="text/css" />

</head>

<body>
<?

$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database"); 
mysql_query("SET NAMES UTF8",$objConnect); 

$objDB = mysql_select_db("sell"); 


$fullmonth=array("มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม", "พฤศจิกายน","ธันวาคม");

$DL=array("Partner","Modern_Trade","Traditional_Trade",);
?>


	 
<form id="form2"  name="form1" method="post" action="report_sellin1.php">
      
          <label>AS Name</label>
            <input type="text" name="person" value="<?=$person; ?>" />   
            <label>DealerType</label>
            <select name="type" id="type" class="id">
              <option value="">ประเภท/ทั้งหมด</option>
              <?
			   for($d=0;$d<count($DL);$d++)
			   {
               if($type == $DL[$d])

							{

								$sel = "selected";

							}

							else

							{

								$sel = "";

							}
			   
							?>
              <option value="<?=$DL[$d]; ?>" <?=$sel;?> > <?= $DL[$d]; ?></option>
              <? } ?>
  </select>
   <label>Month</label>
   <select name="month" id="month">
   <? $mo=date('m');
       $ye=date('Y');
   ?>
                 <option value="">เดือน/ทั้งหมด</option>
                 <? for($i=0;$i<count($fullmonth);$i++) { 
		  if($_POST["OK"]	)
		  {
		 	 if($month == $i+1 )

							{

								$sel = "selected";

							}

							else

							{

								$sel = "";

							}
		  }
		  elseif ($mo == $i+1 )
		 

							{

								$sel = "selected";

							}

							else

							{

								$sel = "";

							}
		  
		  ?>
                 <option value="<?=$i+1; ?>"<?=$sel; ?>><?=$fullmonth[$i]; ?></option>
                 <? } ?>
               </select>
          <label>Year</label>
               <select name="year" id="year">
                <option value="">ปี/ทั้งหมด</option>
		  <? $j=2555;
		   for($i=2012;$i>2010;$i--) {
			     if($_POST["OK"]) {
			     if($year == $i)

							{

								$sel = "selected";

							}

							else

							{

								$sel = "";

							}
		  }  elseif($ye == $i)
			  

							{

								$sel = "selected";

							}

							else

							{

								$sel = "";

							}
			  
			    ?>
                    <option value="<?=$i ; ?>"<?php echo $sel; ?> > <?=$i; ?></option>
                     <? $j-- ;} ?>
                   </select>
          
      
               
        
       
                   <label></label><input type="submit" name="OK" id="OK" value="ตกลง"/>
               
               
        </form> 
         </div> </br></br>
   <?
    
   $date="1";
   $date1="31";
   if($_POST["OK"])
   {
   $dateforadd="$year-$month-$date";
	$dateend="$year-$month-$date1";
   
    
	if($person=="" and $month=="" and $type=="" and $year=="")
	{
		$strSQL = " SELECT * FROM sell_in ";
	}
	
	 elseif($person=="" and $month=="" and $year=="" and $type )
	 {
		 $strSQL = "SELECT * FROM sell_in where  DealerType LIKE '%$type%' "; 
	 }
	  elseif($person=="" and $month=="" and $year and $type )
	 {
		 $dateforadd="$year-01-01";
	$dateend="$year-12-31";
		 
		 $strSQL = "SELECT * FROM sell_in where  DealerType LIKE '%$type%' "; 
		 $strSQL .= " AND InvoiceDate BETWEEN '$dateforadd' and '$dateend'";   
	 }
	 elseif($person=="" and $month=="" and $type=="" and $year )
	 {
		  $dateforadd="$year-01-01";
	$dateend="$year-12-31";
	$strSQL = " SELECT * FROM sell_in WHERE InvoiceDate BETWEEN '$dateforadd' and '$dateend'";
	
	 }
	elseif ($person=="" and $type=="")
	{
  
	  $strSQL = " SELECT * FROM sell_in WHERE InvoiceDate BETWEEN '$dateforadd' and '$dateend'";
	}
	elseif($person=="" and $month and $type )
	  {
		    $strSQL = "SELECT * FROM sell_in where  DealerType LIKE '%$type%' "; 
			$strSQL .= " AND InvoiceDate BETWEEN '$dateforadd' and '$dateend'";   
	  }
	elseif($person and $month=="" and $type=="" )
	  {
		    $strSQL = "SELECT * FROM sell_in where  (A_S LIKE '%".$_POST["person"]."%') "; 
			
	  }
	
      elseif($person and $month and $type=="" )
	  {
		    $strSQL = "SELECT * FROM sell_in where  (A_S LIKE '%".$_POST["person"]."%') "; 
			$strSQL .= " AND InvoiceDate BETWEEN '$dateforadd' and '$dateend'";   
	  }
	  elseif($person and $type and $month )
	  {
		  $strSQL = " SELECT * FROM sell_in WHERE InvoiceDate BETWEEN '$dateforadd' and '$dateend'";
	    $strSQL .= " AND A_S LIKE '%".$_POST["person"]."%' "; 
		$strSQL .= " AND DealerType LIKE '%$type%' "; 
	  }
	  elseif($person and $month=="" and $type )
	  {
		    $strSQL = "SELECT * FROM sell_in where  (A_S LIKE '%".$_POST["person"]."%') "; 
			$strSQL .= " AND DealerType LIKE '%$type%' ";
	  }
	  }
	 
	  else{
		$dateforadd="$ye-$mo-$date";
	$dateend="$ye-$mo-$date1";
	$strSQL = " SELECT * FROM sell_in WHERE InvoiceDate BETWEEN '$dateforadd' and '$dateend'";
	
	}
$objQuery1 = mysql_query($strSQL)or die ("Error Query [".$strSQL."]"); 
 
?>

<table id="tableproduct" >
  <tr class="header"> 
  
<th width="168"  height="31"> DealerCode</th> 
<th width="168"><div align="left"> BillName</div></th>
<th width="168"> <div align="left">ShopName</div></th>  
<th width="168" > <div align="left">Dealertype</div></th> 
<th width="168" > <div align="left">Amphur</div></th>
<th width="168" > <div align="left" >Province</div></th>  
<th width="120" > <div align="left">Zone</div></th>  
<th width="168" > <div align="left">SubArea</div></th> 
<th width="168" > <div align="left">Area</div></th>  
<th width="168" > <div align="left">AS</div></th>  
<th width="168" > <div align="left">AM</div></th>  
<th width="168" > <div align="left">RH</div></th>  
<th width="168" > <div align="center">InvoiceDate</div></th>  
<th width="168" > <div align="left">Material</div></th>  
<th width="168" > <div align="left">Description</div></th>  
<th width="168" > <div align="left">ProductType</div></th>  
<th width="168" > <div align="right">QTY</div></th>  
<th width="168" > <div align="right">NetValue</div></th>  
<th width="168" > <div align="right">TaxAmount</div></th>  
<th width="168" > <div align="right">Total</div></th>  
<th width="181" > <div align="center">PricePerProduct</div></th>  
<th width="168" > <div align="center">SO</div></th>  
<th width="168" > <div align="center">BillDoc</div></th>  
<th width="168" > <div align="center">Selling_Price</div></th>  
<th width="168" > <div align="center">MatQty</div></th>  
<th width="183" > <div align="center">ServiceQty</div></th>  
<th width="164" > <div align="right">ShipToCode</div></th>  


  </tr>
<?
while($objResult= mysql_fetch_array($objQuery1)) { 

$InvoiceDate=date('d-m-Y',strtotime($objResult["InvoiceDate"])) ;

	if($objResult["PricePerProduct"]==0) {
			$PricePerProduct="-";
		}
?>
	<tr bgcolor="<?=$bg; ?>"> 

<td><center><?=$objResult["DealerCode"]; ?></center></td> 
<td><?=$objResult["BillName"]; ?></td> 
<td><?=$objResult["ShopName"]; ?> </td> 
 <td><?=$objResult["DealerType"]; ?></td> 
 <td><?=$objResult["Amphur"]; ?> </td>
 <td><?=$objResult["Province"]; ?> </td>
 <td><?=$objResult["Zone"]; ?> </td>
 <td><?=$objResult["SubArea"]; ?></td>
 <td><?=$objResult["Area"]; ?></td>
 <td><?=$objResult["A_S"]; ?> </td>
 <td><?=$objResult["AM"]; ?> </td>
 <td><?=$objResult["RH"]; ?> </td>
 <td><center><?=$InvoiceDate; ?></center> </td>
 <td><?=$objResult["Material"]; ?> </td>
 <td><?=$objResult["Description"]; ?> </td>
 <td><?=$objResult["ProductType"]; ?> </td>
 <td><div align="right"><?=$objResult["Qty"];?></div> </td>
 <td><div align="right"><?=$objResult["NetValue"]; ?></div> </td>
 <td><div align="right"><?=$objResult["TaxAmount"]; ?></div> </td>
  <td><div align="right"><?=$objResult["Total"]; ?></div> </td>
  <td><center><?=$PricePerProduct; ?></center> </td>
  <td><center><?=$objResult["So"]; ?></center> </td>
   <td><center><?=$objResult["BillDoc"]; ?></center> </td>
  <td><center><?=$objResult["Selling_Price"]; ?></center> </td>
<td><center><?=$objResult["MatQty"]; ?></center> </td>
<td><center><?=$objResult["ServiceQty"]; ?></center> </td>
<td><div align="right"><?=$objResult["ShipToCode"]; ?></div> </td>
</tr> 
<?

}
?>
</table>




</body>
</html>




จากโค้ดครับผม เวลา export ออกมาเป็น excel แล้ว มันจะมี พวก textbox dropdownlist button ติดมาที่ excel ด้วยครับ จะมีวิธี ที่ไม่ให้ มันติดมารึป่าวครับ

อีก อย่างครับ มันไม่มีตารางเวลาอยู่ใน excel ต้องเพิ่มอะไรเข้าไปมั้งครับผม



Tag : PHP, MySQL







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-11-14 14:15:57 By : theyounggun View : 1147 Reply : 2
 

 

No. 1



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

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

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

คิดว่าน่าจะเป็นข้อจำกับของวิธีแบบนี้ครับ ที่ไม่สามารถแทรกพวกรุปภาพหรืออื่น ๆ ได้นอกจาก Font หรือมีวิธีอันนี้ก็ไม่แน่ใจครับ

แต่ถ้าอยากได้ Excel file ที่มีความซับซ้อน แนะนำให้ลองใช้ PHPExcel ดูครับ

มันทำอะไรได้หลายอย่างครับ ลองดูใน Demo / Example ก็ได้ครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-11-15 09:04:39 By : mr.win
 


 

No. 2



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



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


ครับผม ผมคิดว่าจะใช้วิธี ลิงก์ ไปเปิดหน้าใหม่แล้วค่อย save ครับผม ขอบคุณมากๆครับสำหรับคำแนะนำดีๆ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-11-15 09:54:49 By : theyounggun
 

   

ค้นหาข้อมูล


   
 

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