Ask questionsData validation not working when opening & saving a file
- [x ] a bug report - [ ] a feature request - [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
I want to open an XLSX file that has some List Dropdown validation rules in it, write some data in it and save it.
When opening and saving an Excel file, it should retain all the data validation inside it.
It loses all data validation fields ( dropdowns, explanations etc)
Open the bellow excel file with data validation -> save it -> it loses validation.
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:
<?php require __DIR__ . '/vendor/autoload.php'; use PhpOffice\PhpSpreadsheet\IOFactory; // Declare the path of the file $inputFileName = __DIR__ . '/sample.xlsx'; // Load the file $spreadsheet = IOFactory::load($inputFileName); // Get first sheet in preparation for changes $sheetData = $spreadsheet->getSheet(0); // Create an XLSX writer $writer = IOFactory::createWriter($spreadsheet, "Xlsx"); // Save the file $writer->save("05featuredemo.xlsx");
"phpoffice/phpspreadsheet": "^1.11" PHP 7.3
Answer questions eugenio11
Hello, has this fix been implemented in the latest release of PhpSpreadsheet? I've just installed it, I have Data validation list with values loaded from another sheet and those lists are lost after opening with PhpSpreadsheet.