使用存储在db

时间:2017-07-16 15:27:31

标签: php excel export-to-excel

尝试将产品日期导出为Excel。产品说明存储在带有<ul><li>标记的数据库中。

以下是导出为ex​​cel的代码

<?php
//fetch query 

    $header .= "Product Code \t";
    $header .= "Product Name \t";
    $header .= "Description \t";
    $header .= "Purchase Cost \t";
    $header .= "Selling Cost \t";
    $header .= "Type \t";
while($rowtt = mysqli_fetch_array($queryrr))
    {
         $line = '';
         $code = $rowtt['code'];
         $name = $rowtt['Pname'];
         $descr = strip_tags($rowtt['description']);
         $pcost= $rowtt['pcost']; 
         $scost = $rowtt['scost'];
         $type= $rowtt['type'];

        $line .= $code."\t";
        $line .= $name."\t";
        $line .= $descr."\t";
        $line .= $pcost."\t";
        $line .= $scost."\t";
        $line .= $type."\t";
$data .= trim( $line ) . "\n";
$data = str_replace( "\r" , "" , $data );
  }

if ( $data == "" )
{
    $data = "\nNo Record(s) Found!\n";                        
}  

header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=Products.xls");
header("Pragma: no-cache");
header("Expires: 0");

print "$header\n ".$data."";

导出到excel,但在描述中它有像这样的li标签 <ul> <li>Lorel ipsum 123 </li> <li>Lorel ipsum 123 </li> <li>Lorel ipsum 123 </li> <li>Lorel ipsum 123 </li> </ul>

但它显示如下

Product Code | Product Name | Description | Purchase Cost | Selling Cost |Type PT001 | ABCD | Lorel ipsum 123
Lorel ipsum 123 Lorel ipsum 123 Lorel ipsum 123
1500 | 1800 | Type1

0 个答案:

没有答案