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

PHP excel导出乱码问题解决办法

2024/3/25 9:39:50发布38次查看
在2003及其它版本导出一切正常,但是在excel2007上导出乱码,处理方法:
string format for excel to export. valid value are 'excel5','excel2007','excel2003xml','00calc','gnumeric'.
找到createwrite方法,将第二个参数修改成需要生成的excel版本型号:
如:
$objwriter = phpexcel_iofactory::createwriter($objphpexcel, 'excel5');$objwriter->save('php://output');
当然了,如果用的是框架,如yii2框架,那么建议封装成一个小物件,推荐:
https://github.com/moonlandsoft/yii2-phpexcel
小物件使用方法:
use moonland\phpexcel\excel;public function actiont(){ $result = test::find()->all(); excel::widget([ 'models' => $result, 'mode' => 'export', 'format' => 'excel5', 'columns' => ['itemid', 'username', 'company'], 'headers' => ['itemid' => 'id号', 'username' => '用户名', 'company' => '公司'], ]);}
该用户其它信息

VIP推荐

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