phpexcel指定列/表(sheet)被鎖定受保護(hù)加密相應(yīng)列受保護(hù)
一、受保護(hù)phpexcel的列
//實(shí)例化PHPExcel
$objPhpExcel= new \PHPExcel();
$objPhpExcel->getProperties();
//受保護(hù)的地址列
$objPhpExcel->getActiveSheet()->protectCells('A1:A7', 'password');
//解除指定列鎖定
$objPhpExcel->getActiveSheet()->getStyle('B1:B7')->getProtection()->setLocked(\PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);
//設(shè)置sheet鎖定屬性
$objPhpExcel->getActiveSheet()->getProtection()->setSheet(true);
注:以上方法如果用在指定列缺一不可缚甩!具體參數(shù)用途參見源代碼方法
二、phpexcel 受保護(hù)的表 sheet
//受保護(hù)的sheet
$objPhpExcel->getActiveSheet()->getProtection()->setSheet(true);
$objPhpExcel->getActiveSheet()->getProtection()->setSort(true);
$objPhpExcel->getActiveSheet()->getProtection()->setInsertRows(true);
$objPhpExcel->getActiveSheet()->getProtection()->setFormatCells(true);
$objPhpExcel->getActiveSheet()->getProtection()->setPassword('password');
以上參見:
https://stackoverflow.com/questions/17046207/phpexcel-lock-particular-cell
https://stackoverflow.com/questions/21639731/protect-the-excel-file-using-phpexcel