1776 Commits

Author SHA1 Message Date
oleibman 5ce46da559 Merge branch 'master' into issue4435 2025-04-05 17:29:22 -07:00
oleibman 5b799dbbed Ods Reader No Datatype for Null Value
Issue #4435 was initially described incorrectly. While investigating the original description, I came upon this problem. Ods Reader is trying to set some cells to null without supplying a valid DataType to setValueExplicit, causing that method to throw an exception. Reader is changed to no longer call that method when value is null and DataType is null-string.
2025-04-03 19:55:33 -07:00
oleibman e32447c4be Phpstan Level 9: Last 2025-03-31 21:53:47 -07:00
oleibman 5dee5a7bbb Merge pull request #4420 from oleibman/stan2lv905
Phpstan Level 9 - Part 5 of Many
2025-03-28 05:42:51 +00:00
oleibman 2213139d96 Merge branch 'master' into issue4416 2025-03-27 00:01:29 -07:00
oleibman 584c8662d7 Final Touch-up 2025-03-26 23:47:03 -07:00
Mikko a67e778b50 Conditional and table formatting support for html writer 2025-03-26 15:30:33 +02:00
oleibman ae5583caad Merge branch 'master' into issue4422 2025-03-25 20:02:23 -07:00
oleibman cc1357cb1d Merge branch 'master' into gridimprovements 2025-03-25 19:50:51 -07:00
oleibman 31656b0e96 Merge branch 'master' into clonetweak 2025-03-25 00:07:49 -07:00
oleibman 100d14969d Fix Typo in Style exportArray quotePrefix
Fix #4422. Add tests.
2025-03-24 22:05:20 -07:00
oleibman 6b61da0017 Column Widths Not Preserved When Using Read Filter
Fix #4416. A peculiar problem indeed. PhpSpreadsheet has been considering a column to be filtered if any cell in the column is filtered and does not preserve the column width if that is the case. It should consider the column not filtered if any cell in the column is not filtered, and consider it filtered only if there are no cells to which that applies. At least, that's how I think it should work, and this change doesn't break any existing tests, and solves this issue.
2025-03-24 20:18:51 -07:00
oleibman bc315a3edc A Win For Scrutinizer!
It flagged a statement as dead code. It was correct - there was a typo in the variable name. But no tests had failed. The explanation was, of course, that this particular path was not adequately tested.

PhpSpreadsheet extends Excel (dating back to PHPExcel) by allowing the ordinal form of days in the DATE function, implemented as "take the numeric portion if the field is a string consisting of a numeric portion followed by some alphabetics". Whether or not this is a good idea, it would be a breaking change to eliminate it, so that's not going to happen. However, the same logic has been applied to month, and I don't see a use case for that, so I'm eliminating it - any non-numeric string used as the month parameter will now result in a VALUE error. It also turns out that Excel accepts null, false, and true for the month, and PhpSpreadsheet will now do likewise.
2025-03-23 12:33:01 -07:00
oleibman 60c7e35124 Fix Phpstan Errors 2025-03-23 00:31:04 -07:00
oleibman 9875233c7e Tweak to Spreadsheet Clone
Spreadsheet clone already copies Calculation instanceArrayReturnType property. It should also copy some other Calculation instance properties, namely suppressFormulaErrors, calculationCacheEnabled, and branchPruningEnabled.
2025-03-23 00:11:02 -07:00
oleibman c54d55da07 Merge pull request #4417 from oleibman/issue4415
Ignore Fractional Part of Drawing Shadow Alpha
2025-03-23 07:04:00 +00:00
oleibman 4c350a6406 Merge pull request #4414 from oleibman/issue4411
Better Handling of Chart DisplayBlanksAs
2025-03-23 06:52:39 +00:00
oleibman ca71ae77ac TextGrid Improvements
Helper/TextGrid was intended to assist with some samples. However, it has emerged recently on two tickets. PR #4342 intended to introduce functionality very similar to TextGrid, and was closed for that reason. Issue #1640 was closed as stale over 4 years ago, despite the fact that TextGrid seems an adequate resolution for it.

