单击导出到Excel时如何为CardNum设置文本值

时间:2016-12-05 04:58:27

标签: php mysql excel

if(isset($_POST["export_excel"]))  
 {    $sql = "SELECT tract1,CardNum,tract2,tract3 FROM exceldata a LEFT JOIN tblcardnum b on a.EXID =b.EXID ";  
      $result = mysqli_query($connect, $sql);  
      if(mysqli_num_rows($result) > 0)  
      {  
           $output .= '  
                <table class="table" bordered="1">  
                     <tr>  
                          <th>Id</th>  
                          <th>First Name</th>  
                          <th>Last Name</th>  
                     </tr>  
           ';  
           while($row = mysqli_fetch_array($result))  
           {  
                $output .= '  
                     <tr>  
                          <td>'.$row["tract1"].'</td>  
                          <td>'.$row["CardNum"].'</td>  
                          <td>'.$row["tract2"].'</td>  
                     </tr>  
                ';  
           }  
           $output .= '</table>';  
           header("Content-Type: application/xls");   
           header("Content-Disposition: attachment; filename=download.xls");  
           echo $output;  
      }  
 }  

0 个答案:

没有答案