首页 > 解决方案 > 数据验证不适用于 PhpSpreadsheet

问题描述

当我在某些软件中打开表格时,它说表格有误,需要重置,这仅在我添加列表验证时发生

$sheet = $spreadsheet->getActiveSheet();
$objValidation = $spreadsheet->getActiveSheet()
        ->getCell('B2')
        ->getDataValidation();
$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_LIST );
$objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_INFORMATION );
$objValidation->setFormula1('A,B,C');

$writer = new Xlsx($spreadsheet);
$name = str_replace('.','',str_replace(' ', '',microtime().date('Y h'))).'.xlsx';
$path = 'arquivos/modelo_planilha/'.$name;
$writer->save($path);```

标签: phpexcelphpspreadsheet

解决方案


推荐阅读