您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

phpexcel 为何无法生成xlsx文件

2024/4/9 11:11:16发布21次查看
header('content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');header('content-disposition: attachment;filename=fee_detail.xlsx');header('cache-control: max-age=0');$objwriter = phpexcel_iofactory::createwriter($objphpexcel, 'excel2007');$objwriter->save( 'php://output');
为何无法生成xlsx文件。
header('content-type: application/vnd.ms-excel');header('content-disposition: attachment;filename=fee_detail.xls');header('cache-control: max-age=0');$objwriter = phpexcel_iofactory::createwriter($objphpexcel, 'excel5');$objwriter->save('php://output');
可以生成xls文件。
回复讨论(解决方案) 无法生成xlsx,有错误信息吗?或者其他提示信息
经测试可以生成.xlsx ,你在$objwriter->save( 'php://output');后面加上exit();试试。
无法生成xlsx,有错误信息吗?或者其他提示信息
倒是没有出错的信息,我在文件头部增加了下面代码,可以生成xlsx文件
ini_set('display_errors', true);ini_set('display_startup_errors', true);

但是,遇到了一个问题,打不开文件,提示“文件格式或文件扩展名无效。请确定文件未损害.....”的信息。
我想代码应该没什么问题,这套代码可以生成xls文件,并可以打开xls文件。
经测试可以生成.xlsx ,你在$objwriter->save( 'php://output');后面加上exit();试试。
exit(); 一直都有
我在文件头部增加了下面代码,可以生成xlsx文件
ini_set('display_errors', true);ini_set('display_startup_errors', true);

但是,遇到了一个问题,打不开文件,提示“文件格式或文件扩展名无效。请确定文件未损害.....”的信息。
我想代码应该没什么问题,这套代码可以生成xls文件,并可以打开xls文件。 
原因找到了,ziparchive not found
配置了一下php.ini文件,问题解决了。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product