Local clone of [PhpSpreadsheet](https://github.com/PHPOffice/PhpSpreadsheet/)
Go to file
oleibman a8462f3864
Apply Column and Row Styles to Existing Cells (#1721)
* Apply Column and Row Styles to Existing Cells

This is a fix for issue #1712.
When a style is applied to an entire row or column, it is currently
only effective for cells which don't already contain a value.
The code needs to iterate through existing cells in the row/column
in order to apply the style to them.
This could be considered a breaking change, however, I believe that
the change makes things operate as users would expect, and that the
existing implementation is incomplete.

The change also removes protected element conditionalStyles from
the Style class. That element is an unused remnant, and can no longer be
set or retrieved - methods getConditionalStyles and setConditionalStyles
actually act on an element in the Worksheet class.

Finally, additional tests are added so that Style, and in fact the
entire Style directory, now has 100% test coverage.

* Scrutinizer Changes

Scrutinizer flagged 6 statements. 5 can be easily corrected.
One is absolutely wrong (it thinks iterating through cells in column
can return null). Let's see if we can satisfy it.

* Remove Exception For CellIterator on Empty Row/Column

For my first attempt at this change, which corrects a bug by updating styles
for non-empty cells when a style is set on a row or column, I wished to make things
more efficient by using setIterateOnlyExistingCells, something which the
existing documentation recommends. This caused an exception to be generated
when the row or column is empty. So I removed that part of the change while I
researched what was going on.

I have completed that research. The existing code does throw an exception
when the row/column is empty and iterateOnlyExistingCells is true. However,
that does not seem like a reasonable action. This situation is analagous to
iterating over an empty array, and that action is legal and does not throw.
The same should apply here. There were no tests for this situation,
and now there are.

I have added additional tests, and coverage for all of RowCellIterator,
ColumnCellIterator, and CellIterator are all now 100%. Some of my new tests
were added in new members, because the existing tests all relied on mocking,
which was not the best choice for the new tests. One of the existing tests
for RowCellIteratorTest (testSeekOutOfRange) was wrong; it issued the expected
exception, but for the wrong reason. I have added an additional test to
ensure that it fails "correctly".

The existing documentation says that the default value for
IterateOnlyExistingCells is true. In fact, the default value is false.
I have corrected the documentation.

* More Scrutinizer

I believe its analysis is incorrect, but this should silence it.

* DocBlock Correction

ColumnCellIterator DocBlock for current indicated it could return null
or Cell, but it can really return only Cell. This had caused Scrutinizer
to complain earlier.

* PHP8 Environment Appears to be Fixed

Cosmetic change to Doc member. I suspect there is a way to rerun all
the tests without another push, but I have been unable to figure out how.
2020-12-10 18:19:56 +01:00
.github Automatic GitHub releases from git tags 2020-11-26 12:44:07 +09:00
bin Keep sample bootstrap purely in samples 2020-05-17 18:51:13 +09:00
docs Apply Column and Row Styles to Existing Cells (#1721) 2020-12-10 18:19:56 +01:00
samples Merge pull request #1734 from oleibman/morecoverage 2020-12-02 09:46:22 +09:00
src/PhpSpreadsheet Apply Column and Row Styles to Existing Cells (#1721) 2020-12-10 18:19:56 +01:00
tests Apply Column and Row Styles to Existing Cells (#1721) 2020-12-10 18:19:56 +01:00
.gitattributes Drop Travis 2020-11-26 11:10:52 +09:00
.gitignore Move PHP-CS-Fixer cache file out of the project to avoid IDE annoyance 2018-10-21 15:34:33 +11:00
.php_cs.dist Remove undesired annotations 2020-05-18 15:49:29 +09:00
.phpcs.xml.dist Move phpcs config to file 2020-07-26 14:48:06 +09:00
.scrutinizer.yml Scrutinizer wait shorter for coverage 2020-05-25 11:20:08 +09:00
CHANGELOG.PHPExcel.md Prefer https:// URLs when available in docs & comments 2018-10-28 13:55:00 +11:00
CHANGELOG.md Update change log 2020-12-10 18:13:12 +01:00
CONTRIBUTING.md `master` is the new default branch 2019-01-02 15:28:38 +11:00
LICENSE Change license from LGPL 2.1 to MIT 2019-11-17 18:08:34 +01:00
README.md Drop Travis 2020-11-26 11:10:52 +09:00
composer.json Resolve XSS Vulnerability in the HTML Writer (#1719) 2020-11-19 11:59:57 +01:00
composer.lock Resolve XSS Vulnerability in the HTML Writer (#1719) 2020-11-19 11:59:57 +01:00
mkdocs.yml `master` is the new default branch 2019-01-02 15:28:38 +11:00
phpunit.xml.dist Use current PHPUnit configuration xsd 2020-05-17 18:38:49 +09:00

README.md

PhpSpreadsheet

Build Status Code Quality Code Coverage Total Downloads Latest Stable Version License Join the chat at https://gitter.im/PHPOffice/PhpSpreadsheet

PhpSpreadsheet is a library written in pure PHP and offers a set of classes that allow you to read and write various spreadsheet file formats such as Excel and LibreOffice Calc.

Documentation

Read more about it, including install instructions, in the official documentation. Or check out the API documentation.

Please ask your support questions on StackOverflow, or have a quick chat on Gitter.

PHPExcel vs PhpSpreadsheet ?

PhpSpreadsheet is the next version of PHPExcel. It breaks compatibility to dramatically improve the code base quality (namespaces, PSR compliance, use of latest PHP language features, etc.).

Because all efforts have shifted to PhpSpreadsheet, PHPExcel will no longer be maintained. All contributions for PHPExcel, patches and new features, should target PhpSpreadsheet master branch.

Do you need to migrate? There is an automated tool for that.

License

PhpSpreadsheet is licensed under MIT.