簡體   English   中英

如何導出Excel中的數據,包括php中的圖像

[英]How to Export data in Excel including images in php

我正在excel表中導出數據庫(MySQL)中的數據。 我還想使用PHP導出Excel中的圖像。如果有任何演示鏈接可用,請在此處分享

您必須使用其中一個followig庫來執行此操作。

URLS:

https://github.com/PHPOffice/PHPExcel

https://phpexcel.codeplex.com/

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

您正在尋找的是PHPExcel

這是一些例子

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

 public function export_items_to_excel(){ $items = $this->transaction->view_all_items(); $output = ''; $output .= "<table class='table' border='1'> <thead> <th style='background-color:#c7c7c7;'>NAME</th> <th style='background-color:#c7c7c7;'>DESCRIPTION</th> <th style='background-color:#c7c7c7;'>QUANTITY</th> <th style='background-color:#c7c7c7;'>WEIGHT (KG)</th> <th style='background-color:#c7c7c7;'>HS CODE</th> <th style='background-color:#c7c7c7;'>SERIAL NO.</th> <th style='background-color:#c7c7c7;'>UNIT VALUE</th> <th style='background-color:#c7c7c7;'>CURRENCY</th> <th style='width:220px !important;background-color:#c7c7c7;'>PICTURE</th> </thead> <tbody> "; foreach($items as $item){ $output .= " <tr> <td style='text-align:center;'>".$item->item_name."</td> <td style='text-align:center;'>".$item->item_description."</td> <td style='text-align:center;'>".$item->item_quantity."</td> <td style='text-align:center;'>".number_format($item->item_weight, 2)."</td> <td style='text-align:center;'>".$item->item_hs_code."</td> <td style='text-align:center;'>".$item->item_serial_number."</td> <td style='text-align:center;'>".number_format($item->item_unit_value, 2)."</td> <td style='text-align:center;'>".$item->item_currency."</td> <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> </tr> "; } $output .= "</tbody> </table> "; header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); header("Content-Disposition: attachment; filename=items.xls"); header("Cache-Control: max-age=0"); echo $output; } 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM