2014-04-01 26 views

回答

1

您必須使用followig庫之一來執行此操作。

URLS:

https://github.com/PHPOffice/PHPExcel 

https://phpexcel.codeplex.com/ 

https://code.google.com/p/php-excel/ 
+0

從技術上講,其中兩個是相同的庫:codeplex上的PHPExcel與PHPOcel中的github上的PHPOcel回購相同 –

+0

其實,我試圖給出關於PHPExcel庫的更多細節。所以人們可以在第一個URL中找到代碼。第二個URL是關於該庫的完整詳細信息 – Ananth

+0

https://github.com/PHPOffice/PHPExcel/wiki/User%20Documentation是github上的有用參考 –

1

你在找什麼是PHPExcel

這裏有一些examples

0

這就是我解決這個問題的方法。希望這可以幫助!

public function export_items_to_excel(){ 
 
    \t \t $items = $this->transaction->view_all_items(); 
 

 
    \t \t $output = ''; 
 

 
    \t \t $output .= "<table class='table' border='1'> 
 
\t \t \t \t \t \t <thead> 
 
\t \t \t     <th style='background-color:#c7c7c7;'>NAME</th> 
 
\t \t \t     <th style='background-color:#c7c7c7;'>DESCRIPTION</th>  
 
\t \t \t     <th style='background-color:#c7c7c7;'>QUANTITY</th> 
 
\t \t \t     <th style='background-color:#c7c7c7;'>WEIGHT (KG)</th> 
 
\t \t \t     <th style='background-color:#c7c7c7;'>HS CODE</th> 
 
\t \t \t     <th style='background-color:#c7c7c7;'>SERIAL NO.</th> 
 
\t \t \t     <th style='background-color:#c7c7c7;'>UNIT VALUE</th> 
 
\t \t \t     <th style='background-color:#c7c7c7;'>CURRENCY</th> 
 
\t \t \t     <th style='width:220px !important;background-color:#c7c7c7;'>PICTURE</th> 
 
\t \t    \t </thead> 
 
\t \t \t \t   <tbody> 
 
    \t \t \t \t \t "; 
 
\t \t foreach($items as $item){ 
 
\t \t $output .= " 
 
\t \t \t \t <tr> 
 
\t \t \t \t \t <td style='text-align:center;'>".$item->item_name."</td> 
 
\t \t \t \t \t <td style='text-align:center;'>".$item->item_description."</td> 
 
\t \t \t \t \t <td style='text-align:center;'>".$item->item_quantity."</td> 
 
\t \t \t \t \t <td style='text-align:center;'>".number_format($item->item_weight, 2)."</td> 
 
\t \t \t \t \t <td style='text-align:center;'>".$item->item_hs_code."</td> 
 
\t \t \t \t \t <td style='text-align:center;'>".$item->item_serial_number."</td> 
 
\t \t \t \t \t <td style='text-align:center;'>".number_format($item->item_unit_value, 2)."</td> 
 
\t \t \t \t \t <td style='text-align:center;'>".$item->item_currency."</td> 
 
\t \t \t \t \t <td style='text-align:center;width:220px !important;height:220px !important;'><img src='".base_url()."assets/uploads/".$item->item_picture."' style='width:200px !important;height:152px !important;'> </td> 
 
\t \t \t \t </tr> 
 
\t \t \t \t \t "; 
 
     \t } 
 
     \t $output .= "</tbody> 
 
     \t \t \t </table> 
 
     \t \t "; 
 
     \t header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); 
 
     \t header("Content-Disposition: attachment; filename=items.xls"); 
 
     \t header("Cache-Control: max-age=0"); 
 
     \t echo $output; 
 
    \t }