我有一个问题,我不能导出日语文本到excel(xls)。
我使用了以下代码:

header('Content-type: application/ms-excel;charset=UTF-8');
header('Content-Disposition: attachment; filename='.$filename);
header("Pragma: no-cache");
echo $contents;

但在excel文件中,文本变成了如下有趣的字符:
é™?定ç‰? ã?¨ã??ã?¯ã??ã?£ã?†ã?ªã?¢å??犬ã?®ã?Œæ??ã?

什么??195英镑??195英镑?是吗?是吗?是什么??195英镑??195英镑??195英镑??195’?是吗?
目前,我正在使用hostingmanager,我尝试在不同的服务器上使用相同的代码,没有问题。
有什么问题。因为php版本?是吗?
请帮帮我。

最佳答案

试试这个

<form action="itemexcel.php" method="post"
onsubmit='$("#datatodisplay").val( $("<div>").append( $("#ReportTable")
.eq(0).clone()).html() )'>

div或table我们想使用的div或table应该是id=“reporttable”
<table id="ReportTable" width="781" border="2"> Or <div id id="ReportTable">
<tr>
<td><input type="hidden" id="datatodisplay" name="datatodisplay"></td>
<td><input class="bg" type="submit" value="Export To Excel"></td>
</tr></table></div>

<input type="hidden" id="datatodisplay" name="datatodisplay">
<input class="bg" type="submit" value="Export To Excel">

itemExcel.php页面
<?php
header('Content-Type: application/force-download');
header('Content-disposition: attachment; filename=itemcode.xls');
// Fix for crappy IE bug in download.
header("Pragma: ");
header("Cache-Control: ");
echo $_REQUEST['datatodisplay'];
?>

关于php - PHP导出到Excel,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13639303/

10-11 01:40