使用PHPExcel导出excel后为什么有空格

时间:2017-09-05 15:13:01

标签: php excel

Excel file  为什么在导出excel之后它确实有空间。我想从1开始我已经清除了代码中的空格但没有任何反应。谢谢你的帮助

       <?php

function db_connect(){
 $servername = "localhost";
$username = "root";
$password = "";
$dbname = "sti_lms";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
 die("Connection failed: " . $conn->connect_error);
}
  return $conn;
      }
   ?>


 <?php
     /* File name : download_data_in_excel.php */
     include('dbcon.php'); // include database connection file
      $filename ="Books.xls";
       header('Content-type: application/ms-excel');
       header('Content-Disposition: attachment;filename='.$filename);
       $sql = "SELECT * FROM book";
       $conn = db_connect();
        if($conn){
          $result = $conn->query($sql);
              echo "Accession\tCall_Num\tAuthor\tBook_Title\tCatalog\tbookcopies\tpublishername\tcopyrightyear\n"; // prints header line with field names
if ($result->num_rows > 0) {// output data of each row
    while($row = $result->fetch_assoc()) {
        echo $row['acc_id']."\t".$row['callnum']."\t".$row['author']."\t". $row['book_title']."\t".$row['catalog']."\t".$row['book_copies']."\t".$row['publisher_name']."\t".$row['copyright_year']."\n";// prints each record with five fields in a row
            }
    } 
}

0 个答案:

没有答案