问题描述
我的网站具有下载excel表格的功能.我将PHPExcel库与Codeigniter一起使用来创建.xlsx工作表.它几乎可以在所有地方正常工作,但可以在iPad/iPhone Safari中使用.屏幕上出现以下错误. Safari错误屏幕截图
My website has a functionality of downloading excel sheet. I'm using PHPExcel library with Codeigniter to create the .xlsx sheet. It works fine almost everywhere but in iPad/ iPhone Safari. The following error covers the screen. Safari Error Screenshot
我下载文件的代码如下:
My code to download the file is following:
$ filename ='attendance_list.xlsx';
$filename='attendance_list.xlsx';
header('Content-Type:application/vnd.ms-excel');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition:附件; filename ='.$ filename.'"');
header('Content-Disposition: attachment;filename="'.$filename.'"');
header('Cache-Control:max-age = 0');
header('Cache-Control: max-age=0');
$ objWriter = PHPExcel_IOFactory :: createWriter($ this-> excel,'Excel2007');
$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel2007');
$ objWriter-> save('php://output');
$objWriter->save('php://output');
我正在通过jquery和AJAX用此代码调用php函数.请给我答案.
And i am calling the php function with this code via jquery and AJAX. Please provide me with the answers.
推荐答案
而不是:
header('Content-Type:application/vnd.ms-excel');
header('Content-Type: application/vnd.ms-excel');
使用
header('Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
这篇关于在iPad和iPhone Safari上为ERROR_MESSAGE_MAIN ERROR_MESSAGE_REASON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!