最近需要用yii2做一个导出excel带密码设置的功能,找了好多都没有达到目的,后来终于在git找到了一个,不过得php版本7.4以上
https://github.com/nick322/secure-spreadsheet
$objWriter = new Xlsx($objPHPExcel); $file_path = $title . '.xlsx'; $objWriter->save($file_path);//保存到本地 //设置excel文件打开密码 $xlsx_encrypt = new Encrypt(); $xlsx_encrypt->input($file_path) ->password($data['password']) ->output($file_path); header('Content-Type: application/octet-stream'); header('Content-Transfer-Encoding: Binary'); header("Content-disposition: attachment; filename=\"" . basename($file_path) . "\""); readfile($file_path); @unlink($file_path);
标签:xlsx,加密,excel,Content,header,file,path,php From: https://www.cnblogs.com/wutianfei/p/17565761.html