Commit Graph

4699 Commits

Author SHA1 Message Date
oleibman edf7f71e2a Merge branch 'master' into atsign 2024-06-30 00:28:18 -07:00
oleibman 1253f358bf Resolve Merge Conflict 2024-06-30 00:02:46 -07:00
oleibman b051d4946c Use CELL("width") As Another Unimplemented Array Function
I might want to implement CHOOSECOLS after this PR is merged.
2024-06-29 23:28:21 -07:00
oleibman 14c3df0ebc Merge pull request #4076 from oleibman/pr1415
CSV Writer Allow Varying Number of Columns
2024-06-30 02:34:08 +00:00
oleibman e8bb091f3b Merge branch 'master' into pr1415 2024-06-29 19:32:02 -07:00
oleibman 1ef063381b Update CHANGELOG.md 2024-06-29 19:28:40 -07:00
oleibman aae4992dca Merge pull request #4074 from yfinkel/patch-1
Update JpGraphRendererBase.php - check existing of PlotLabel
2024-06-30 02:12:15 +00:00
Юрий Финкель 675efc1f79 getDataLabel() defends against empty labels 2024-06-28 11:01:58 +04:00
Юрий Финкель 3b37d3e300 getDataLabel() defends against empty labels 2024-06-28 10:58:03 +04:00
Юрий Финкель 766a73cf84 getDataLabel() defends against empty labels 2024-06-28 10:54:30 +04:00
Юрий Финкель f3693406ed getDataLabel defends against empty labels 2024-06-28 10:49:56 +04:00
Юрий Финкель ccee8690d1 getDataLabel defends against empty labels 2024-06-28 10:43:05 +04:00
oleibman 02479de01a CSV Writer Allow Varying Number of Columns
Supersedes PR #1415 by @AndrewMonty, which went stale in May 2020, and which is not directly usable due to changes between now and then. Fix #1414, which also went stale; I will remove the stale status and reopen the issue pending the merging of this PR.

Add an option to CSV Writer so that it writes the cells for a row only through the highest data column used in the row, rather than through the highest data column used in the worksheet.
2024-06-27 00:01:55 -07:00
Юрий Финкель 17fc6234e6 Update JpGraphRendererBase.php 2024-06-26 12:39:26 +04:00
Юрий Финкель 36f316856b Check existing of PlotLabel before using its method getDataValue()
I'v got that:

Uncaught PHP Exception Symfony\Component\ErrorHandler\Error\FatalError: "Error: Uncaught Error: Call to a member function getDataValue() on bool in .../vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php:337

I've found that it's necessary to check existing of PlotLabel before using its method getDataValue().
2024-06-26 10:59:17 +04:00
Юрий Финкель acd0e386e8 Update JpGraphRendererBase.php - check existing of PlotLabel
I've got
Uncaught PHP Exception Symfony\Component\ErrorHandler\Error\FatalError: "Error: Uncaught Error: Call to a member function getDataValue() on bool in .../vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php:337

I found that it's necessary to check existing of PlotLabel before using its method getDataValue().
2024-06-26 10:35:25 +04:00
oleibman d767d4618a Merge pull request #4071 from oleibman/year1904
Make Base Date a Property of Spreadsheet
2024-06-26 05:00:26 +00:00
oleibman fe162bcf0e Update CHANGELOG.md 2024-06-25 21:58:10 -07:00
oleibman f181a4c66e Merge branch 'master' into year1904 2024-06-22 22:13:42 -07:00
oleibman 43589bc9b6 Make Base Date a Property of Spreadsheet
This change is extracted from PR #2787 by @MarkBaker. That change mostly deals with array functions, and that part will be superseded by PR #3962. However, this part of 2787 is not included in 3962.

Fix #1036 (closed as stale in 2019 and just reopened). Excel spreadsheets can have either of 2 base dates, 1900 or 1904, and the numeric value of any date cells will vary depending on which base date is in use. PhpSpreadsheet has, till now, handled that as a static property of Shared/Date. This does not work well if two spreadsheets with different base dates are open simultaneously. The code is changed to store the base date as a property of the spreadsheet when an Xls/Xlsx spreadsheet is loaded, and use that property when saving an Xls/Xlsx spreadsheet. Any call to `getCalculatedValue` or `getFormattedValue` will temporarily set the Shared/Date value to that of the spreadsheet, and restore it at completion. In order to avoid a BC break, the Xls and Xlsx readers will continue to populate the Shared/Date value as before.
2024-06-22 22:09:22 -07:00
oleibman cabd60ca09 Merge pull request #4060 from oleibman/stan9d
Better Definitions for Mixed Parameters and Values Part 3 of Many
2024-06-23 04:31:16 +00:00
oleibman 2076a07190 Minor Tweaks 2024-06-22 21:11:19 -07:00
oleibman fed7a32298 Dead Code 2024-06-21 22:30:12 -07:00
oleibman ef2b5b9e00 Mostly Docs and Tests
Also support for Xml format.
2024-06-21 21:55:05 -07:00
oleibman 3a690a755c SINGLE Function, and Gnumeric
SINGLE function can be used to return first value from a dynamic array result, or to return the value of the cell which matches the current row (VALUE error if not match) for a range. Excel allows you to specify an at-sign unary operator rather than SINGLE function; this PR does not permit that.

Add support for reading CSE array functions for Gnumeric.

Throw an exception if setValueExplicit Formula is invalid (not a string, or doesn't begin with equal sign. This is equivalent to what happens when setValueExplicit Numeric specifies a non-numeric value.

Added a number of tests from PR #2787.
2024-06-21 07:08:22 -07:00
oleibman 0b471ef772 Dead Code, and 1 Static Call to Non-Static 2024-06-20 01:21:43 -07:00
oleibman 2c9e2e2b43 Spill Operator
Spill operator now works both as trailing `#` and ARRAYANCHOR function. `#` is converted to ARRAYANCHOR when writing. I do not think it is important to convert the other way when reading.

Documentation updates have started, but are a work in progress.

SINGLE function is implemented. I believe it works correctly when referring to a cell, but not when referring to a cell range. No attempt is yet made to convert leading `@` to and from SINGLE; I haven't figured out how to do so without interfering with `@` in structured references.

ISREF has problems. At least one of its tests was wrong, and many of those that were right were so accidentally. The code is changed, quite kludgily, so that almost all the tests are now deliberately correct. One very complicated test is incorrect; for now, I will skip it, and will open an issue when this PR is merged.
2024-06-20 00:43:03 -07:00
oleibman 8609b78e53 Eliminate Dead Code 2024-06-17 15:19:55 -07:00
oleibman d7700125fa Spills
Implement SPILL for dynamic arrays. Calculating a dynamic array function will result in a SPILL error if it attempts to overlay a non-null cell which was not part of its previous calculation. Furthermore, it will set to null all cells which were part of its previous calculation but which are not part of the current one (i.e. one or both of the dimensions of the calculation is smaller than it had been); this should also apply for spills (whose result is reduced to 1*1).

Excel will stop you from changing the value in any cell in a dynamic array except the formula cell itself. I have not built this particular aspect into PhpSpreadsheet.

As usual, MS has taken some unusual steps here. If the result of a dynamic array calculation is #SPILL!, it will nevertheless be written to the xml as #VALUE!. It recognizes this situation by adding a new `vm` attribute to the cell, and expanding metadata.xml to recognize this.

A new optional parameter `$reduceArrays` is added to `toArray` and related functions. This will reduce a dynamic array to its first cell, which seems more useful than outputing it as an array (default).
2024-06-17 14:22:52 -07:00
oleibman 275b9480a3 Merge pull request #4069 from mogic-le/yield-docs
Documentation and example for rangeToArrayYieldRows()
2024-06-17 18:21:07 +00:00
Christian Weiske 1c931e2870 Documentation and example for rangeToArrayYieldRows()
Related: https://github.com/PHPOffice/PhpSpreadsheet/pull/3906
2024-06-17 11:29:36 +02:00
oleibman 784e8a0288 Drop Some Dead Code 2024-06-14 09:26:08 -07:00
oleibman ad2194d737 CONCATENATE Changes, and Csv/Html/Ods Support
The CONCATENATE function has been treated as equivalent to CONCAT. This is not how it is treated in Excel; it is closer to (and probably identical to) the ampersand concatenate operator. The difference manifests itself when any of the arguments is an array (typically a cell range). Code is added to support this difference.

Support for array results is added to Csv Writer, Html Writer, and Ods Reader and Writer. I have not figured out how to get it to work with Xls.
2024-06-14 08:30:18 -07:00
oleibman 60baa3a1b6 Merge pull request #4065 from oleibman/issue4004td
More RTL Support for Xlsx/Html Comments
2024-06-11 13:27:54 +00:00
oleibman 5c3b63068e Merge branch 'master' into issue4004td 2024-06-11 06:25:38 -07:00
oleibman a3c6f8f5c6 Update CHANGELOG.md 2024-06-11 06:24:33 -07:00
oleibman 846fec7afa Minor Performance Improvements 2024-06-10 09:19:35 -07:00
oleibman ef176f382e Excel Handle Array Functions as Dynamic Rather than CSE
With a number of changes, PhpSpreadsheet can finally generate a spreadsheet which Excel will recognize as a Dynamic Array function rather than CSE. In particular, changes are needed to ContentTypes, workbook.xml.rels, cell definitions in the worksheet, and a new metadata.xml is added.
2024-06-09 20:48:32 -07:00
oleibman b57a549fab More RTL Support for Xlsx/Html Comments
Following up from PR #4006. There is an additional RTL property available. It controls the placement of bidirectional neutral characters (mainly punctuation), as opposed to strong (alphabetic characters) or weak (numeric characters), especially at the beginning or end of a line. The new Comment property textboxDirection will be used for that purpose.

In a discussion in issue #4004 following the implementation of the PR, the comment was mixed RTL and LTR, and this led to some formatting problems. The user was able to overcome these with the timely insertion of Unicode directional control characters, but it would be preferable to have it happen automatically, which this change will permit. However, the use of these control characters cannot be entirely done away with. In the new test case, if one of the all-English lines ended with, say, a colon, it would not display correctly; LRM (left-to-right mark) after the colon would be needed. Likewise, one or two of the comment lines with mixed RTL and LTR (discussed in the issue) is not formatted correctly, and might require LRO/PDF or equivalent.
2024-06-06 16:55:27 -07:00
oleibman 3daac0a640 Add TODO Note
ArrayFunctions2Test - the calculations seem too complicated for PhpSpreadsheet. The debug log is 21,300 lines, so I don't know how far I will get with it.
2024-06-06 13:16:16 -07:00
oleibman 6b5bf84fbb Still More Formatting
I think I should go back to bed.
2024-06-06 07:09:50 -07:00
oleibman 47481c6a12 More Formatting
Frustrating morning.
2024-06-06 07:05:19 -07:00
oleibman 1b2198419e Incorrect Case for Filename 2024-06-06 07:01:45 -07:00
oleibman 856a00b8f0 Formatting 2024-06-06 06:55:33 -07:00
oleibman 08ba00b575 Populate Rest of Array Cells, UNIQUE Changes
See issue #4062. When calculating an array formula, populate all the cells associated with the result. This is almost the same as Excel's behavior. As yet, there is no attempt to create a #SPILL error, so cells may be inappropriately overwritten. Also, if the array size shrinks (e.g. there are fewer unique values than before),  no attempt is made to unpopulate the cells which were in range but are now outside the new dimensions. Spill and unpopulation are somewhat related, and will probably be handled at the same time, but their time has not yet come.

UNIQUE, at least for rows, was treating all cell (calculated) values as strings. This is not the same behavior as Excel, which will preserve datatypes, and treat int 3 and string 3 as unique values. Excel will, however, treat int 3 and float 3.0 as non-unique. Within UNIQUE, private function uniqueByRow is changed to try to preserve the the datatype when executing (it will probably treat 3.0 as int - I don't know how I can, or even if I should attempt to, do better - but no int nor float should be treated as a string).
2024-06-06 06:52:14 -07:00
oleibman 1c06890c7f Merge pull request #4064 from oleibman/issue4063
Handle Empty String in SharedStrings
2024-06-06 13:41:05 +00:00
oleibman 7c1ff62ed4 Update CHANGELOG.md 2024-06-06 06:38:50 -07:00
oleibman 5e26de63a9 Handle Empty String in SharedStrings
Fix #4063. Fix #1560. Fix #1293. PhpSpreadsheet is not accounting for an empty string in Xlsx sharedStrings.xml.The code which parses it in Reader/Xlsx looks for a `t` or `r` tag descending from `si`, but, in this case, the tag is coded as `<si/>`, with neither t nor r tag descending. An else clause is added to set the string to empty string in this case.

I was surprised that this had not turned up before, and a search through the archives found at least 2 earlier reports from 4 years ago. Those had been marked stale; the stale indicator is removed, and the issues are re-opened, to be closed when this PR is merged.
2024-06-06 06:17:02 -07:00
oleibman b79cd20f75 Merge branch 'master' into atsign 2024-06-05 06:58:26 -07:00
oleibman 85c1512b67 Better Definitions for Mixed Parameters and Values Part 3 of Many
Continuing work started with PR #4016 and PR #4026. Improve documentation within program by making explicit what types of values are allowed for variables described as "mixed". In order to avoid broken functionality, this is done mainly through doc-blocks. This will get us closer to Phpstan Level 9, but many changes will be needed before we can consider that.

This change has more executable code changes than its predecessor. I will wait longer than normal before merging it to allow for additional testing.
2024-06-04 06:47:51 -07:00