[英]How to Export data in Excel including images in php
i am exporting data from database (MySQL) in excel sheet. 我正在excel表中导出数据库(MySQL)中的数据。 i also want to export images in Excel using PHP.if any demo link is available, please share it here
我还想使用PHP导出Excel中的图像。如果有任何演示链接可用,请在此处分享
You have to use one of the followig library to do that. 您必须使用其中一个followig库来执行此操作。
URLS: URLS:
https://github.com/PHPOffice/PHPExcel
https://phpexcel.codeplex.com/
https://code.google.com/p/php-excel/
This is how I solved mine. 这就是我解决了我的问题。 Hope this helps!
希望这可以帮助!
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.