-
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
Adding option to stop at a conditional styling, if it matches (only Xlsx-Files) #292
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, before being merge, we should address my comments and add unit tests. Also it might make it easier to unit tests if the writer was also implemented. That would be an even nicer contribution.
/** | ||
* Stop on this condition, if it matches | ||
* | ||
* @var int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a boolean instead of leaking file format into our model
@@ -28,6 +28,9 @@ class Conditional implements IComparable | |||
const OPERATOR_NOTCONTAINS = 'notContains'; | |||
const OPERATOR_BETWEEN = 'between'; | |||
|
|||
const IF_TRUE_STOP = 1; | |||
const IF_TRUE_DONT_STOP = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be dropped in favor of boolean
@@ -491,6 +491,10 @@ private function writeConditionalFormatting(XMLWriter $objWriter, Phpspreadsheet | |||
$objWriter->writeAttribute('text', $conditional->getText()); | |||
} | |||
|
|||
if( $conditional->getStopIfTrue() === Conditional::IF_TRUE_STOP ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix code style with composer fix
command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly it seems i can't run composer fix on windows - are the three equal-signs a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can see a details of what wrong on Travis.
@PowerKiKi can you have a look at the changes? As mentioned, i can't seem to run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I you can't run composer, then try ./vendor/bin/php-cs-fixer fix
which would have the same effect.
It would be best to write unit tests without writing files to disk, but if you cannot, then you could get inspiration from \PhpOffice\PhpSpreadsheetTests\Functional\Enclosure
.
@@ -28,6 +28,9 @@ class Conditional implements IComparable | |||
const OPERATOR_NOTCONTAINS = 'notContains'; | |||
const OPERATOR_BETWEEN = 'between'; | |||
|
|||
const IF_TRUE_STOP = true; | |||
const IF_TRUE_DONT_STOP = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant those two const
should be deleted entirely. There is no need to define a const for true
.
@PowerKiKi Could you have a look at the latest changes? |
Thanks for your cooperation ! I tweaked it a little bit and merged it. |
- 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)
This would be used like `$conditonal->setStopIfTrue()` and is only supported for XLSX format for now. Closes PHPOffice#292
- 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)
This is:
Checklist:
What does it change?
Can read & write conditional cell formating with "stopIfTrue"-Option, which would prevent any further condition checks if matched. Only implemented for Xlsx-Files (Xlsx Writer/Reader).