//phpexcel 在zentao中案例$objExcel=$this->app->loadClass('PHPExcel');// 创建文件格式写入对象实例, uncomment$objWriter=newPHPExcel_Writer_Excel5($objExcel);// 用于其他版本格式$objExcel->setActiveSheetIndex(0);$objActSheet=$objExcel->getActiveSheet();//设置A1单元格的选择列表$objValidation=$objActSheet->getCell("A1")->getDataValidation();$objValidation->setType(PHPExcel_Cell_DataValidation::TYPE_LIST)->setErrorStyle(PHPExcel_Cell_DataValidation::STYLE_INFORMATION)->setAllowBlank(false)->setShowInputMessage(true)->setShowErrorMessage(true)->setShowDropDown(true)->setErrorTitle('输入的值有误')->setError('您输入的值不在下拉框列表内.')->setPromptTitle('设备类型')//把sheet名为mySheet2的A1,A2,A3作为选项->setFormula1('mySheet2!$A$1:$A$3');//设置为具体的内容// -> setFormula1('"select1,select2,select3"');//设置为变量内容,例如:$myStr = 'select1,select2,select3'// -> setFormula1('"'.$myStr.'"');//设置单元格颜色$objStyleA1=$objActSheet->getStyle('A1');$objStyleA1->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);//设置CELL填充颜色$objFillA1=$objStyleA1->getFill();$objFillA1->setFillType(PHPExcel_Style_Fill::FILL_SOLID);$objFillA1->getStartColor()->setARGB('FFcdcdff');//设置当前活动sheet的名称$objActSheet->setTitle('mySheet1');//新增一个sheet,命名为mySheet2$objExcel->createSheet();// Add some data to the second sheet, resembling some different data types$objExcel->setActiveSheetIndex(1);$objExcel->getActiveSheet()->setCellValue('A1','item1');$objExcel->getActiveSheet()->setCellValue('A2','item2');$objExcel->getActiveSheet()->setCellValue('A3','item3');$objExcel->getActiveSheet()->setTitle('mySheet2');$objExcel->setActiveSheetIndex(0);$outputFileName="output.xls";header("Content-Type: application/force-download");header("Content-Type: application/octet-stream");header("Content-Type: application/download");header('Content-Disposition:inline;filename="'.$outputFileName.'"');header("Content-Transfer-Encoding: binary");header("Last-Modified: ". gmdate("D, d M Y H:i:s") ." GMT");header("Cache-Control: must-revalidate, post-check=0, pre-check=0");header("Pragma: no-cache");$objWriter->save('php://output');
php excel 设置下拉菜单,phpexcel setFormula下拉选择列表 序列
最新推荐文章于 2023-08-01 12:16:35 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)