问题描述
- php excel加密的实现方法
-
使用PHPExcel怎么对导出的excel文档加密,在打开文件时需要输入密码的那种。在调用其加密方法时无法实现加密是为什么?
解决方案
三个层次,你用的是哪一种?
An example on setting document security:
$objPHPExcel->getSecurity()->setLockWindows(true);
$objPHPExcel->getSecurity()->setLockStructure(true);
$objPHPExcel->getSecurity()->setWorkbookPassword("PHPExcel");
An example on setting worksheet security:
$objPHPExcel->getActiveSheet()->getProtection()->setPassword('PHPExcel');
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true);
$objPHPExcel->getActiveSheet()->getProtection()->setSort(true);
$objPHPExcel->getActiveSheet()->getProtection()->setInsertRows(true);
$objPHPExcel->getActiveSheet()->getProtection()->setFormatCells(true);
An example on setting cell security:
$objPHPExcel->getActiveSheet()->getStyle('B1')->getProtection()->setLocked(
PHPExcel_Style_Protection::PROTECTION_UNPROTECTED
);
时间: 2025-01-30 11:03:30