如何从php中的单元格html代码中的excel文件中读取数据

时间:2015-08-13 21:04:49

标签: php html import-from-excel

ı有excell的产品清单

excell看起来像这样

 a colum is pruduct code
 b colum is pruduct name
 c colum is description but this cell inside to html code 

看起来像这样

<p style="color: rgb(51, 51, 51); font-family: sans-serif, Arial, Verdana, 'Trebuchet MS'; font-size: 13px; line-height: 20.7999992370605px;"><span style="color: rgb(0, 0, 0); line-height: 1.6;">ürün açıklamaları </span></p>

<p style="color: rgb(51, 51, 51); font-family: sans-serif, Arial, Verdana, 'Trebuchet MS'; font-size: 13px; line-height: 20.7999992370605px;"></p>
<p style="color: rgb(51, 51, 51); font-family: sans-serif, Arial, Verdana, 'Trebuchet MS'; font-size: 13px; line-height: 20.7999992370605px;"></p>
<div>
<p style="&quot;text-align:"></p>
</div>
<div>
<p></p>
</div>
<div>
<p></p>
</div>

ı发现并使用该PHP代码

 $exurunacıklama=$data->sheets[0]['cells'][$i][3];
 echo " hücre: ".$exurunacıklama."</br>";

但是这段代码没有给我html代码

只给我

ürün açıklamaları 

如何获取excell cels的html代码

感谢您的帮助

2 个答案:

答案 0 :(得分:0)

你应该看一下:https://phpexcel.codeplex.com/,可能有用

答案 1 :(得分:0)

一种简单易用的方法是在.csv文件中转换excel文件并填充数组...使用&#34;另存为&#34;在excel上命令,选择.csv和&#34; *&#34;作为字段分隔符...在PHP代码下面

// Open the file .csv
 $data= array();
$filename="data.csv";
$fp = @fopen($filename, 'r'); 

// Add each line to $data array
if ($fp) {
   $records = explode("\n", fread($fp, filesize($filename)));
}

$num_rec=count($records);

for($i=0;$i<$num_rec;$i++){
$record=explode("*",$records[$i]);
$data[]=$record;
}
print_r($data);