如何修复Excel导出(PHP)中的"选项卡"?

use*_*700 -1 php excel encoding delimiter separator

我应用此解决方案来解决我将文件导出到.CSV和Excel的编码问题并且它成功运行,但现在又出现了另一个问题:

我在PHP中使用的标签("\ t")作为Excel文件的分隔符停止工作.在我解决上一个问题之前它正在工作.当我打开excel文件时,显示如下:

"ColumnAColumbBColumnC"(全部在一起).

如果导出它像csv ('Content-type: text/csv; charset=UTF-8')我有成功,但不是Excel(Content-type: application/vnd.ms-excel; charset=UTF-8).

对此有何解决方案?

注意:使用","作为分隔符对我来说不是一个好的解决方案,因为在某些字段中我的值为",".

小智 9

我在PHP中使用的标签("\ t")作为Excel文件的分隔符停止工作.

对,那是正确的.

尽管如此,仍然有一种简单的方法可以导出到Excel.

使用<td>和表<tr>,这确实很好.

一个例子:

<?php
    header("Content-Type: text/plain");
    echo "<table border='1'>";
    echo "<tr>";
    echo "<th>Name</th>";
    echo "<th>First Name</th>";
    echo "<th>Department</th>";
    echo "<th>Date</th>";
    echo "<th>Topic</th>";
    echo "<th>State</th>";
    echo "<th>E-mail</th>";
    echo "<th>Place</th>";
    echo "<th>Registration fee</th>";
    echo '</tr>';
    echo '</table>';
    header("Content-disposition: attachment; filename=example_export_to_excel.xls");
    }
?>
Run Code Online (Sandbox Code Playgroud)

这非常适合出口到e​​xcel.不需要库,为什么看起来很简单.