Since it seems that there is a use for this function beyond its original intended usage, I added a few parameters to give it some flexibility - the ability to omit row and/or column headers, and the ability to add a divider line between rows.

A description of this function is added to the formal documentation.
2025-03-22 20:37:28 -07:00
oleibman 71b243539a Ignore Fractional Part of Drawing Shadow Alpha
Fix #4415. We store the rarely-used property Drawing/Shadow/Alpha as an integer representing the percentage. Excel also stores it as an integer, but multiplies it by 1,000, so we divide by 1,000 when we read this value. This can, and in the case of the issue at hand does, leave a fractional portion. Php has deprecated passing a float with a fractional portion to an int argument, so the reporter saw a deprecation message. This is easily fixed.
2025-03-20 20:11:11 -07:00
oleibman 19055da8b6 Better Handling of Chart DisplayBlanksAs
Fix #4411. User copied some code from a PHPExcel program which set DisplayAsBlanks to `0`. This resulted in what Excel deemed a corrupt spreadsheet using PhpSpreadsheet. The only values allowed for that field are `gap`, `zero` (not `0`), and `span`. PHPExcel used `0` as a default, and got away with it because it ignored the value entirely when writing out the spreadsheet, using `gap` all the time.

I had to choose between throwing an exception and just using the default when an attempt is made to set that property to an invalid value. An exception just seems more punitive than helpful to me, especially if we want people to migrate from PHPExcel, which still seems to have a large user base. So I've gone with using `gap` in place of an invalid value. Note that, according to https://learn.microsoft.com/ru-ru/openspecs/office_standards/ms-oe376/b5c5c694-21d9-437c-9a4a-21e0e843eed8, `gap` is used as the default whenever it is permitted for the chart in question; and, when it isn't permitted, the chart will use its default method (which will always be `zero`).

