Skip to content
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

Closed
wants to merge 11 commits into from

Conversation

sbreiler
Copy link
Contributor

@sbreiler sbreiler commented Dec 15, 2017

This is:

  • a bugfix
  • a new feature

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).

Copy link
Member

@PowerKiKi PowerKiKi left a 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
Copy link
Member

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;
Copy link
Member

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 ) {
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

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 PowerKiKi added missing test reader/xlsx Reader for MS OfficeOpenXML-format (xlsx) spreadsheet files labels Dec 16, 2017
@sbreiler
Copy link
Contributor Author

@PowerKiKi can you have a look at the changes? As mentioned, i can't seem to run composer fix on my windows machine. I would add unit test, if everything else is fine.

Copy link
Member

@PowerKiKi PowerKiKi left a 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;
Copy link
Member

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.

@sbreiler
Copy link
Contributor Author

sbreiler commented Jan 2, 2018

@PowerKiKi Could you have a look at the latest changes? Travis errored 'cause of some composer initialization problems...

@PowerKiKi PowerKiKi closed this in 653adf8 Jan 7, 2018
@PowerKiKi
Copy link
Member

Thanks for your cooperation ! I tweaked it a little bit and merged it.

PowerKiKi added a commit that referenced this pull request 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 pull request Nov 20, 2018
This would be used like `$conditonal->setStopIfTrue()` and is only supported
for XLSX format for now.

Closes PHPOffice#292
Dfred pushed a commit to Dfred/PhpSpreadsheet that referenced this pull request 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
missing test reader/xlsx Reader for MS OfficeOpenXML-format (xlsx) spreadsheet files
Development

Successfully merging this pull request may close these issues.

3 participants