Commit Graph

4334 Commits

Author SHA1 Message Date
sji a034ab8989 Update CHANGELOG.md 2023-12-19 23:32:31 +09:00
sji 98ab75da99 Reduce memory consumption of Worksheet::rangeToArray() when many empty rows are read 2023-12-19 18:00:37 +09:00
oleibman c9ef889b16 Merge pull request #3832 from oleibman/findfont2
Addendum to Shared Font
2023-12-18 19:10:35 +00:00
oleibman 58ea5b5dcf Addendum to Shared Font
Forgot a couple of lines I intended to include.
2023-12-18 10:42:17 -08:00
oleibman 6f84f41ee6 Merge pull request #3830 from oleibman/issue2809
Recurse Directories Searching for Font File
2023-12-18 16:58:42 +00:00
oleibman 551d69c874 Update Font.php
Specified wrong constant for RecursiveIteratorIterator
2023-12-18 08:18:03 -08:00
oleibman 722600c8dc Update CHANGELOG.md 2023-12-18 08:05:00 -08:00
oleibman 7a4dd2d954 Merge branch 'master' into issue2809 2023-12-18 07:48:37 -08:00
oleibman 4e7a1487f9 Merge pull request #3828 from oleibman/issue3819
Strip `_xlfn.` and `_xlws.` In Formula Translations
2023-12-16 15:49:47 +00:00
oleibman 03da55cd8f Merge branch 'master' into issue3819 2023-12-16 07:20:22 -08:00
oleibman 25b3e1ca4a Minor Doc Block Improvement 2023-12-15 18:30:15 -08:00
oleibman 5a418ea1fb Recurse Directories Searching for Font File
Fix #2809. User felt font files should be searched recursively. The problem could be overcome merely by specifying a more precise font location. However, user has a point - the file layout on user's system is pretty common, and can be integrated into PhpSpreadsheet code easily. As a bonus, the DocBlock for setTrueTypeFontPath, which the user felt was misleading, doesn't even have to change.
2023-12-15 17:30:08 -08:00
oleibman c4da79e09a Ignore Coverage of Deprecated Functions 2023-12-15 08:18:35 -08:00
oleibman b6aa45659c Slightly Improved Regex
Use lookahead assertion to find xlfn/xlws only when preceding function name.
2023-12-15 02:21:41 -08:00
oleibman 3009873c44 Fix PR Number in Change Log 2023-12-14 13:49:01 -08:00
oleibman 5b7fce9286 Strip _xlfn. and _xlfs. In Formula Translations
Fix #3819. Excel can add these prefixes (basically invisible to end-user). Formula translation in PhpSpreadsheet fails when dealing with these unexpected prefixes, and, even if it handled it correctly, the unexpected prefixes confuse the users. I have changed to strip those prefixes when translating to a locale. This is probably not perfect, but is almost certainly good enough. I could easily add the same change when translating from a locale to English, but I don't think there's a good use case for that, so am opting not to do so for now.

