【发布时间】:2014-05-27 08:55:38
【问题描述】:
我正在尝试将图像插入到 Excel 工作表中。下面是我用来将数据导出到excel的代码。当我尝试插入图像时,它不会插入图像,而是仅显示图像代码。任何帮助,将不胜感激。提前致谢
$file_ending = "xls";
//header info for browser
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=$filename.xls");
header("Pragma: no-cache");
header("Expires: 0");
/*******Start of Formatting for Excel*******/
//define separator (defines columns in excel & tabs in word)
$sep = "\t"; //tabbed character
//start of printing column names as names of MySQL fields
echo("HR Motors\t\tREPAIR ORDER\t\t\t");
?>
<img src="../images/Bosch-Logo.png" />
<?php
echo("\n");
echo("Repair Order\t".$result1['order_no']."\tLabour Bill No\t".$result1['labour_bill_no']."\t\t\n");
echo("Name\t".$custdata['customer_name']."\tRegd No\t".$custdata['registration_no']."\tDate\t".date('d/m/Y')."\n");
echo("Make\t".$custdata['make']."\tModel\t".$custdata['model']."\tContact No\t".$custdata['contact_no']."\n");
echo("Fuel Type\t".$custdata['fuel_type']."\tEmail\t".$custdata['email_id']."\tEngine No\t".$custdata['engine_no']."\n");
echo("Chassis No\t".$custdata['chassis_no']."\tODO Meter\t".$result1['odo_meter']."\t\t\n\n");
echo("Labour Bill\n");
echo("Service\tDescription\tPrice");
print("\n");
//end of printing column names
//start while loop to get data
while($row = mysql_fetch_row($result))
{
$schema_insert = "";
for($j=0; $j<mysql_num_fields($result);$j++)
{
if($j==0){
if(!isset($row[$j]))
$schema_insert .= "NULL".$sep;
elseif ($row[$j] != "")
$schema_insert .= "$row[$j]".$sep;
else
$schema_insert .= "".$sep;
}else{
if(!isset($row[$j]))
$schema_insert .= "NULL".$sep;
elseif ($row[$j] != "")
$schema_insert .= "$row[$j]".$sep;
else
$schema_insert .= "".$sep;
}
}
$schema_insert = str_replace($sep."$", "", $schema_insert);
$schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert);
$schema_insert .= "\t";
print(trim($schema_insert));
print "\n";
}
【问题讨论】: