如何在将数据导出到 .xls(EXCEL) 文件时显示带有 UTF-8 字符的数据

How to display data that is with UTF-8 charcter while exporting it to .xls(EXEL) file

<?php
$month=$_REQUEST["month"];
include 'include/myfunc.php';
$sql = "SELECT * FROM announcement WHERE month='".$month."'";
$result = mysqli_query($con,$sql);
$status="";
$html='<table><tr><td>Date</td><td>Announcement Detail</td><td>Tag</td><td>Amount</td><td>Status</td><td>File Name</td></tr>' ;

while( $row = mysqli_fetch_array($result) )
{
    if ($row['status']=="active") {
      $status = "निरकर्त";
    }else{
        $status = "लंबित";
    }

    $html.='<tr><td>'.$row['date'].' '.$row['month'].' '.$row['year'].'</td><td>'.$row['announcement_detail'].'</td><td>'.$row['tag'].'</td><td>'.$row['amount'].'</td><td>'.$status.'</td><td>'.$row['file'].'</td></tr>' ;
}
$html.= '</table>';
header('Content-Type:application/xls');
header('Content-Disposition:attachment;filename=report.xls');

echo $html;
?>

导出的时候是这样的निरकरà¥à¤¤ 我试过放入这个 header("content-type:application/xls;charset=UTF-8"); 仍然只得到垃圾值。任何人都可以帮助我到底应该做什么,以便无论天气如何都能正确显示数据用户以英语或印地语存储数据。

你没有做回声,而是像这样转换它,它会起作用。

print chr(255) . chr(254) . mb_convert_encoding($html, 'UTF-16LE', 'UTF-8');