The documentation mentions `translateFormulaToLocale` and `translateFormulaToEnglish`. Neither of these exist; both names are preceded by an underscore. I have changed the code to match the documentation rather than vice versa, retaining deprecated versions of the underscored routines which merely invoke the non-underscored routines.
2023-12-14 13:29:30 -08:00
oleibman 84e1cfad8c Merge pull request #3827 from oleibman/countifs
COUNTIFS Does Not Require _xlfn
2023-12-14 01:31:07 +00:00
oleibman 4857602559 Update CHANGELOG.md 2023-12-13 16:16:33 -08:00
oleibman 36b9a6484a Merge branch 'master' into countifs 2023-12-13 16:12:18 -08:00
oleibman 9592145be7 Merge pull request #3826 from PHPOffice/dependabot/composer/dompdf/dompdf-2.0.4
Bump dompdf/dompdf from 2.0.3 to 2.0.4
2023-12-14 00:07:31 +00:00
oleibman b0a776d556 COUNTIFS Does Not Require _xlfn
It was on our list as "introduced in 2019". It was, in fact, available with Excel 2007 (https://support.microsoft.com/en-us/office/excel-functions-alphabetical-b3944572-255d-4efb-bb96-c6d90033e188#bm3), so does not require a prefix when writing it to a spreadsheet. Brought to my attention with issue #3819, although I'm not sure correcting this will entirely solve the user's problem.
2023-12-13 15:43:42 -08:00
dependabot[bot] d8a91f35d2 Bump dompdf/dompdf from 2.0.3 to 2.0.4
Bumps [dompdf/dompdf](https://github.com/dompdf/dompdf) from 2.0.3 to 2.0.4.
- [Release notes](https://github.com/dompdf/dompdf/releases)
- [Commits](https://github.com/dompdf/dompdf/compare/v2.0.3...v2.0.4)

---
updated-dependencies:
- dependency-name: dompdf/dompdf
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-13 23:30:56 +00:00
oleibman 0fd7cc339a Merge pull request #3821 from oleibman/issue3820
Clone Worksheet With Table and/or Chart
2023-12-13 16:31:02 +00:00
oleibman 83daee854b Update CHANGELOG.md 2023-12-13 08:14:09 -08:00
oleibman da58d6cb6a Merge pull request #3824 from PHPOffice/dependabot/composer/phenx/php-svg-lib-0.5.1
Bump phenx/php-svg-lib from 0.5.0 to 0.5.1
2023-12-13 15:45:32 +00:00
dependabot[bot] d2365d6e58 Bump phenx/php-svg-lib from 0.5.0 to 0.5.1
Bumps [phenx/php-svg-lib](https://github.com/PhenX/php-svg-lib) from 0.5.0 to 0.5.1.
- [Release notes](https://github.com/PhenX/php-svg-lib/releases)
- [Commits](https://github.com/PhenX/php-svg-lib/compare/0.5.0...0.5.1)

---
updated-dependencies:
- dependency-name: phenx/php-svg-lib
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-13 13:52:41 +00:00
oleibman af5b6316c9 Cover A Bit More Code 2023-12-12 13:28:26 -08:00
oleibman 3f20b2347a Merge pull request #3815 from oleibman/issue3811
Tests Involving Decimal and Currency Separators
2023-12-12 18:24:24 +00:00
oleibman 72034e69fa Merge branch 'master' into issue3811 2023-12-12 10:17:12 -08:00
oleibman bf460cd4e2 Merge branch 'master' into issue3820 2023-12-12 10:12:34 -08:00
oleibman a5ce6b5529 Add Cloning of Charts
I had originally said I wouldn't add it to this PR, but I have changed my mind.
2023-12-12 09:49:23 -08:00
Adrien Crivelli 5aaed9ef6f Merge pull request #3084 from sashashura/patch-1
GitHub Workflows security hardening
2023-12-12 10:18:24 +00:00
Adrien Crivelli da0269da79 Merge branch 'master' into patch-1 2023-12-12 10:08:09 +01:00
Adrien Crivelli 689f961d1e Merge pull request #3823 from PHPOffice/readthedocs
Allow merge queue
2023-12-12 08:48:52 +00:00
Adrien Crivelli 026647e961 Allow merge queue 2023-12-12 09:45:05 +01:00
Adrien Crivelli 3972a842cd Configure Read the Docs
readthedocs.org build every commit pushed on `master`. However
builds have been failing for the past two months, because they
now require a config file. I assumed that config file was added,
but I was wrong. So I added it.
2023-12-12 09:42:12 +01:00
oleibman 117f89c751 Clone Worksheet With Table
Fix #3820. When cloning a worksheet, special handling is already included for `cellCollection` and `drawingCollection`. It needs to be added for `tableCollection` as well. In theory, `chartCollection` also needs it. However, there are no clone methods for any of the Chart objects, so that will be a substantially larger effort. There is no need to delay this fix waiting for that.
2023-12-11 15:31:26 -08:00
oleibman 0cd725d000 Automate Function-by-Name and Function-by-Category Docs (#3818)
* Automate Function-by-Name and Function-by-Category Docs

Examining whether it is possible to analyze the 2 Php scripts in the bin directory even though they lack a .php extension, I found that the docs generated by `generate-document` had not been updated in over a year even though support for a number of functions (e.g. ARRAYTOTEXT) had long ago been implemented. The files generated by the other script `generate-locales` are automatically generated as part of the unit test suite, and I can't see any reason not to do the same for `generate-document`.

It isn't totally clear that the 2 scripts in bin are needed any more now that each has an equivalent in the unit test suite. For now, I'm keeping them, and allowing them to be analyzed by phpcs, php-cs-fixer, and phpstan.

* Reflection Not Required

Remove it from bin scripts and DocumentGeneratorTest.

* Better Html/Css Display for Function Lists

* Redesign Features Cross Reference Doc

It was inaccurate, and pretty much impossible to read in entirety. This version should be easier to read, and to correct. That's important, because there are almost certainly new inaccuracies in this version.

* Add Html to Features Cross-Reference Readers
2023-12-11 07:38:13 -08:00
oleibman 27d3f09a90 Reader Xls Dead Code (#3756)
* Reader Xls Dead Code

Recent changes left Xls Reader with a ton of Scrutinizer messages. I have filtered away the false positives. Most of what is left is dead code, and this PR addresses those. Most of those are used to parse the BIFF data, but we either don't need to implement, or haven't yet implemented, those particular parsed data items. I think it is more useful to comment those out for documetary purposes rather than deleting them.

* Missed a Few
2023-12-10 07:44:30 -08:00
oleibman 4bac7ee4f5 Update CsvNumberFormatLocaleTest.php
More future-proofing.
2023-12-09 09:56:44 -08:00
oleibman 14d8d2b560 Update LocaleFloatsTest.php 2023-12-09 09:38:21 -08:00
oleibman e15fd7b673 Update LocaleFloatsTest.php
A bit of future-proofing.
2023-12-09 09:33:16 -08:00
oleibman 02a6513ec8 Remove byColumnAndRow Examples From Documentation (#3816)
* Remove byColumnAndRow Examples From Documentation

Responding to https://github.com/PHPOffice/PhpSpreadsheet/discussions/2706#discussioncomment-7798739.

* Migration From PHPExcel - Charts

Updated section to recommend use of mitoteam/jpgraph.

* Update accessing-cells.md

Remove 'by coordinate' from headings.
2023-12-09 07:46:50 -08:00
oleibman 2ae179c718 Merge branch 'master' into issue3811 2023-12-07 22:59:24 -08:00
oleibman fe4750b034 Update LocaleFloatsTest.php
Directory name was inadvertently left case-insensitive.
2023-12-07 22:58:01 -08:00
oleibman 9bef9c90ce Tests Involving Decimal and Currency Separators
This was suggested by the investigation of issue #3811. No fix is necessary for the issue. However, two possible code solutions (Php setlocale, which comes with certain design flaws, and StringHelper set(Decimal/Thousands)Separator were suggested, and neither is adequately tested. This PR adds such tests.

Unusually, getting StringHelper Decimal Separator, Thousands Separator, and Currency Code can result in a change to those properties. So, the existing design in several tests where those properties are captured in Setup and restored in Teardown do not work quite as designed. Instead, the ability to set those properties to their default value (null) is added, and the tests re-done to restore the default in Teardown.

The two methods yield the same results when parsing input. However, they diverge when examining output fields through `getFormattedValue`. Such output is currently correct (usually) when using setlocale, but not when using StringHelper. The former works through the 'trick' of using `sprintf(%f)`, which generates a locale-aware string. However, using non-locale-aware `sprintf(%F)` followed by `str_replace` will produce the correct result for both setlocale and StringHelper. One place in the code uses a cast to string, which is incorrect for both methods. Following that up with the same str_replace makes it correct for both. These changes permit, but do not require, the user to avoid setlocale altogether.

It remains an open question whether Settings/Calculation::setLocale should set DecimalSeparator, CurrencySeparator, and CurrencyCode. That makes logical sense, but it would be a breaking change, and having to explicitly set those values when using setLocale does not seem especially burdensome. For now, such a change will not be made.
2023-12-07 22:49:43 -08:00
oleibman 29c0162e2a Let Phpstan Run on Samples (#3808)
* Let Phpstan Run on Samples

Phpstan currently analyzes all source and test members. We already run phpcs and php-cs-fixer on samples as well. I would expect that samples are often used as templates for code in userland; it behooves us to be at least as careful with those members as for the others which are already being analyzed.  Aside from 1300+ messages `Variable $helper might not be defined.`, which will be suppressed in phpstan.neon.dist, there are really only a few changes needed for sample members, so that part of the code base was already in good shape, and is now even better. No annotations were needed.

* Scrutinizer 2 out of 3

1 false positive, now suppressed; fix other 2.

* Remove Dead Code

* Very Minor Changes

* Add infra
2023-12-06 09:40:27 -08:00
oleibman 5bcbc7db0c WIP Avoid a PHP8.4 Deprecation (#3789)
Fix #3782. A signature of the ReflectionMethod constructor will be deprecated, and PhpSpreadsheet runs afoul of that change in one place. Php8.4 is not yet available in any form, and I am reluctant to make this change until we see that the issue is real (and that this PR fixes it), so am leaving this PR in draft status till then.

I note that one Excel function `PI` is implemented not as a class method in PhpSpreadsheet, but rather as a call to the native Php function `pi`. The ReflectionMethod call is subject to a TypeError in the changed code, but that is already the case. We haven't seen a TypeError because (a) it will arise only if the caller supplies an argument to the function (which must be called with zero arguments), and (b) there are no test cases for that function. The code is slightly cleaned up, and test cases are now added. This is not an important enough problem to rush this PR - the existing code (and the changed code), rather than failing with TypeError, will fail with a CalculationException (wrong number of arguments) before it gets to the TypeError; that is the correct behavior.
2023-12-06 07:08:14 -08:00
oleibman 0fddcc184d Performance Improvement for Xlsx Reader (#3810)
* Performance Improvement for Xlsx Reader

Fix #3683. PR #3497 fixed a problem involving formulas and the quotePrefix style attribute. It did so by automatically turning off quotePrefix for any formulas encountered by Xlsx Reader. Under the right circumstances, it turns out that that change can cause a file read to take noticeably more time than previously. This change will turn off quotePrefix only if it is already on, and that appears to eliminate the performance problem while continuing to solve the original problem.

* Very Minor Improvement

* Update CHANGELOG.md
2023-12-05 21:10:02 -08:00
oleibman df3c6d9122 Prevent Loop in Shared/File::realpath (#3809)
Fix #3807. Function attempts to rationalize `..` in filenames in a way that normally works just fine. Reporter notes that at least one of the filenames that will be analyzed when a spreadsheet is read can be maliciously altered in a manner which does not harm Excel when reading the file, but which puts PhpSpreadsheet into a loop. This PR fixes the problem.
2023-12-04 16:58:53 -08:00