PHP version upgrade, Iterator adjustments, bugfixes
Summary:
- Minimum supported PHP version increased from 5.6 to 7.1.
- Full support for PHP 8.1.
- Iterator adjustments. (Details further below.)
- General code cleanup and bugfixes.
Breaking changes:
- Type hints from PHP 7.0 and 7.1 were added. Take note of this if you happen to extend any of the reader's classes
in your code. - Trying to iterate through a document without first calling open() will now throw an exception.
- The key of each row is 1-based now. This is to be in alignment with the values of the "r" attribute in the actual
XLSX document, which this method represents. - The count() method was removed, as it didn't provide the intended functionality.
Its actual functionality, which is to count how many rows were read so far, can be easily emulated by incrementing
a counter variable within the iteration loop. - Exception messages and -types in case of errors were adjusted.
If you rely on their exact types/wording in any way, make sure to adjust your exception handling accordingly. - The methods setDecimalSeparator() and setThousandsSeparator() were removed.
(This change was already communicated in a previous version, but not completely enforced yet.) - indexFromColumnLetter() no longer returns false on error. An exception is thrown instead.
Breaking changes for code addressing SharedStrings directly:
- SharedStrings now manages its own temporary files. Manual management from the outer scope is no longer necessary.
- Attempting to read SharedStrings data after closing the SharedStrings instance will now throw an exception.
- setHandleCurrentIndex() and setCount() have been removed from SharedStringsOptimizedFile, as they served no real
function.
Non-breaking changes:
- Calling close() now properly cleans up unnecessary resources from the reader that may have an impact on its memory
consumption. - Documentation improvements.
Iterator adjustments:
The Iterator interface allows iteration through the document by using a foreach on the Reader instance.
The previous implementation of the reader did not follow the Iterator interface rules correctly.
The adjustments in this update rectify this. As a result, take note of the following changes:
If you're using foreach on the Reader instance to read the document contents (like the example code in the readme):
- The key of each element now represents the actual row number, which, in XLSX, starts counting at 1.
(Previous versions started at 0.)
If you're calling the methods current() or key() directly:
- Do not call current() or key() without first checking the return value of valid().
Trying to access invalid positions will now throw an exception. - current() and key() both start at the first position now, regardless of the order in which they are called.
- key() is 1-based now. This is to be in alignment with the values of the "r" attribute in the actual XLSX document,
which this method represents.