问题
I am trying to create an excel sheet using PHPExcel, modify the data in the excel sheet then download the modified data that I created into a template format i have stored on my server. I noticed that once I downloaded the sheet with data in it, that the error checking/data validation was gone, most of it was drop downs for valid options.
I noticed from a previous question asked here that PHPExcel doesn't support array formulas, are the dropdowns/data validation options in Excel considered array formula?
If not then how can I load the data into a Template Excel Sheet already stored on my server using PHPExcel and maintain the dropdown boxes that are already saved into the Excel Sheet?
edit: To clarify I already have an excel sheet that I am using as a template document, I am simply loading the excel sheet, adding data to it, and then saving it and sending it for download to the user. The formatting and column headers show up fine after I open the newly downloaded sheet, but validation checks/ and drop down boxes are missing.
Here is my code
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$sheet = $objPHPExcel->getActiveSheet();
$sheet->getCell('A1')->setValue('new value');
$sheet->getCell('B1')->setValue('y');
$url = 'templateFile.xlsx';
$outputFileType = PHPExcel_IOFactory::identify($url);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $outputFileType);
$objWriter->save("temp/templateFileWithData.xlsx");
in the above example code, cell B1 would have a warning text and a drop down box on it asking users to select 'Y' or 'N' as the only valid options
Thanks for any help.
来源:https://stackoverflow.com/questions/31835155/phpexcel-write-from-template-file-and-maintain-drop-down-and-validation-checks