Commit Graph

133 Commits

Author SHA1 Message Date
MarkBaker 541bf0f876 Merge branch 'master' into 2.0-Development
# Conflicts:
#	docs/topics/calculation-engine.md
#	phpstan-baseline.neon
#	src/PhpSpreadsheet/Reader/Xlsx.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfCTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfPreciseTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ErfTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ParseComplexTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IrrTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AddressTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndirectTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php
#	tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php
2022-09-25 16:57:54 +02:00
MarkBaker 84d6d98348 Unit tests for correctly handling hidden merged cells in Readers 2022-09-16 12:27:57 +02:00
MarkBaker a26a58dbd2 Merge branch 'master' into 2.0-Development
# Conflicts:
#	phpstan-baseline.neon
#	src/PhpSpreadsheet/Cell/Cell.php
2022-08-17 18:44:24 +02:00
Mark Baker 6cdfd3c6d6 Merge branch '2.0-Development' into 2.x-Calendar-Changes 2022-08-17 16:48:45 +02:00
MarkBaker 765037e31d Ensure that correct calendar (read from the spreadsheet when loaded) is used for all date-related calculations and formatting 2022-08-17 16:41:14 +02:00
MarkBaker 3964087779 Test for calendar when reading Excel Files.
Set Excel calendar to be used for calculations and formatting for the calendar stored against the spreadsheet.
2022-08-08 15:17:27 +02:00
oleibman b661d31887 Limited Support for Chart Titles as Formulas (#2971)
This is a start in addressing issue #2965 (and earlier issue #749). Chart Titles are usually entered as strings or Rich Text strings, and PhpSpreadsheet supports that. They can also be entered as formulas (typically a pointer to a cell with the title text), and, not only did PhpSpreadsheet not support that, it threw an exception when reading a spreadsheet that did so.

This change does:
- eliminate the exception
- set a static chart title when it can determine it from the Xml

This change does not:
- fully support dynamic titles (e.g. if you change the contents of the source cell, or delete or insert cells or rows or columns)
- permit the user to set the title to a formula
- allow the use of formulas when writing a chart title to a spreadsheet
- provide styling for titles when it has read them as a formula
2022-08-06 17:39:18 -07:00
MarkBaker fe4808b3d5 Merge branch 'master' into 2.0-Development
# Conflicts:
#	composer.lock
#	tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php
2022-08-03 14:03:43 +02:00
oleibman 5de82981d8 Html Reader Not Handling non-ASCII Data Correctly (#2943)
* Html Reader Not Handling non-ASCII Data Correctly

Fix #2942. Code was changed by #2894 because PHP8.2 will deprecate how it was being done. See linked issue for more details. Dom loadhtml assumes ISO-8859-1 in the absence of a charset attribute or equivalent, and there is no way to override that assumption. Sigh. The suggested replacements are unsuitable in one way or another. I think this will work with minimal disruption (replace ampersand, less than, and greater than with entities representing illegal characters, then use htmlentities, then restore ampersand, less than, and greater than).

* Better Implementation

Use regexp to escape non-ASCII. Less kludgey, less reliant on the vagaries of the PHP maintainers.

* Additional Tests

Test non-ASCII outside of cell contents: sheet title, image alt attribute.

* Apply Same Change in Second Location

Forgot to change loadFromString.

* Additional Test

Confirm escaped ampersand is handled correctly.
2022-07-16 22:08:44 -07:00
oleibman f0059bb4bc Xlsx Chart Reader and Writer Mishandle Explosion Value (#2928)
Fix #2506. Reader only tests if Explosion is set without capturing its value. Writer hard-codes value when it is set.
2022-07-14 07:48:53 -07:00
MarkBaker ae746d035e Merge branch 'master' into 2.0-Development
# Conflicts:
#	phpstan-baseline.neon
#	src/PhpSpreadsheet/Shared/StringHelper.php
2022-07-09 16:38:08 +02:00
oleibman c3f53854b6 Php/iconv Should Not Treat FFFE/FFFF as Valid (#2910)
Fix #2897. We have been relying on iconv/mb_convert_encoding to detect invalid UTF-8, but all techniques designed to validate UTF-8 seem to accept FFFE and FFFF. This PR explicitly converts those characters to FFFD (Unicode substitution character) before validating the rest of the string. It also substitutes one or more FFFD when it detects invalid UTF-8 character sequences.

A comment in the code being change stated that it doesn't handle surrogates. It is right not to do so. The only case where we should see surrogates is reading UTF-16. Additional tests are added to an existing test reading a UTF-16 Csv to demonstrate that surrogates are handled correctly, and that FFFE/FFFF are handled reasonably.
2022-07-02 08:53:39 -07:00
MarkBaker a8fc5bc954 Merge branch '2.0-Development' into CalculationEngine-Array-Formulae-Initial-Work
# Conflicts:
#	phpstan-baseline.neon
#	tests/PhpSpreadsheetTests/Worksheet/WorksheetTest.php
2022-06-18 13:48:44 +02:00
FlameStorm 1829dea91e Ignore square-$-brackets prefix in format string (#2886)
* Ignore square-$-brackets prefix in format string

* Test for square-$-brackets prefix in format string issue fixed

* Fix for phpstan compliance

* Additional assert for checking number format of tested source cell
2022-06-15 14:55:17 -07:00
oleibman 90bdc7c12e Test For Excel File Saved With Ribbon Data (#2883)
File from https://www.rondebruin.nl/win/s2/win003.htm. I have been in conversation with the author, who has no objection to its use. I have not actually opened the file in Excel (at least not with macros enabled); I am using it merely to demonstrate that the ribbon data is read and written correctly. Test added; no source code changed. This should slightly increase coverage for Reader/Xlsx (moderate), Writer/Xlsx (slight), and Spreadsheet (substantial). Note that this file has no Ribbon Bin objects, so some coverage is still lacking.
2022-06-14 08:33:36 -07:00
oleibman c936f1d9f8 Coverage Improvements (#2859)
Mostly new tests, some code annotations, some minor code changes:
- RichText clone logic is wrong
- TextElement doesn't have object properties, doesn't need clone
2022-06-01 08:29:56 -07:00
MarkBaker b1ca6eee66 Merge branch '2.0-Development' into CalculationEngine-Array-Formulae-Initial-Work
# Conflicts:
#	phpstan-baseline.neon
2022-05-28 11:33:42 +02:00
MarkBaker bb7e083745 Add Hidden Worksheet unit tests for other Readers 2022-05-24 14:40:45 +02:00
MarkBaker 23ce21901d Add support for reading Worksheet Visibility for Gnumeric 2022-05-24 14:08:41 +02:00
MarkBaker 3fae29d613 Add support for reading Worksheet Visibility for Ods 2022-05-23 15:30:45 +02:00
oleibman 7c1c896959 Change and Re-enable URLImageTest (#2844)
Disabled it earlier because its reliance on an external site not under our control was causing problems. URL in spreadsheet is now changed to point to an image in phpspreadsheet.readthedocs.io, which should be more reliable. Test is re-enabled.
2022-05-21 08:07:59 -07:00
MarkBaker 198878b347 Add unit tests for ChartSheet reading 2022-05-16 13:30:30 +02:00
MarkBaker fd44f47f62 Fix issue with Xls Reader converting all named ranges from absolute to relative 2022-05-12 12:47:18 +02:00
MarkBaker f5b4308f22 Merge branch 'master' into CalculationEngine-Array-Formulae-Initial-Work 2022-05-11 21:01:34 +02:00
oleibman 070bc68514 Html Reader Converting Cell Containing 0 to Null String (#2813)
Fix #2810. Repairing some Phpstan diagnostics, used `?:` rather than `??` in a few places.

2 different Html modules are affected. Also, Ods Reader, but its problem is with sheet title rather than cell contents. And, as it turns out, Ods Reader was already not handling sheets with a title of `0` correctly - it made a truthy test before setting sheet title. That is now changed to truthy or numeric. Other readers are not susceptible to this problem. Tests are added.
2022-05-10 07:33:45 -07:00
MarkBaker acfd752794 Merge branch 'master' into CalculationEngine-Array-Formulae-Initial-Work
# Conflicts:
#	phpstan-baseline.neon
#	src/PhpSpreadsheet/Calculation/Calculation.php
2022-05-07 08:30:12 +02:00
oleibman 766252ccb0 Real Errors Identified in Calculation by Scrutinizer (#2774)
* Real Errors Identified in Calculation by Scrutinizer

Before Scrutinizer broke, I took a look at the remaining 43 errors which it categorized as 'major'. Most of these were false positives, but, in the case of Calculation and Reader/Xlsx/Chart, I was able to determine that its analysis of some of the problems was correct. There is little point addressing the false positives until it starts working again, but we should fix the real errors.

This PR addresses the real errors in Calculation.
- A test for `$pCellParent` should have been a test  for `$pCellWorksheet`.
- A test for `$operand1Data['reference']` should have been a test for `$operand1Data['value']`.
- A test for `$operand2Data['reference']` should have been a test for `$operand2Data['value']`.

* Fix Attempt to Erroneously Call trim on Array

Fix #2780. Warning message is being issued when getting calculated value of cell with value `=INDIRECT(ADDRESS(ROW(),COLUMN()-2))/$C$4`. This appears to be the case for all recent (and probably not so recent) releases; it is not a result of changes to the code base. Fix added to this PR because the erring section of code was proximate to code already changed in the PR. Test added.

* Minor Code Changes

Apply some suggestions from @MarkBaker
2022-04-30 19:13:17 -07:00
MarkBaker d613de1da5 Merge branch 'master' into CalculationEngine-Array-Formulae-Initial-Work
# Conflicts:
#	docs/references/function-list-by-category.md
#	docs/references/function-list-by-name.md
#	phpstan-baseline.neon
#	src/PhpSpreadsheet/Worksheet/Worksheet.php
2022-04-30 13:27:40 +02:00
andres1gb 4cd1d7039d Fix reading of files in the root of a zip (#2731)
* Fix reading of files in the root of a zip

Xlsx.php relies in dirname($filename) for path generation. When path is a bare filename (i.e. files in the root of the zip file), dirname($filename) returns a relative path to the current directory ("."). This is ok for filesystems, but not when accesing contents in a zip file.

Xlsx documents with files in the root of the zip container are not common, but legit. I've found it to happen in files generated by Google Campaign Manager 360.

* Update Xlsx.php

* Update Xlsx.php

* Update CHANGELOG.md

* Add files via upload

* Create XlsxRootZipFilesTest.php

* Update XlsxRootZipFilesTest.php

* Add files via upload

* Delete rootZipFiles.xlsx

* Update XlsxRootZipFilesTest.php

* Update Xlsx.php
2022-04-18 06:54:41 -07:00
redforks d593617287 Fix font index problem (#2642)
* Fix font index problem

* Update RichTextSizeTest.php

Eliminate Phpstan failure.

* Update RichTextSizeTest.php

Eliminate now-unused import.
2022-04-17 08:27:28 -07:00
MarkBaker fe1e0d2a9f Merge branch 'master' into CalculationEngine-Array-Formulae-Initial-Work 2022-03-24 21:05:22 +01:00
MarkBaker 0a9d15407f Suport fill style and color for reading CF Formats 2022-03-19 19:47:14 +01:00
MarkBaker 2b3addc30a Merge branch 'master' into CalculationEngine-Array-Formulae-Initial-Work 2022-03-19 16:41:03 +01:00
Mark Baker 23e2d702ff Merge branch 'master' into Xls-Reader-Conditional-Formatting 2022-03-19 16:21:14 +01:00
MarkBaker be8c444951 More minor tweaks 2022-03-19 16:15:48 +01:00
MarkBaker dc255fb46e Merge branch 'master' into CalculationEngine-Array-Formulae-Initial-Work
# Conflicts:
#	phpstan-baseline.neon
2022-03-19 13:18:53 +01:00
MarkBaker c73bb612e0 Unit tests for Xls Reader DataValidation 2022-03-19 12:04:14 +01:00
MarkBaker 45c08d6cd4 Initial work on reading conditional styles for the Xls Reader
Successfully reading the CF ranges and CF rules; not yet reading the styles
2022-03-18 21:09:32 +01:00
MarkBaker cb5a451aaf Initial work on Reading Conditional Formatting from Xls files 2022-03-15 13:25:23 +01:00
MarkBaker d6b6a110ec Additional array formula tests for Ods Reader 2022-03-05 10:37:43 +01:00
MarkBaker b67841a3dd Additional Gnumeric Reader array formula unit tests 2022-03-04 23:07:11 +01:00
MarkBaker 3dbc7ddd25 Handle aray formulae in the Gnumeric Reader (with unit tests) 2022-03-04 22:09:46 +01:00
MarkBaker 2c95f3a9f8 Merge branch 'master' into CalculationEngine-Array-Formulae-Initial-Work 2022-03-04 14:59:27 +01:00
MarkBaker f3d5028518 Work on setting up locale-aware formatted number conversion for the Csv Reader
Unit tests for locale-aware boolean conversion for Csv Reader
2022-03-02 08:53:29 +01:00
MarkBaker f64e2c2408 Prep-work for handling matrix arithmetic in the calc engine, with some basic unit tests 2022-02-27 22:19:12 +01:00
MarkBaker 444d0fd77c Unit tests for merge ranges for Ods Reader/Writer 2022-02-26 22:51:15 +01:00
MarkBaker e30e7cbfd4 More unit tests 2022-02-26 22:14:21 +01:00
oleibman 9cf526a920 Reading Xlsx With Supplied Palette (#2595)
Fix #2499, which see for details of an obscure problem affecting both PhpSpreadsheet and Excel. Add support for palette contained in workbook styles. This seems to be a very rare occurrence, so allow it only when the palette contains exactly 64 entries. If there are other possibilities, we'll presumably have a new workbook to guide us how to handle them. Also add some tests for specification of indexed color without palette, another rarity (no in-range examples amongst our current files). Also change one private static array, initialized once at run-time and never changed, to a constant.
2022-02-23 22:09:22 -08:00
Thorsten Ho 0cb60a5098 Fix XLSX broken vertical align font style (#2619)
* Fix XLSX broken vertical align font style

* Add fix information to changelog

* Fix phpcs issues
2022-02-23 20:23:59 -08:00
oleibman 5bf0656e92 Xlsx Reader Warning When No sz Tag for RichText (#2550)
Fix #2542. Xlsx Reader is expecting a `sz` tag when reading RichText, but it is not required, and PhpSpreadsheet issues a warning message when it is missing.
2022-02-12 06:43:29 -08:00