php导出excel,使用office打开乱码解决

header("Content-type:application/vnd.ms-excel;");  
header("Content-Disposition:attachment;filename=".$fileName.".xls"); 
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); 
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate');

array_unshift($list, $header);
foreach ($list as $key1 => $row) {
     foreach ($row as $key2 => $cell) {
          $list[$key1][$key2] = sprintf('%s', $cell);
     }
}

$table = '';
 foreach ($list as $key1 => $row) {
      $table .= sprintf('%s', implode('', $row));
}
echo ''.$table.'
'; exit;

你可能感兴趣的:(php导出excel,使用office打开乱码解决)