美文网首页
php导出excel,使用office打开乱码解决

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

作者: 简单的破小孩儿 | 来源:发表于2018-07-18 16:45 被阅读0次
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('<td>%s</td>', $cell);
     }
}

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

相关文章

网友评论

      本文标题:php导出excel,使用office打开乱码解决

      本文链接:https://www.haomeiwen.com/subject/umxapftx.html