Home >Backend Development >PHP Tutorial > 怎么让phpexcel生成的excel文件打开时需要密码

怎么让phpexcel生成的excel文件打开时需要密码

WBOY
WBOYOriginal
2016-06-13 13:24:181624browse

如何让phpexcel生成的excel文件打开时需要密码
如题。
我搜索网上的一些解决方案说可以这样:

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
$objPHPExcel=new PHPExcel();
$objPHPExcel->getSecurity()->setLockWindows(true);
$objPHPExcel->getSecurity()->setLockStructure(true);
$objPHPExcel->getSecurity()->setWorkbookPassword("abc");
$objWriter=new PHPExcel_Writer_Excel5($objPHPExcel);
$objWriter->setTempDir(".");
$objWriter->save("abc.xls");



但是生成的文件还是可以直接打开,不需要密码的。请问谁知道该怎么实现?

------解决方案--------------------
dddddd有道理!
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn