Commit Graph

4509 Commits

Author SHA1 Message Date
oleibman fbcd68ce87 Update CHANGELOG.md 2024-03-15 15:49:29 -07:00
oleibman 44e8b4886c Merge branch 'master' into issue3923 2024-03-15 14:07:25 -07:00
oleibman 9b3f205528 Merge pull request #3939 from oleibman/sysformats2
Additional Support for Date/Time Styles
2024-03-15 18:49:01 +00:00
Mark Baker d01575416a Merge pull request #3937 from PHPOffice/Looping_the_Loop
Documentation about Iterating through Cells
2024-03-11 15:24:53 +00:00
Mark Baker a1e1af697c Merge pull request #3936 from PHPOffice/Behind_the_Mask
Documentation about Number Format Masking
2024-03-11 15:17:14 +00:00
Mark Baker 7b55c61552 Merge pull request #3938 from PHPOffice/The_Dating_Game
Documentation about Date Handling
2024-03-11 15:13:54 +00:00
oleibman 7893942a72 Unallocated Cells Affected by Column/Row Insert/Delete
Fix #3923. Cells which have not yet been allocated cause problems when they need to be moved due to a column/row insert/delete. Code had been added in ReferenceHelper earlier to create missing cells, but only in the last data column. It needs to change to create the missing cells:
- for columns, in rows 1 to "highest data row" for columns "before column" to "highest data column".
- for rows, in columns A to "highest data column" for rows "before row" to "highest data row".
2024-03-09 11:05:50 -08:00
oleibman accb321197 Additional Support for Date/Time Styles
Excel supports the following notations for cell styles:
- `[$-F800]` and `[$-x-sysdate]` will format the date according to what appears to be the user's system long date format.
- `[$-F400]` and `[$-x-systime]`, will format the time according to what appears to be the user's system long time format.
- Builtin style 14 will format date according to what appears to be the user's system short date format.
- Builtin style 22 will format date and time according to the user's preference. It appears that the date portion is formatted according to the user's system short date format, but the time portion is formatted according to a format which is neither system short time format nor system long time format, so I'm not sure how this preference is set.

For F800, sysdate, F400, and systime, any other characters in the style are ignored, except that, if you have more than one of this type of block in the style, Excel will treat it as corrupt (error message on open and style changed to General).

Support is added for the new codes. In addition, note that the value displayed in the cell may differ in different environments. To give the PhpSpreadsheet programmer an opportunity to emulate what the intended audience will most often see, properties `shortDateFormat` (default value is builtin 14), `longDateFormat` (default value is `dddd, mmmm d, yyyy`), `dateTimeFormat` (defaults to builtin 22), and `timeFormat` (default is `FORMAT_DATE_TIME2`), with corresponding setters and getters, are added to Style/NumberFormat. Note that, if these properties are set to some other value in PhpSpreadsheet, it will not affect the values in the cell or the style - it is merely a convenience for the programmer. It will, however, affect column width if autosize is specified for the column. If the programmer does not alter any of the new properties, the output should be unchanged from before for builtins 14 and 22.

The new styles are also recognized by the `TEXT` function. In this case, the cell's calculated value may differ from user to user.

