如何设置单元格的文本长度,以便在导出文件后编辑该单元格时没有人可以超过该长度?
答案 0 :(得分:1)
您可以查看PHPExcel中data validation rules的TYPE_TEXTLENGTH
选项
$objValidation = $objPHPExcel->getActiveSheet()
->getCell('A1')
->getDataValidation();
$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_TEXTLENGTH );
$objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_STOP );
$objValidation->setAllowBlank(true);
$objValidation->setShowInputMessage(true);
$objValidation->setShowErrorMessage(true);
$objValidation->setErrorTitle('Input error');
$objValidation->setError('Text exceeds maximum length');
$objValidation->setPromptTitle('Allowed input');
$objValidation->setPrompt('Maximum text length is 6 characters.');
$objValidation->setFormula1(6);