Releases: AsperaGmbH/xlsx-reader
Releases · AsperaGmbH/xlsx-reader
PHP 8.2 support and bugfixes
- Full support for PHP 8.2.
- New ReaderConfiguration property: $xml_reader_flags (settable via setXmlReaderFlags())
Will be given to any usage of XMLReader, allowing declaration of libxml constants such as LIBXML_PARSEHUGE. - Added dependency to ext-libxml in composer.json. (Was already required before, but wasn't explicitly noted as such.)
- Fixed issues with system date/time format specifications in XLSX file.
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.
Temporary workaround in approach to PHP 8.1 support
- Suppress PHP 8.1 notices about return type incompatibilities
Fix unintended returnUnformatted behavior change
- Fixed an issue that made returnUnformatted overrule all configuration options for date/time values.
More options for skipping empty cells/rows, formatter enhancements, Iterator interface implementation adjustments
Breaking changes:
- next() no longer returns the current row. Use current() instead.
- SkipEmptyCells needs to be supplied as a ReaderSkipConfiguration constant now.
Non-breaking changes:
- New configuration option "SkipEmptyRows".
Use it to exclude either all empty rows or all empty rows at the end of the document from the output.
Use ReaderSkipConfiguration values to configure it. - Configuration option "SkipEmptyCells" can now be configured to only skip trailing empty cells.
- Added support for scientific notation format.
- Fraction formatting support was enhanced.
- Fixed: "General" format does not output values as decimal, if they are stored using scientific notation internally.
- Fixed: Assorted edge cases in number formatting.
- Added notes to documentation of "ReturnUnformatted" and "ReturnPercentageDecimal" about possible gotchas.
- Internal refactorings.
New configuration classes, 'ReturnPercentageDecimal' option and various small improvements
Breaking changes:
- Reader configuration options must now be supplied to the Reader constructor via a ReaderConfiguration instance.
Supplying configuration options via an array is no longer supported. - When the "ReturnUnformatted" option is set, percentage values are now returned as strings instead of numbers.
This aligns their behavior with that of other values. - setDecimalSeparator() and setThousandsSeparator() methods have been removed, as they no longer had any function.
- Forced date/time format '' (empty string) gets interpreted correctly now.
Non-breaking changes:
- New configuration option "ReturnPercentageDecimal".
When set to true, percentage values will be returned using their technical, internal representation ('50%' => '0.5')
rather than how they are displayed within a document ('50%' => '50'). - Remove unnecessary restriction of custom formats to predetermined formats from the official specification documents.
- SharedStringsConfiguration calls can now be chained.
- Fix potential resource leaks caused by not closing reader instances.
- Update README.md to reflect the current code state.
Support for empty rows with attributes
- Added support for empty rows with attributes (or: self-closing row tags).
- Minor improvement of test handling.
Support for multi-range row span values
- Added support for multi-range row span values, fixing issues caused by sheets that use them.
Improved Number Format Support
Breaking changes:
- Public-facing method "setCurrencyCode" has been removed, as the currency_code value had no effect to begin with.
Non-breaking changes:
- New configuration option "ReturnUnformatted". If set to true, cell values will be returned without number formatting applied. (Note: Date/Time values are still controlled by the "ReturnDateTimeObjects" option.)
- Number format parsing has been improved. The reader is now capable of parsing more complex number formats.
- General format now outputs cell values as-is, instead of attempting to cast them to a float.
Support for negative date/time values
- Fixed issues regarding negative date/time values, causing very early date definitions to lead to unexpected errors.
- Fixed number formatting not being applied in all expected cases.