Note that this is a small subset of adding locale information to styles. No attempt is made to support any of the other possibilities - locale data will continue to be passed through to the spreadsheet, but PhpSpreadsheet will discard it before attempting to generate the formatted value of a cell.
2024-03-08 21:13:56 -08:00
oleibman 9a94aea7ad Merge pull request #3924 from oleibman/issue3918
Default Style Alignment
2024-03-09 04:23:01 +00:00
oleibman 280c18e8ee Update CHANGELOG.md 2024-03-08 20:17:13 -08:00
oleibman 5587ca0cd5 Merge branch 'master' into issue3918 2024-03-08 19:14:49 -08:00
oleibman 9c5bf341be Merge pull request #3923 from oleibman/issue3730
Unexpected Absolute Address in Xlsx Rels File
2024-03-08 06:28:25 +00:00
MarkBaker 3435faeca5 Documentation about Date Handling 2024-03-07 12:38:38 +01:00
MarkBaker 868f6d4abe Documentation about Iterating through Cells 2024-03-07 12:37:40 +01:00
MarkBaker 790f489fe2 Documentation about Number Format Masking 2024-03-07 12:35:20 +01:00
oleibman bea48f068c Merge pull request #3929 from PHPOffice/dependabot/composer/squizlabs/php_codesniffer-3.9.0
Bump squizlabs/php_codesniffer from 3.8.1 to 3.9.0
2024-03-01 17:08:05 +00:00
oleibman d1378929c2 Merge pull request #3928 from PHPOffice/dependabot/composer/phpstan/phpstan-phpunit-1.3.16
Bump phpstan/phpstan-phpunit from 1.3.15 to 1.3.16
2024-03-01 17:07:38 +00:00
oleibman 95b9125206 Merge pull request #3927 from PHPOffice/dependabot/composer/phpstan/phpstan-1.10.59
Bump phpstan/phpstan from 1.10.57 to 1.10.59
2024-03-01 17:07:14 +00:00
oleibman 89f996ad95 Merge pull request #3926 from PHPOffice/dependabot/composer/phpunit/phpunit-9.6.17
Bump phpunit/phpunit from 9.6.16 to 9.6.17
2024-03-01 17:06:44 +00:00
oleibman 617393291f Merge pull request #3925 from PHPOffice/dependabot/composer/friendsofphp/php-cs-fixer-3.51.0
Bump friendsofphp/php-cs-fixer from 3.48.0 to 3.51.0
2024-03-01 17:06:06 +00:00
dependabot[bot] a749480a42 Bump squizlabs/php_codesniffer from 3.8.1 to 3.9.0
Bumps [squizlabs/php_codesniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer) from 3.8.1 to 3.9.0.
- [Release notes](https://github.com/PHPCSStandards/PHP_CodeSniffer/releases)
- [Changelog](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/CHANGELOG.md)
- [Commits](https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.8.1...3.9.0)

---
updated-dependencies:
- dependency-name: squizlabs/php_codesniffer
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-01 11:58:44 +00:00
dependabot[bot] e4ff49566e Bump phpstan/phpstan-phpunit from 1.3.15 to 1.3.16
Bumps [phpstan/phpstan-phpunit](https://github.com/phpstan/phpstan-phpunit) from 1.3.15 to 1.3.16.
- [Release notes](https://github.com/phpstan/phpstan-phpunit/releases)
- [Commits](https://github.com/phpstan/phpstan-phpunit/compare/1.3.15...1.3.16)

---
updated-dependencies:
- dependency-name: phpstan/phpstan-phpunit
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-01 11:58:38 +00:00
dependabot[bot] d62172a35d Bump phpstan/phpstan from 1.10.57 to 1.10.59
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 1.10.57 to 1.10.59.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Changelog](https://github.com/phpstan/phpstan/blob/1.11.x/CHANGELOG.md)
- [Commits](https://github.com/phpstan/phpstan/compare/1.10.57...1.10.59)

---
updated-dependencies:
- dependency-name: phpstan/phpstan
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-01 11:58:33 +00:00
dependabot[bot] 35c6111a23 Bump phpunit/phpunit from 9.6.16 to 9.6.17
Bumps [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) from 9.6.16 to 9.6.17.
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/9.6.17/ChangeLog-9.6.md)
- [Commits](https://github.com/sebastianbergmann/phpunit/compare/9.6.16...9.6.17)

---
updated-dependencies:
- dependency-name: phpunit/phpunit
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-01 11:58:22 +00:00
dependabot[bot] ee1fd8b9aa Bump friendsofphp/php-cs-fixer from 3.48.0 to 3.51.0
Bumps [friendsofphp/php-cs-fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) from 3.48.0 to 3.51.0.
- [Release notes](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases)
- [Changelog](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/CHANGELOG.md)
- [Commits](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.48.0...v3.51.0)

---
updated-dependencies:
- dependency-name: friendsofphp/php-cs-fixer
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-01 11:58:14 +00:00
oleibman 76b2dc70ea Merge pull request #3915 from oleibman/issue3907
Formula Misidentifying Text as Cell After Insertion/Deletion
2024-03-01 01:19:03 +00:00
oleibman c51ec67327 Update CHANGELOG.md 2024-02-29 17:15:36 -08:00
oleibman 4a459e0558 Merge branch 'master' into issue3907 2024-02-29 17:05:04 -08:00
oleibman b020c208c2 Merge pull request #3916 from oleibman/issue3909
Incorrect SUMPRODUCT Calculation
2024-02-29 21:09:04 +00:00
oleibman d418762a33 Win For Scrutinizer
It pointed out a problem that I would have thought should result in test failure. Code corrected, and documentation updated to describe the unexpected behavior.
2024-02-29 12:18:34 -08:00
oleibman d46b7b3e9d Default Style Alignment
Fix #3918, sort of. Xlsx cells use the default style when they omit the `s` tag, or when `s="0"` is specified. LibreOffice does not honor Alignment in the default Style unless the cell explicitly uses the second form, even though it honors other default Styles (e.g. bold font) when `s` is omitted. Gnumeric seems to have the same problem. A bug report has been filed with LibreOffice.

In the meantime, this PR adds to Xlsx Writer an optional boolean property `explicitStyle0` with setter and getter. Default is false, which will continue the current behavior by adding an `s` tag only when the cell uses a non-default style (this is how Excel itself behaves). When set to true, Xlsx Writer will explicity write `s="0"` for all cells using default style. This will allow users to create an Xlsx spreadsheet with default alignment of cells that will show up correctly when the spreadsheet is viewed with LibreOffice. Technically speaking, it is *probably* safe to always use `true`, except that the spreadsheet size will be a bit larger. However, my hope is that this is a temporary measure which can go away when the vendors have had a chance to fix their problems, hence the `false` default.
2024-02-29 11:11:00 -08:00
oleibman 41dd6c373d Unexpected Absolute Address in Xlsx Rels File
Fix #3730. File workbook.xml.rels in test file specified absolute addressing for shared strings, styles, and worksheets. Previous changes had addressed absolute addressing for worksheets, but shared strings and styles had not yet been addressed.
2024-02-29 07:38:38 -08:00
oleibman d09120d209 Merge pull request #3921 from rdey/hotfix/prepending-zero-prc
Fix issue with prepending zero in percentage -10<n<-9
2024-02-28 15:41:43 +00:00
Nicholas Ruunu c1d141bea3 Fix issue with prepending zero in percentage
Before it was a bug when flooring negative numbers added to the length of
the number for the sprintf mask.
For example -0.091 becomes -9.1 in percentage, floors to -10 which is going to
increase $wholePartSize by 1 and add a leading zero to the result: -09.1% with
format 0.0%.
This happened for negative ranges where floor will increse the length of
the original number.
2024-02-27 23:31:16 +01:00
oleibman dc84a51f74 Merge pull request #3906 from oleibman/issue3904c
Improve Performance of Csv Writer
2024-02-23 05:05:15 +00:00
oleibman 3dd40ee634 Update CHANGELOG.md 2024-02-22 20:59:05 -08:00
oleibman 9a685e378a Merge branch 'master' into issue3904c 2024-02-22 20:42:18 -08:00
oleibman 64bdc6424c Incorrect SUMPRODUCT Calculation
Fix #3909. SUMPRODUCT is mishandling multi-row ranges. In Calculation/Calculation, `checkMatrixOperands` will often resize its operands. When it does so, it needs to recalculate the dimensions of each. This fixes the reported problem.

Likely cause was PR #3260. That ticket noted the poor coverage of the code being replaced. Tests of the problem in this ticket were absent and are now added. Despite this, I note that `resizeMatricesShrink` is virtually uncovered, and `resizeMatricesExpand` has substantial gaps in its coverage. I have covered some, but not all, of the Expand gaps. I am struggling to come up with examples to fill its remaining gaps and those for Shrink. However, I will merge this fix in about a week even if I don't succeed.
2024-02-21 22:32:30 -08:00
oleibman a096fcc77d Formula Misidentifying Text as Cell After Insertion/Deletion
Fix #3907. After row/column insertion/deletion, PhpSpreadsheet updates formulas which include cells which have moved. However, it can mis-identify cell addresses within the formula. Examples:
- `=SUM(A2,'F1 (SETTINGS)'!A1:B1)` It identifes F1 as a cell address.
- `=SUM(A2,'x F1 (SETTINGS)'!A1:B1)` It identifes F1 as a cell address. (This looks the same as the above, but, for technical reasons, it's different.)
- `=SUM(A2,definedname1A1)` It identifes A1 as a cell address.
- Sheet names in formulas are compared case-sensitively, and should be compared insensitively. This can make a difference if the formula includes its own sheet name, e.g. on sheet `Data`, formula `=SUM(DATA!A1:A2)` might have to change, but it will not do so with the existing logic.

The defined name part is fairly straightforward. The regular expressions that identify a cell address just have to be a bit more robust. It was doing a negative look-behind for an alphabetic character or dollar sign; underscore, period, and digits, all of which can be part of a defined name, need to be added to that list.

The other situations need a bit of a kludge, but not one so bad that I'm ashamed of it. The formulas will be altered before analysis so that sheet names are replaced with Unicode FFFD (sheetname does not match current sheet), FFFC (sheetname, enclosed in apostrophes, matches current sheet), and FFFB (sheetname, not enclosed in apostrophes, matches current sheet). This prevents the existing regular expressions from finding a cell address within a sheet name, and makes it easy to restore the original, with or without apostrophes, when the sheet name matches the current sheet and the cell(s) which it qualifies have to be changed.

Tests are added for all the situations mentioned above. No existing tests required changes.
2024-02-21 22:10:58 -08:00
oleibman d0393a2eed Merge pull request #3903 from oleibman/issue3900
Handling of User-supplied Decimal and Thousands Separators
2024-02-22 06:04:20 +00:00
oleibman 0c8a80e834 Merge pull request #3914 from PHPOffice/dependabot/composer/phenx/php-svg-lib-0.5.2
Bump phenx/php-svg-lib from 0.5.1 to 0.5.2
2024-02-21 22:36:25 +00:00
dependabot[bot] d0895c65de Bump phenx/php-svg-lib from 0.5.1 to 0.5.2
Bumps [phenx/php-svg-lib](https://github.com/PhenX/php-svg-lib) from 0.5.1 to 0.5.2.
- [Release notes](https://github.com/PhenX/php-svg-lib/releases)
- [Commits](https://github.com/PhenX/php-svg-lib/compare/0.5.1...0.5.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-21 18:29:46 +00:00
oleibman 18a5396eb4 Improve Performance of Csv Writer
Fix #3904. PR #3839 provided a huge performance boost for sparsely populated spreadsheets. Unfortunately, it degraded performance for more densely populated spreadsheets when writing Csvs. The reason is that Csv Writer calls toArray for each row, meaning that a lot of the intermediate data used to speed things up needs to be recalculated for every row. It would be better off calling toArray just once for the entire spreadsheet; however this gives back some of the memory improvements of PR #3834. However, the memory effects can be substantially alleviated by supplying a Generator function to do the work. This PR does that; the result is that Csv Writer is now quite a bit faster, and with only a small memory uptick, vs. its performance in PhpSpreadsheet 1.29.
2024-02-17 08:48:31 -08:00
oleibman 0c37ae2c30 Merge pull request #3898 from oleibman/stanannotations
Eliminate Some Phpstan-ignore Annotations
2024-02-15 05:59:59 +00:00
oleibman e1fb68efc1 Handling of User-supplied Decimal and Thousands Separators
Fix #3900. The code to adjust Decimal and Thousands separators to user-specified choices expects to convert periods to commas and vice versa - hard-coded without taking the user specification into account. This is likely to be the only significant use case, however, as the issue demonstrates, it is not the only possibility. In particular, it will mess up Csv output if decimal separator is kept as period, but thousands separator is set to null string. The code is altered to replace period with the user-selected decimal separator, and comma with the user-selected thousands separator. No existing tests broke as a result of this change in behavior.
2024-02-14 21:20:45 -08:00
Adrien Crivelli c677a2f1c8 Never mention a specific PhpSpreadsheet version in documentation 2024-02-11 14:39:49 +08:00
oleibman 1ac1e7f11f Eliminate Some Phpstan-ignore Annotations
This PR resolves about half the statements which we tell Phpstan to ignore. There will still be 23 such annotations spread over 10 source modules for various reasons (too complicated, suspect PhpSpreadsheet code, one Phpstan bug), plus some deliberate errors in the test suite.
2024-02-08 21:14:14 -08:00
oleibman d620497511 Merge pull request #3893 from oleibman/stanarray2
Phpstan Fixes
2024-02-07 17:44:53 +00:00
oleibman 3512304974 Merge pull request #3897 from oleibman/round84
Floating Point and Php Nightly 8.4
2024-02-07 17:32:00 +00:00
oleibman e4ce0ea8f8 Floating Point and Php Nightly 8.4
Fix #3896. It appears that floating-point arithmetic will give different results in Php 8.4 vs. all earlier releases. This causes tests to fail in the nightly run for ROUNDDOWN, ROUNDUP, and AMORDEGRC. I imagine this won't be the last we hear of this. The failures are a distraction when reviewing PR's. This PR eliminates the distraction by adding in a fudge factor for Php 8.4+ while not changing Php 8.3-. It is not a particularly robust solution, but it should be stable for Php 8.3-, and good enough for Php 8.4+ while I study if a better solution is available.
2024-02-06 12:04:58 -08:00