There were no tests nor samples for this property. All the tests and samples which use it use only `gap`. I have added a small test, and a new sample to illustrate the difference between the 3 options.
2025-03-19 20:21:14 -07:00
oleibman bb3d5fa510 Merge pull request #4404 from oleibman/issue4202
Permit Read to Class Which Extends Spreadsheet
2025-03-16 04:52:04 +00:00
oleibman 50bf8a0fad Wrong Case in File Name 2025-03-13 12:10:21 -07:00
oleibman 6083e393c1 Permit Read to Class Which Extends Spreadsheet
See discussion #4202. Users can extend Spreadsheet, but the readers cannot return the extended class. This is solved pretty easily by adding a protected method in BaseReader which returns a new Spreadsheet. Users can then extend the Reader which they want, overriding that method to return the extended class.
2025-03-13 12:01:33 -07:00
oleibman c3ea02ec01 Merge branch 'master' into localesplit2 2025-03-12 00:34:59 -07:00
oleibman 596af4e4b3 Merge branch 'master' into patch-1 2025-03-09 21:35:21 -07:00
oleibman d462fbf05e Fix Phpstan and Scrutinizer Problems 2025-03-09 21:27:29 -07:00
oleibman 263a397b84 Add test, Disable TREND_BEST_FIT, POLYNOMIAL_BEST_FIT 2025-03-09 20:21:16 -07:00
oleibman 156a12c0a4 Move Locale Logic in Calculation to Separate Class
Make things more maintainable (I hope).
2025-03-07 23:55:44 -08:00
oleibman b2d885fc4c Merge branch 'master' into stan2lv901 2025-03-07 21:55:50 -08:00
oleibman 4d81e53606 Merge branch 'master' into customfunc 2025-03-07 11:47:56 -08:00
oleibman 3ef8ec4b1a Merge pull request #4393 from oleibman/formularange
Add FormulaRange to IgnoredErrors Possibilities
2025-03-07 03:44:16 +00:00
oleibman c0a966b9bb Add a Test
Prove you can't override a built-in function.
2025-03-06 16:40:09 -08:00
oleibman d1d12ed92d Phpstan Level 9 - Part 1 of Many
Dealing mostly with mixed variable type. In a great many cases, problems can be resolved replacing `getValue` with `getValueString` or `getCalculatedValue` with `getCalculatedValueString`.
2025-03-05 21:59:54 -08:00
oleibman 190af743f8 Add FormulaRange to IgnoredErrors Possibilities
When I implemented IgnoredErrors (PR #3508), I dealt only with those that I understood well enough to come up with an example. I finally found an example for FormulaRange in the wild, so this PR adds it. Still unsupported are `calculatedColumn`, `emptyCellReferece`, `listDataValidation`, and `unlockedFormula`.
2025-03-03 20:16:12 -08:00
oleibman 53bce34456 Add Ability to Add Custom Functions to Calculation
For an overview of why this is desired (and ways that people have coped with its absence), see issue #2900 and issue #4048; also PR #4043 which will be superseded by this PR.

The list of Excel functions is moved from Calculation/Calculation to its own member. I believe that it is done in a way that will not cause big complications to two experiments from @MarkBaker (PR #2714 and PR #2734). I believe it is also done in such a way that further refactoring of Calculation can follow this model.

Custom functions can be added or removed from the function list. You cannot add a function if it already exists in the list, and you cannot remove a non-custom function from the list. They will, of course, not be understood by Excel if written to a spreadsheet; the use case is mainly using the Calculation engine outside of spreadsheet context.
2025-03-02 13:56:34 -08:00
oleibman a67a981d5e BIN2DEC, OCT2DEC, HEX2DEC Return Numbers Rather than Strings
Fix #4383.
2025-03-02 01:16:14 -08:00
oleibman 44ed8a8b6d Merge branch 'master' into issue4381 2025-02-28 16:17:52 -08:00
oleibman a1f90b76e4 Add A Test 2025-02-26 18:52:31 -08:00
oleibman ea490a1d87 Remove Unwanted Tests 2025-02-26 00:58:57 -08:00
oleibman fcc781d3d7 Merge branch 'master' into php82-str-split-function-return 2025-02-25 22:33:31 -08:00
oleibman 753e5d5e5a Merge branch 'master' into pr1449 2025-02-25 20:40:10 -08:00
oleibman db6e6ebd72 3rd Parameter for AVERAGEIF/SUMIF Can Also Be #REF! 2025-02-25 20:11:23 -08:00
oleibman 990e3ec3a3 Handle #REF! As Argument to COUNTIF, AVERAGEIF, SUMIF
Fix #4381. The report refers to COUNTIF, but AVERAGEIF and SUMIF, which are implemented in the same module, exhibit the same behavior. (There may be others, but, for now, I will just fix those 3.)

Most methods which implement Excel functions should accept mixed arguments, so that they won't throw exceptions when calculated. Of course, MS often doesn't give much guidance as to how unexpected arguments should be handled. It at least seems clear that MS will often substitute #REF! for some arguments, and will return #REF! as the result in such cases. My test indicates that a formula using, say, #DIV/0! in lieu of #REF! will cause Excel to deem the spreadsheet corrupt. So, I think I am just going to deal with #REF! and let other unexpected values continue to throw exceptions.
2025-02-24 21:40:12 -08:00
oleibman 8013034796 Fix Some Phpstan V2 Issues as Well
Performance of Phpstan V2 on my machine is dreadful. I will not be upgrading till I figure out how to fix it.
2025-02-24 15:43:35 -08:00
oleibman 53a984b747 Merge branch 'master' into feature/justifyLastLine 2025-02-23 12:39:58 -08:00
oleibman f366749285 Polishing Up 2025-02-23 12:38:44 -08:00
oleibman 01539876b1 Merge branch 'master' into issue4375 2025-02-23 12:28:17 -08:00
oleibman caf12eb80f Merge branch 'master' into pr1449 2025-02-21 13:24:21 -08:00
oleibman 2661adfb22 Merge pull request #4370 from oleibman/clonespreadsheet
Allow Clone on Spreadsheet
2025-02-21 01:45:06 +00:00
oleibman d813d7efcb Merge pull request #4360 from oleibman/issue4536
Xlsx Reader Defined Name on Sheet with Apostrophe in Title
2025-02-21 01:32:02 +00:00