PHP导出带图像的excel
您好,我可以使用以下代码。导出功能工作正常,但没有图像导出功能。为什么?请帮帮我PHP导出带图像的excel,php,html,excel,codeigniter,Php,Html,Excel,Codeigniter,您好,我可以使用以下代码。导出功能工作正常,但没有图像导出功能。为什么?请帮帮我 <?php header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
<?php
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=member_list.xls");
?>
<table cellpadding="0" cellspacing="0" border="0" class="table table-bordered">
<thead>
<tr><th colspan="6"><h3>Member List</h3></th></tr>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Phone No</th>
<th>Date of Birth</th>
<th>Profile Image</th>
<th>Status</th>
<th>InsertDate</th>
</tr>
</thead>
<tbody>
<?php
if(!empty($memberlist))
{
foreach ($memberlist as $row){ ?>
<tr class="gradeX odd">
<td><strong><?php echo $row->id;?></strong></td>
<td><?php echo $row->display_name;?></td>
<td><?php echo $row->user_email;?></td>
<td><?php echo $row->phone;?></td>
<td><?php echo $row->dob;?></td>
<td><img src="<?php echo base_url().'uploads/images/member/'.$row->profile_image;?>" width="80" height="65" /><?php echo base_url().'uploads/images/member/'.$row->profile_image;?></td>
<?php
if($row->is_active == 1)
{
?>
<td>Active</td>
<?php
}
else
{
?>
<td>Inactive</td>
<?php
}
?>
<td><?php echo $row->insertdate;?></td>
</tr>
<?php } } ?>
</tbody>
</table>
?>
成员名单
身份证件
名称
电子邮件
电话号码
出生日期
轮廓图像
地位
插入日期
配置文件_图像;?>“width=“80”height=“65”/>
活跃的
不活跃的
?>
如何用一列导出我的excel?它们是显示图像。我们需要这个导出的文件,它有八列,如果在我的数据中找到,则第六列是显示图像。使用
FCPATH
而不是使用base\u url();
这就是我如何解决我的问题的。希望这对我有所帮助
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;
}
公共函数导出\u项\u到\u excel(){
$items=$this->transaction->view_all_items();
$output='';
$output.=”
名称
描述
量
重量(千克)
HS代码
序列号。
单位价值
通货
图画
";
foreach($items作为$item){
$output.=”
“$item->item\u name”
“$item->item\u说明。”
“$item->item\u数量”
.number\u格式($item->item\u重量,2)
“$item->item\u hs\u代码。”
“$item->item\u序列号。”
.number\u格式($item->item\u unit\u值,2)
“$item->item\u货币。”
项目图片。“'style='width:200px!重要;height:152px!重要;'>
";
}
$output.=”
";
标题(“内容类型:application/vnd.openxmlformats officedocument.spreadsheetml.sheet”);
标题(“内容处置:附件;文件名=items.xls”);
标头(“缓存控制:最大年龄=0”);
echo$输出;
}
这不是Excel文件,只是扩展名为.xl的html标记,您知道只有最后一个内容类型头(您尝试设置的4个内容类型头)才会发送到浏览器