开发者

Can I create Excel file with password protection

开发者 https://www.devze.com 2023-04-01 14:52 出处:网络
Can i create save password protected Excel file with php? I find the a lot of class and method and did\'t found 开发者_如何学运维

Can i create save password protected Excel file with php? I find the a lot of class and method and did't found 开发者_如何学运维 thank you


You can use (the excellent) PHPExcel for this. To lock a whole workbook:

$reader = new PHPExcel_Reader_Excel2007;
$workbook =  $reader->load("document.xlsx");
$workbook->getSecurity()->setWorkbookPassword("your password");

Or to lock a sheet:

$reader = new PHPExcel_Reader_Excel2007;
$workbook =  $reader->load("document.xlsx");
$workbook->-getActiveSheet()->getSecurity()->setWorkbookPassword("your password");


Short answer: No you cannot create a password protected file from PHPExcel until now.

https://github.com/PHPOffice/PHPExcel/issues/442#issuecomment-57867961

0

精彩评论

暂无评论...
验证码 换一张
取 消