-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cell coordinates which are already a range cause an exception #319
Labels
Comments
Would you have a Minimal, Complete, and Verifiable example of code that exhibits this issue ? |
PowerKiKi
added
bug
writer/xlsx
Writer for MS OfficeOpenXML-format (xlsx) spreadsheet files
help wanted
labels
Jan 8, 2018
Thanks, I can indeed reproduce with your code. Copy/pasted here for convenience: <?php
require __DIR__ . '/vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Cell\DataValidation;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xls;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$spreadsheet = new Spreadsheet();
$spreadsheet->getActiveSheet()->setDataValidation(
'A1:A2',
(new DataValidation())
->setType(DataValidation::TYPE_LIST)
->setShowDropDown(true)
->setFormula1('"A,B,C,"')
);
// XLS saving - Works with ranges as it doesn't merge cell coordinates
(new Xls($spreadsheet))->save('out.xls');
// XLSX saving - Worked with ranges before cell coordinates were merged into ranges
(new Xlsx($spreadsheet))->save('out.xlsx'); If you are able to submit a PR with your suggested fix and include unit tests, we might get it to be merged. |
5 tasks
PowerKiKi
added a commit
that referenced
this issue
Jan 28, 2018
- Support for PHP 7.2 - Support cell comments in HTML writer and reader - [#308](#308) - Option to stop at a conditional styling, if it matches (only XLSX format) - [#292](#292) - Support for line width for data series when rendering Xlsx - [#329](#329) - Better auto-detection of CSV separators - [#305](#305) - Support for shape style ending with `;` - [#304](#304) - Freeze Panes takes wrong coordinates for XLSX - [#322](#322) - `COLUMNS` and `ROWS` functions crashed in some cases - [#336](#336) - Support XML file without styles - [#331](#331) - Cell coordinates which are already a range cause an exception [#319](#319)
Dfred
pushed a commit
to Dfred/PhpSpreadsheet
that referenced
this issue
Nov 20, 2018
Dfred
pushed a commit
to Dfred/PhpSpreadsheet
that referenced
this issue
Nov 20, 2018
- Support for PHP 7.2 - Support cell comments in HTML writer and reader - [PHPOffice#308](PHPOffice#308) - Option to stop at a conditional styling, if it matches (only XLSX format) - [PHPOffice#292](PHPOffice#292) - Support for line width for data series when rendering Xlsx - [PHPOffice#329](PHPOffice#329) - Better auto-detection of CSV separators - [PHPOffice#305](PHPOffice#305) - Support for shape style ending with `;` - [PHPOffice#304](PHPOffice#304) - Freeze Panes takes wrong coordinates for XLSX - [PHPOffice#322](PHPOffice#322) - `COLUMNS` and `ROWS` functions crashed in some cases - [PHPOffice#336](PHPOffice#336) - Support XML file without styles - [PHPOffice#331](PHPOffice#331) - Cell coordinates which are already a range cause an exception [PHPOffice#319](PHPOffice#319)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Because Coordinate::mergeRangesInCollection is now used in the the Xlsx worksheet writer for data validation and it doesn't support existing ranges you can no longer call Worksheet\Worksheet setDataValidation with a column range as it'll cause the "Cell coordinate string can not be a range of cells" exception.
PhpSpreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php
Line 405 in 27d83b4
I suggest moving the definition of $mergedCoordCollection to line 403 then skip coordinate parsing if the coord is already a range like so:
The text was updated successfully, but these errors were encountered: