Closed sysmaya closed 2 years ago
I am not able to duplicate your problem with the code above and the current version of PhpSpreadsheet - the output file is as expected, with A1 using data validation, and B1:B3 not, with the rest of the sheet locked. Do you still see the problem with the current version?
I just put the validation rule for A1. The error is that adjacent cells show the same validation rule. See attached image
$spreadsheet = new Spreadsheet();
$sheet1 = $spreadsheet->getActiveSheet();
$sheet1->setCellValue("B1", 'xx');
$sheet1->setCellValue("B2", 'yy');
$validation = $sheet1->getCell('A1')->getDataValidation();
$validation->setType( \PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST );
$validation->setErrorStyle( \PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_INFORMATION );
$validation->setAllowBlank(false);
$validation->setShowInputMessage(true);
$validation->setShowErrorMessage(true);
$validation->setShowDropDown(true);
$validation->setErrorTitle('Input error');
$validation->setError('Value is not in list.');
$validation->setPromptTitle('Pick from list');
$validation->setPrompt('Please pick a value from the drop-down list.');
$validation->setFormula1('"Item A,Item B,Item C"');
$sheet1->getCell("A1")->setDataValidation($validation);
$writer = new Xls($spreadsheet);
$writer->save('helloworld7.xls');
Why is the validation rule displayed in column B?
I install the latest version 1.16 from: https://php-download.com/package/phpoffice/phpspreadsheet
Sorry, I am still unable to duplicate your symptom. In Excel, I see the dropdown in A, as expected. I see the same in LibreOffice Calc. You are using OpenOffice Calc, which I do not have installed. Is it possible for you to see how your file looks in Excel or LibreOffice?
Here's B:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue for you, please try to help by debugging it further and sharing your results. Thank you for your contributions.
Unable to duplicate. No update to ticket since June. Closing.
This is: A Bug (Error) Report
What is the expected behavior?
I create a DataValidation only for cell A1. I add protection to the sheet. There should only be validation in A1
What is the current behavior?
I create a DataValidation only for cell A1. I add protection to the sheet. The DataValidation is mistakenly copied to the unprotected cells.
What are the steps to reproduce?
Which versions of PhpSpreadsheet and PHP are affected?
1.15.0 - 2020-10-11