0

PHPでcsvファイルを生成しています。

Windows、Linuxでは問題なく動作します。しかし、Mac(Excel)では、めちゃくちゃになります。

すべてのデータが 1 つの列に表示され、コンマで区切られません。

Mac Excel のヘッダーを渡す方法があるかどうか疑問に思っていたので、デフォルトでセパレーター (コンマ) を識別します。

これが私が使用しているヘッダーです。

header("Content-type: application/vnd.ms-excel");
//header('Content-type: application/ms-excel');
//header("Content-Type: text/x-csv");
header("Content-disposition: csv" . date("Y-m-d") . ".xls");
header("Content-disposition: filename=".$filename.".xls");
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".strlen($csv_output));
header("Pragma: no-cache");
header("Expires: 0");

ありがとうございます

4

1 に答える 1

0

ご利用の際は、

header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".xls");
header("Content-disposition: filename=".$filename.".xls");

Excel ファイルを作成し、そこに CSV データを挿入しています。これをヘッダーとして使用してみることができます:

header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=file.csv");
于 2012-06-27T01:16:35.687 に答える