Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PHP在excel工作表中导入图像_Php_Excel_Import - Fatal编程技术网

使用PHP在excel工作表中导入图像

使用PHP在excel工作表中导入图像,php,excel,import,Php,Excel,Import,我正在尝试将图像插入excel工作表。下面是我用来将数据导出到excel的代码。当我尝试插入图像时,它不会插入图像,而是显示图像的代码。任何帮助都将不胜感激。提前谢谢 $file_ending=“xls” //浏览器的标题信息 标题(“内容类型:应用程序/xls”); 标题(“内容处置:附件;文件名=$filename.xls”); 标题(“杂注:无缓存”); 标题(“到期日:0”); /*******Excel格式设置的开始*******/ //定义分隔符(定义excel中的列和word中的选

我正在尝试将图像插入excel工作表。下面是我用来将数据导出到excel的代码。当我尝试插入图像时,它不会插入图像,而是显示图像的代码。任何帮助都将不胜感激。提前谢谢

$file_ending=“xls”

//浏览器的标题信息
标题(“内容类型:应用程序/xls”);
标题(“内容处置:附件;文件名=$filename.xls”);
标题(“杂注:无缓存”);
标题(“到期日:0”);
/*******Excel格式设置的开始*******/
//定义分隔符(定义excel中的列和word中的选项卡)
$sep=“\t”//制表符
//开始将列名打印为MySQL字段的名称
echo(“HR电机\t\t修理订单\t\t”);
?> 

制表符分隔值文件(您正在创建)不是Excel文件,只是Excel可以读取的文件。。。。但它只支持纯文本数据、无格式、无图像、无特殊Excel功能(如自动筛选),甚至不支持多个工作表

如果要在Excel文件中嵌入图像,则需要使用类似的库创建真正的OfficeOpenXML(.xlsx)或BIFF(.xls)格式的Excel文件

//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";
}