Commit Graph

3606 Commits

Author SHA1 Message Date
BrokenSourceCode 46beabbefe Fix `ezyang/htmlpurifier` caret version range 2022-09-25 14:37:47 +02:00
MarkBaker 5f644c0144 Prepare Change Log for next release 2022-09-25 13:29:42 +02:00
MarkBaker 86f3730ded 1.25.0 - 2022-09-25
### Added

- Implementation of the new `TEXTBEFORE()`, `TEXTAFTER()` and `TEXTSPLIT()` Excel Functions
- Implementation of the `ARRAYTOTEXT()` and `VALUETOTEXT()` Excel Functions
- Support for [mitoteam/jpgraph](https://packagist.org/packages/mitoteam/jpgraph) implementation of
  JpGraph library to render charts added.
- Charts: Add Gradients, Transparency, Hidden Axes, Rounded Corners, Trendlines, Date Axes.

### Changed

- Allow variant behaviour when merging cells [Issue #3065](https://github.com/PHPOffice/PhpSpreadsheet/issues/3065)
  - Merge methods now allow an additional `$behaviour` argument. Permitted values are:
    - Worksheet::MERGE_CELL_CONTENT_EMPTY - Empty the content of the hidden cells (the default behaviour)
    - Worksheet::MERGE_CELL_CONTENT_HIDE - Keep the content of the hidden cells
    - Worksheet::MERGE_CELL_CONTENT_MERGE - Move the content of the hidden cells into the first cell

### Deprecated

- Axis getLineProperty deprecated in favor of getLineColorProperty.
- Moved majorGridlines and minorGridlines from Chart to Axis. Setting either in Chart constructor or through Chart methods, or getting either using Chart methods is deprecated.
- Chart::EXCEL_COLOR_TYPE_* copied from Properties to ChartColor; use in Properties is deprecated.
- ChartColor::EXCEL_COLOR_TYPE_ARGB deprecated in favor of EXCEL_COLOR_TYPE_RGB ("A" component was never allowed).
- Misspelled Properties::LINE_STYLE_DASH_SQUERE_DOT deprecated in favor of LINE_STYLE_DASH_SQUARE_DOT.
- Clone not permitted for Spreadsheet. Spreadsheet->copy() can be used instead.

### Removed

- Nothing

### Fixed

- Fix update to defined names when inserting/deleting rows/columns [Issue #3076](https://github.com/PHPOffice/PhpSpreadsheet/issues/3076) [PR #3077](https://github.com/PHPOffice/PhpSpreadsheet/pull/3077)
- Fix DataValidation sqRef when inserting/deleting rows/columns [Issue #3056](https://github.com/PHPOffice/PhpSpreadsheet/issues/3056) [PR #3074](https://github.com/PHPOffice/PhpSpreadsheet/pull/3074)
- Named ranges not usable as anchors in OFFSET function [Issue #3013](https://github.com/PHPOffice/PhpSpreadsheet/issues/3013)
- Fully flatten an array [Issue #2955](https://github.com/PHPOffice/PhpSpreadsheet/issues/2955) [PR #2956](https://github.com/PHPOffice/PhpSpreadsheet/pull/2956)
- cellExists() and getCell() methods should support UTF-8 named cells [Issue #2987](https://github.com/PHPOffice/PhpSpreadsheet/issues/2987) [PR #2988](https://github.com/PHPOffice/PhpSpreadsheet/pull/2988)
- Spreadsheet copy fixed, clone disabled. [PR #2951](https://github.com/PHPOffice/PhpSpreadsheet/pull/2951)
- Fix PDF problems with text rotation and paper size. [Issue #1747](https://github.com/PHPOffice/PhpSpreadsheet/issues/1747) [Issue #1713](https://github.com/PHPOffice/PhpSpreadsheet/issues/1713) [PR #2960](https://github.com/PHPOffice/PhpSpreadsheet/pull/2960)
- Limited support for chart titles as formulas [Issue #2965](https://github.com/PHPOffice/PhpSpreadsheet/issues/2965) [Issue #749](https://github.com/PHPOffice/PhpSpreadsheet/issues/749) [PR #2971](https://github.com/PHPOffice/PhpSpreadsheet/pull/2971)
- Add Gradients, Transparency, and Hidden Axes to Chart [Issue #2257](https://github.com/PHPOffice/PhpSpreadsheet/issues/2257) [Issue #2229](https://github.com/PHPOffice/PhpSpreadsheet/issues/2929) [Issue #2935](https://github.com/PHPOffice/PhpSpreadsheet/issues/2935) [PR #2950](https://github.com/PHPOffice/PhpSpreadsheet/pull/2950)
- Chart Support for Rounded Corners and Trendlines [Issue #2968](https://github.com/PHPOffice/PhpSpreadsheet/issues/2968) [Issue #2815](https://github.com/PHPOffice/PhpSpreadsheet/issues/2815) [PR #2976](https://github.com/PHPOffice/PhpSpreadsheet/pull/2976)
- Add setName Method for Chart [Issue #2991](https://github.com/PHPOffice/PhpSpreadsheet/issues/2991) [PR #3001](https://github.com/PHPOffice/PhpSpreadsheet/pull/3001)
- Eliminate partial dependency on php-intl in StringHelper [Issue #2982](https://github.com/PHPOffice/PhpSpreadsheet/issues/2982) [PR #2994](https://github.com/PHPOffice/PhpSpreadsheet/pull/2994)
- Minor changes for Pdf [Issue #2999](https://github.com/PHPOffice/PhpSpreadsheet/issues/2999) [PR #3002](https://github.com/PHPOffice/PhpSpreadsheet/pull/3002) [PR #3006](https://github.com/PHPOffice/PhpSpreadsheet/pull/3006)
- Html/Pdf Do net set background color for cells using (default) nofill [PR #3016](https://github.com/PHPOffice/PhpSpreadsheet/pull/3016)
- Add support for Date Axis to Chart [Issue #2967](https://github.com/PHPOffice/PhpSpreadsheet/issues/2967) [PR #3018](https://github.com/PHPOffice/PhpSpreadsheet/pull/3018)
- Reconcile Differences Between Css and Excel for Cell Alignment [PR #3048](https://github.com/PHPOffice/PhpSpreadsheet/pull/3048)
- R1C1 Format Internationalization and Better Support for Relative Offsets [Issue #1704](https://github.com/PHPOffice/PhpSpreadsheet/issues/1704) [PR #3052](https://github.com/PHPOffice/PhpSpreadsheet/pull/3052)
- Minor Fix for Percentage Formatting [Issue #1929](https://github.com/PHPOffice/PhpSpreadsheet/issues/1929) [PR #3053](https://github.com/PHPOffice/PhpSpreadsheet/pull/3053)
2022-09-25 13:06:17 +02:00
MarkBaker 77a064f58d Minor tweak 2022-09-25 13:02:01 +02:00
MarkBaker eb91890f8b Minor tweak 2022-09-23 15:34:18 +02:00
Mark Baker 6f5597d7b1
Merge pull request #3077 from PHPOffice/Issue-3076_Insert-Row-with-Defined-Names-Examples
Correct update to named ranges and formulae when inserting/deleting columns/rows
2022-09-23 14:44:56 +02:00
MarkBaker d682f2f95e Correct update to named ranges and formulae when inserting/deleting columns/rows 2022-09-23 14:03:38 +02:00
MarkBaker 3b0c450742 Merge remote-tracking branch 'origin/Issue-3076_Insert-Row-with-Defined-Names-Examples' into Issue-3076_Insert-Row-with-Defined-Names-Examples
# Conflicts:
#	src/PhpSpreadsheet/ReferenceHelper.php
2022-09-23 13:25:15 +02:00
MarkBaker abcbac6f9a Correct update to named ranges and formulae when inserting/deleting columns/rows 2022-09-23 13:24:31 +02:00
MarkBaker b7c025a183 Correct update to named ranges and formulae when inserting/deleting columns/rows 2022-09-22 01:10:53 +02:00
MarkBaker b9ded919fc Minor cosmetic changes 2022-09-21 15:37:51 +02:00
MarkBaker 6e93505cf5 Minor cosmetic changes 2022-09-21 14:43:24 +02:00
Mark Baker 813c2c7c70
Merge pull request #2959 from VincentLanglet/writerSave
Add throws tag to Writer::save method
2022-09-21 14:07:27 +02:00
Mark Baker e8a03fb410
Merge branch 'master' into writerSave 2022-09-21 13:56:22 +02:00
oleibman 53e0828d49
Sync composer.lock (#3075)
When I cloned this morning, composer gave me a message that the lock file was not up to date with the latest changes in composer.json. I do not understand why, but it suggested to run `composer update`, which I did. This led to a handful of problems with php-cs-fixer, all fixed with changes to doc-blocks, and phpstan (only Writer/Xls/Worksheet required a change to code). We would presumably have had these problems at the start of next month when dependabot did its thing, so fix them now.
2022-09-20 08:37:00 -07:00
oleibman a2b2984104
Document Charset Restriction for Html/Xml Reader (#3068)
Fix #1681, although probably not to the originator's satisfaction. Html and Xml readers will handle documents only with a charset of UTF-8. This PR documents that restriction. No change to source code; see the original issue for explanation.
2022-09-19 06:49:01 -07:00
oleibman a3921d20bc
Upgrade ezyang/htmlpurifier for Php8.2 (#3073)
They have just issued a new release. Using that should eliminate the last of our Php8.2 unit test problems, so we will be able to change that to non-experimental when it is convenient for us.
2022-09-19 06:20:48 -07:00
MarkBaker 579d2f9f69 Minor documentation update 2022-09-18 21:17:03 +02:00
MarkBaker 1f5ae85d19 Minor documentation update 2022-09-18 21:16:36 +02:00
Mark Baker 12cf2159f8
Merge pull request #3074 from PHPOffice/Issue-3056_Update-DataValidation-SqRef-On-Insert-Delete-Rows-Columns
Ensure that the sqRef stored for a DataValidation is updated on insert/delete rows/columns
2022-09-18 17:36:54 +02:00
Mark Baker a6cfd8c504
Merge branch 'master' into Issue-3056_Update-DataValidation-SqRef-On-Insert-Delete-Rows-Columns 2022-09-18 17:26:27 +02:00
MarkBaker 1746a5ac26 Ensure that the sqRef stored for a DataValidation is updated on insert/delete rows/columns, together with the DataValidationCollection value 2022-09-18 17:21:10 +02:00
oleibman c465b1c283
Minor Changes for Cygwin (#3070)
No source code changes. Mitoteam added a change to better accomodate Cygwin; pick up their new release. While testing, discovered one test that was already skipped on Windows and needs to be skipped on Cygwin as well.
2022-09-17 07:32:12 -07:00
oleibman ceb3bb2f38
Changelog Catch-up (#3069)
Added 5 changes.
2022-09-16 13:16:45 -07:00
oleibman b7fa470138
Scrutinizer Changes (#3060)
* Scrutinizer Changes

Scrutinizer appears to be working again. But the PRs that have used it have neither added new issues nor fixed existing ones. This PR should fix some exisiting; let's see what Scrutinizer does with it.

* Address Some False Positives

In Reader/Xlsx/Chart.
2022-09-16 09:16:11 -07:00
oleibman 90422bf1d2
R1C1 Format and Internationalization, plus Relative Offsets (#3052)
* R1C1 Format and Internationalization, plus Relative Offsets

Fix #1704, albeit imperfectly. Excel's implementation of this feature makes it impossible to fix perfectly. I don't know why it was necessary to internationalize R1C1 in the first place - the benefits are so minimal,and the result is worksheets that break when opened in different locales. Ugh. I can't even find complete documentation about the format in different languages; I am using https://answers.microsoft.com/en-us/officeinsider/forum/all/indirect-function-is-broken-at-least-for-excel-in/1fcbcf20-a103-4172-abf1-2c0dfe848e60 as my definitive reference.

This fix concentrates on the original report, using the INDIRECT function; there may be other areas similarly affected. As with ambiguous date formats, PhpSpreadsheet will do a little better than Excel itself when reading spreadsheets with internationalized R1C1 by trying all possibilities before giving up. When it does give up, it will now return `#REF!`, as Excel does, rather than throwing an exception, which is certainly friendlier. Although read now works better, when writing it will use whatever the user specified, so spreadsheets breaking in the wrong locale will still happen.

There were some bugs that turned up as I added test cases, all of them concerning relative addressing in R1C1 format, e.g. `R[+1]C[-1]`. The regexp for validating the format allowed for minus signs, but not plus signs. Also, the relevant functions did not allow for passing the current cell address, which made relative addressing impossible. The code now allows these, and suitable test cases are added.

* Use Locale for Formats, but Not for XML

Implementing a suggestion from @MarkBaker to use the system locale for determining R1C1 format rather than looping through a set of regexes and accepting any that work. This is closer to how Excel itself operates. The assumption we are making is to use the first character of the translated ROW and COLUMN functions. This will not work for Russian or Bulgarian, where each starts with the same letter, but it appears that Russian, at least, still uses R1C1. So our algorithm will not use non-ASCII characters, nor characters where ROW and COLUMN start with the same letter, falling back to R/C in those cases. Turkish falls into that category. Czech uses an accented character for one of the functions, and I'm guessing to use the unaccented character in that case. Polish COLUMN function is NR.KOLUMNY, and I'm guessing to use K in that case.

The function that converts R1C1 references is also used by the XML reader *where the format is always R1C1*, not locale-based (confirmed by successfully opening in Excel an XML spreadsheet when my language is set to French). The conversion code now handles that distinction through the use of an extra parameter. Xml Reader Load Test is duplicated to confirm that spreadsheet is loaded properly whether the locale is English or French. (No, I did not add an INDIRECT function to the Xml spreadsheet.)

Tests CsvIssue2232Test and TranslationTest both changed locale without resetting it when done. That omission was exposed by the new code, and both are now corrected.

* OpenOffice and Gnumeric

OpenOffice and Gnumeric make it much easier to test with other languages - they can be handled with an environment variable. Sensibly, they require R and C as the characters for R1C1 notation regardless of the language. Change code to recognize this difference from Excel.

* Handle Output of ADDRESS Function

One other function has to deal with R1C1 format as a string. Unlike INDIRECT, which receives the string on input, ADDRESS generates the string on output. Ensure that the ADDRESS output is consistent with the INDIRECT input.

ADDRESS expects its 4th arg to be bool, but it can also accept int, and many examples on the net supply it as an int. This had not been handled properly, but is now corrected.

* More Structured Test

I earlier introduced a new test for relative R1C1 addressing. Rewrite it to be clearer.

* Add Row for This to Locale Spreadsheet

It took a while for me to figure out how it all works. I have added a new row (with English value `*RC`) to Translations.xlsx, in the "Lookup and Reference" section of sheet "Excel Functions". By starting the "function name" with an asterisk, it will not be confused with a "real" function (confirmed by a new test). This approach also gives us the flexibility to do something similar if another surprise case occurs in future; in particular, I think this is more flexible than adding this as another option on the "Excel Localisation" sheet. It also means that any errors or omissions in the list below will be handled as with any other translation problem, by updating the spreadsheet without needing to touch any code.

The spreadsheet has the following entries in the *RC row:
- first letter of ROW/COLUMN functions for da, de, es, fi, fr, hu, nl, nb, pt, pt_br, sv
- no value for locales where ROW/COLUMN functions start with same letter - bg, ru, tr
- no value for locales with a multi-part name for ROW and/or COLUMN - it, pl (I had not previously noted Italian as an exception)
- no value for locales where ROW and/or COLUMN starts with a non-ASCII character - cs (this would also apply to bg and ru which are already included under "same letter")
- it does nothing for locales which are defined on the "Excel Localisation" sheet but have no entries yet on the "Excel Functions" sheet (e.g. eu)

Note that all but the first bullet item will continue to use R/C, which leaves them no worse off than they were before this change.
2022-09-16 08:25:26 -07:00
Mark Baker a846a93f52
Merge pull request #3066 from PHPOffice/Issue-3065_Merge-Cell-Options
Additional options for mergeCells() method
2022-09-16 14:17:06 +02:00
MarkBaker 84d6d98348 Unit tests for correctly handling hidden merged cells in Readers 2022-09-16 12:27:57 +02:00
MarkBaker 8ecf69a5c4 Handle additional merge options like those provide in OpenOffice or LibreOffice to hide cell values in a merge range rather than empty them, or to merge the values as well as the cells
This includes reading hidden values in merge ranges, so that Unmerging can restore their visibility
2022-09-15 21:07:31 +02:00
Mark Baker c6e84fbaf9
Merge pull request #3049 from PHPOffice/Calculation-Examples
Update Excel function samples for Date/Time and Engineering functions
2022-09-14 20:19:33 +02:00
Mark Baker 47067494f5
Merge branch 'master' into Calculation-Examples 2022-09-14 20:13:38 +02:00
oleibman 8513c6418c
Memory Leak in Sample35 (#3062)
* Memory Leak in Sample35

All but 6 chart samples can be rendered by Sample35. Of those 6, 3 of the problems are because the script runs out of memory processing them. Adopting a suggestion from @MAKS-dev in issue #2092, adding a call to gc_collect_cycles after the charts from each spreadsheet is rendered appears to make it possible to include those 3 spreadsheets in Sample35 after all.

Also take advantage of this opportunity to correct a number (hopefully all) of Scrutinizer problems with JpgraphRendererBases.

* Minor Fix

Problem running 8.1 unit tests.

* Resolve Problems with Pie 3D Charts

Minor fix, leaving only one spreadsheet unusable in Sample35. The reasons for its unusability are now documented in the code.

* Mitoteam Made Changes

Discussing this problem with them, they decided they should make a change for Pie3D rather than forcing us to use the workaround pushed earlier. Change to require mitoteam 10.2.3, revert workaround.
2022-09-14 10:12:53 -07:00
oleibman 6c1651e995
Floating-point Equality in Two Tests (#3064)
* Floating-point Equality in Two Tests

Merging a change today, Git reported failures that did not occur during "normal" unit testing. The merge still succeeded, but ... The problem was an error comparing float values for equal, and the inequality occurred beyond the 14th decimal digit. Change the tests in question, which incidentally were not part of the merged changed, to use assertEqualsWithDelta.

* Egad - 112 More Precision-related Problems

Spread across 9 test members.
2022-09-14 09:05:01 -07:00
oleibman 252474c1bd
Scrutinizer Clean Up Tests (#3061)
* Scrutinizer Clean Up Tests

No source code involved.

* Scrutinizer Whack-a-mole

Fixed 17, added 10. Trying again.

* Simplify Some Tests

Eliminate some null assertions.

* Dead Code

Remove 2 statements.
2022-09-14 07:11:20 -07:00
MarkBaker 441ae741d7 Update Excel function samples for Date/Time and Engineering functions 2022-09-14 14:16:32 +02:00
oleibman 3e8d50547c
Minor Fix for Percentage Formatting (#3053)
Fix #1929. This was already substantially fixed, but there was a lingering problem with an unexpected leading space. It turns out there was also a problem with leading zeros, also fixed. There are also problems involving commas; fixing those seems too complicated to delay these changes, but I will add it to my to-do list.
2022-09-12 08:45:13 -07:00
oleibman 2fe66d097f
Upgrade mitoteam/jpgraph for Php8.2 Usage (#3058)
They just released a Php8.2-compatible version. We should use that version going forward. Some tests had been disabled in 8.2 due to the problems which the new release fixes; these are now restored.
2022-09-12 08:23:43 -07:00
oleibman b5f70de61d
More Scrutinizer Catch Up (#3050)
* More Scrutinizer Catch Up

Continue the work of PR #3043 by attending to the 12 remaining 'new' issues.

* Php 8.1 Problem

One new null-instead-of-string problem.
2022-09-09 07:56:11 -07:00
oleibman 7e3807309d
Reconcile Differences between Css and Excel For Cell Alignment (#3048)
This PR expands on PR #2195 from @nkjackzhang. That PR has been stalled for some time awaiting requested fixes. Those fixes are part of this PR, and additional tests and samples are added. The original request was to handle `vertical-align:middle` in Css (Excel uses `center`). This PR does its best to also handle vertical alignment Excel values not found in Css - `justify` (as `middle`) and `distributed` (as `middle`). It likewises handles valid Css values not found in Excel (`baseline`, `sub`, and `text-bottom` as `bottom`; `super` and `text-top` as `top`; `middle` as `center`).

It also handles horizontal alignment Excel values not found in Css - `center-continuous` as `center` and `distributed` as `justify`; I couldn't think of a reasonable equivalent for `fill`, so it is ignored.

The values assigned for vertical and horizontal alignment are now lower-cased (special handling required for `centerContinuous`).
2022-09-09 07:34:36 -07:00
Mark Baker 420a63bc01
Merge pull request #3047 from PHPOffice/Calculation-Examples
Update Excel function samples for Database and Date/Time functions
2022-09-04 22:56:23 +02:00
Mark Baker 350f38ca60
Merge branch 'master' into Calculation-Examples 2022-09-04 22:46:11 +02:00
MarkBaker 3884aa7477 Update Excel function samples for Date/Time functions 2022-09-04 21:06:42 +02:00
oleibman adbda63912
Phpstan and Xlsx Reader (#3043)
Eliminate most Phpstan messages in Xlsx Reader. In combination with similar changes to Xlsx Writer, baseline will shrink to just over 3,000 lines.
2022-09-04 10:43:31 -07:00
oleibman 57a72037b5
Phpstan and Xlsx Reader (#3044)
Eliminate most Phpstan messages in Xlsx Reader. In combination with similar changes to Xlsx Writer, baseline will shrink to just over 3,000 lines.
2022-09-04 09:45:29 -07:00
oleibman 5f33ec0eea
Phpstan Baseline < 4000 Lines Part 3 (#3041)
The last of these changes for now. No remaining Phpstan complaints in any Writer/Xlsx. Number of lines remaining in Phpstan baseline is now below 3500.
2022-09-03 19:00:01 -07:00
MarkBaker ad2d3df2f7 Update Excel function samples for Database functions 2022-09-03 14:26:41 +02:00
oleibman 4f8aa806bc
Phpstan Baseline < 4000 Lines Part 2 Html (#3037)
Continue to reduce the size of Phpstan Baseline by fixing problems reported for Writer/Html.
2022-08-30 22:34:20 -07:00
oleibman 9eb5e7e976
Phpstan Baseline < 4000 Lines Part 1 (#3023)
A lot of easily fixed problems throughout Writer/Xlsx/*, mostly supplying int rather than string as input to WriteAttribute/WriteElement. There are, in fact, so many opportunities, that I will split it over 2 or 3 PRs. But this first one will get Phpstan baseline down to the goal on its own.

Some of the other problems are also easily fixed. In particular, the docBlocks in Style/ConditionalFormatting/ConditionalDataBar do not allow for null values, and should.
2022-08-29 22:15:50 -07:00
MarkBaker 026f699a65 Minor documentation updates 2022-08-29 17:14:03 +02:00
oleibman ca90379dc4
2 Minor Phpstan-related Fixes (#3030)
For one of the Phpstan upgrades, some message text had changed so drastically that the only practical solution at the time was to move the messages from phpstan-baseline.neon to phpstan.neon.dist. This was not ideal, but it allowed us time to move on and study the errors, which I have now done. At one point, Parser is expecting a variable to be an array, and that was not clear from the code. If not an array, the code will error out (which was Phpstan's concern); I have changed it to throw an exception instead. This satisfies Phpstan, and I can get the message out of neon.dist (without needing to restore it to baseline). Unsurprisingly, the exception was never thrown in the existing test suite, although I added a couple of tests to exercise that code.

In Helper/Dimension, Phpstan flagged a statement inappropriately. I suppressed the message using an annotation and filed a bug report https://github.com/phpstan/phpstan/issues/7563. A fix for the problem was merged yesterday, which is good, but it puts us in a tenuous position. The annotation is needed now, but, when the fix is inevitably pushed to the version we use, the no-longer-needed annotation will trigger a different message. Recode so that neither the current nor the future versions will issue a message, eliminating the annotation in the process.
2022-08-27 23:15:16 -07:00