267 Commits

Author SHA1 Message Date
oleibman d5b9ba68e2 New Tests 2025-10-23 12:18:59 -07:00
oleibman ee03c0a467 Add Some Coverage 2025-10-21 09:58:26 -07:00
oleibman c3a78e480d Xls Reader ListWorksheetInfo and New ListWorksheetDimensions
PR #4687 corrected how Xls Writer generated its Dimensions records. We ignore the Dimensions record on read since it does not affect our processing in the slightest. However, the PR raises the possibility that someone might wish to see the data in the Dimensions record. (The PR did an adequate test for retrieving Dimensions data, but it is not generalizable.) To accommodate such a case, we add a new ListWorksheetDimensions function to Xls Reader, similar to ListWorksheetInfo. As luck would have it, the spreadsheet with which I tested the new function produced incorrect results for ListWorksheetInfo, which was ignoring XLS_TYPE_MULRK records. So I added the necessary code to fix ListWorksheetInfo as well.
2025-10-21 07:12:20 -07:00
oleibman b5ba4ffa24 Merge pull request #4655 from oleibman/issue850
Better Support For Style Alignment Read Order
2025-10-11 19:26:32 +00:00
oleibman 7c9f42e9ea Merge pull request #4676 from oziriemeka/fix/4505-vml-namespace
Xlsx: register x and o namespaces for VML shapes; add test for #4505
2025-10-11 18:38:00 +00:00
oleibman db1aba6554 Better Sample File 2025-10-09 08:19:12 -07:00
karrakoliko b8687edd53 fix: do not trigger Undefined array key "x" 2025-10-04 16:15:27 +07:00
Emeka Oziri 8fcde62db6 Xlsx: register x and o namespaces for VML shapes; add test for #4505
Fixes SimpleXMLElement::xpath(): Undefined namespace prefix when reading VML comments/shapes by registering x: (Excel) and o: (Office) namespaces alongside v:.

Includes:
- tests/PhpSpreadsheetTests/Reader/Xlsx/Issue4505Test.php
- tests/data/Reader/XLSX/issue.4505.xlsx

Refs: https://github.com/PHPOffice/PhpSpreadsheet/issues/4505
2025-10-03 23:37:56 +01:00
oleibman dbff58a532 Better Support For Style Alignment Read Order
Fix #850 (marked stale many years ago, but now reopened). User had a typo in their script which would have caused problems no matter what. However, it exposed another problem. Style Alignment Read Order was supported only by the Xlsx Reader and Writer, but it could have been supported pretty easily for most other formats. This PR adds support for the following:

- Xls (read and write)
- Html (write, and read using inline styles). Html reader does not yet process most classes.
- Pdf (write). PhpSpreadsheet does not have a Pdf reader.
- Ods (write). PhpSpreadsheet does not yet support reading most Ods styles.
- Xml (read). PhpSpreadsheet does not have an Xml writer.
- Gnumeric (no change). It appears that the Gnumeric product does not support this attribute.
- Csv (no change). Csv does not support any styles.
- Slk (no change). Slk does not support non-Latin characters, so this attribute doesn't make sense for it.
2025-09-19 14:15:05 -07:00
oleibman fff2373b39 Merge branch 'master' into issue4584 2025-09-16 23:48:50 -07:00
oleibman 31d1cd7e17 Minor Tweaks 2025-09-14 01:20:24 -07:00
oleibman 9df8ceb5c0 Minor Improvements to Reader/Writer Coverage 2025-09-14 00:18:08 -07:00
oleibman dc25bc1ac4 Coverage Tweaks 2025-09-12 00:41:14 -07:00
oleibman 5082b35709 Conditional Formatting in extLst
Fix #4629. Excel Xml can specify Conditional Formatting in 2 ways - either using a `conditionalFormatting` tag as a child of `worksheet`, or in a slightly different manner as a child of `worksheet->extLst`. Although these are both handled by PhpSpreadsheet, the former is lost if there exists a latter whose cell range (`sqref`) matches it. This PR merges the former with the latter in that circumstance, preserving both.

The issue also notes that `font` and `stopIfTrue` are not handled correctly. Support for those was missing in the `extlst` handling, and is now added with this PR.
2025-09-05 11:13:09 -07:00
oleibman 08f2f1bfd8 Merge pull request #4579 from oleibman/issue1637
Handle Google-only Formulas Exported from Google Sheets
2025-08-17 03:43:32 +00:00
oleibman f51ec365c5 Handle Google-only Formulas Exported from Google Sheets
Fix #1637, which went stale but is now re-opened. When Google Sheets exports a document to Xlsx or Ods, it replaces Google-only formulas with something that Excel or LibreOffice can handle. In the test case accompanying this PR, cell C1 on Google Sheets contains `=flatten(A1:A5,B1:B5)`. On export, C1:C10 (the actual result is a 10*1 array) are changed to `=IFERROR(__xludf.DUMMYFUNCTION("flatten(A1:A5, B1:B5)"),1.0)`, where `1.0` is replaced by the calculated value for each cell in question.

The issue reports an Internal Error when evaluating such a formula. I am unable to duplicate that. However, PhpSpreadsheet evaluates the cell as a `#NAME?` error rather than the correct value (1.0 for cell C1). The reason is that `__xludf.DUMMYFUNCTION` does not match the regexp for formulas, but does match the regexp for defined names. Not finding such a defined name results in the Name error. Altering the formula regexp to recognize `__xludf.` is easy, and solves the problem.
2025-08-10 14:45:05 -07:00
issa a3588b2c22 Add test for unsupported icon sets 2025-08-09 07:23:18 +09:00
issa 0327b49060 Added Conditional Formatting: IconSet for Xlsx (#4560) 2025-08-07 08:59:11 +09:00
oleibman b489fb3a17 Merge branch 'master' into issue4539 2025-07-21 21:23:15 -07:00
oleibman 2735c40179 StyleMerger Use Copy Of baseStyle
Using baseStyle directly can lead to the by-reference problems associated with Cell and Style.
2025-07-17 07:45:55 -07:00
oleibman a15091737f Html Writer Conditional Formatting Inline Css
Fix #4539. Conditional Formatting was recently added to Html Writer. It works fine when not using inline Css. However, when using inline Css, the code inadvertently added 2 different `style` attributes (one for the unconditional style and one for the conditional style) to the same cell. This is not valid html, and results in losing the conditional styling. This PR combines the two `style` attributes into one, which will now come after the `class`, `colspan`, and `rowspan` attributes.

Aside from the new tests, this PR changes an unusually large number of existing tests. While this might normally be considered a red flag, it is not a problem here. All of the changes involve merely changing the order of attributes within html tags; none of them affect how the generated html would appear in a browser.
2025-07-15 22:22:34 -07:00
oleibman 9708d72ee1 Ods Reader Process Nested table-row
Fix #4528. Fix #2507. Ods Reader expects `table:table-row` to descend directly from `table:table`. But it turns out that it can be nested under `table:table-header-rows`, `table:table-rows`, or `table:table-row-group`. Similar considerations apply to `table:table-column`. Ods Reader is changed to process the nesting tags, and therefore the nested tags underneath them. This is a major change, but it doesn't seem to have broken any existing tests or samples.

No attempt is made to add any of the nesting tags in Ods Writer.

It should be noted that 4528 has an additional problem, which has been reported as issue #4530. It is not fixed by this PR.
2025-07-08 12:52:55 -07:00
oleibman cadeb88d4b Xlsx Reader Do Not Process Printer Settings for Dataonly
Fix #4477. Xlsx Spreadsheet could be loaded and saved normally, but, when the load specified Dataonly, the output file was corrupt. Reader is changed to not process Printer Settings when Dataonly is in effect.
2025-05-21 19:15:20 -07:00
oleibman e6aacf72b0 Merge pull request #4466 from oleibman/issue407b
Ods Handling of Ceiling and Floor
2025-05-15 01:22:53 +00:00
oleibman 39511e03b5 Ods Handling of Ceiling and Floor
Fix #407, which went stale over 7 years ago, and is now reopened. Ods handling of CEILING and FLOOR functions is, apparently by design, subject to interoperability problems with Excel. See [FLOOR](https://wiki.documentfoundation.org/Documentation/Calc_Functions/FLOOR) and [CEILING](https://wiki.documentfoundation.org/Documentation/Calc_Functions/CEILING). Ods implements its own `CEILING.XCL` and `FLOOR.XCL` functions for interoperability purposes. PhpSpreadsheet will implement those, and `CEILING.ODS` and `FLOOR.ODS` psuedo-functions as well; none of these four will be listed in the official Functions documentation.

In all of the descriptions below, FLOOR follows CEILING exactly.

Ods writes its functions to Xml as follows:
- CEILING.XCL becomes COM.MICROSOFT.CEILING
- CEILING.MATH becomes COM.MICROSOFT.CEILING.MATH
- CEILING.PRECISE becomes COM.MICROSOFT.CEILING.PRECISE
- CEILING remains unchanged

PhpSpreadsheet Ods Writer will do the same, plus:
- CEILING.ODS becomes CEILING

PhpSpreadsheet Ods Reader will act as follows:
- CEILING (not preceded by 'COM.MICROSOFT.') becomes CEILING.ODS
- COM.MICROSOFT.CEILING.MATH becomes CEILING.MATH
- COM.MICROSOFT.CEILING.PRECISE becomes CEILING.PRECISE
- COM.MICROSOFT.CEILING becomes CEILING

PhpSpreadsheet Xlsx Writer will act as follows:
- CEILING.ODS becomes CEILING.MATH
- CEILING.XCL becomes CEILING

PhpSpreadsheet Xls Writer will recognize only the CEILING and FLOOR functions.

Note that the only difference between Ods CEILING and CEILING.MATH is that CEILING will return an error if the number and significance operands have opposite signs. PhpSpreadsheet implements this as `#VALUE!`.
2025-05-10 21:40:28 -07:00
oleibman 0245f6ba22 Removing Columns/Rows Containing Merged Cells
Fix #282, which went stale over 7 years ago, and is now reopened. This is certainly related to issue #4379. If merged cells are in the midst of deleted rows/columns, the merge may continue to exist after the deletion, leading to various problems including spreadsheet corruption. The problem is not with either Reader or Writer.

This PR will automatically unmerge all merged cells whose first cell is in the delete range before performing the deletion. This will address the corruption problem. Something more sophisticated may be required, so I won't merge this PR for a while to give me a chance to think about it some more.
2025-05-09 20:58:06 -07:00
oleibman 5c94de34a9 More Phpstan Level 10 Prep - Readers
Also upgrade Phpstan.
2025-05-03 21:18:55 -07:00
oleibman de9fdc3855 XML Reader Recognize Indents
Fix #4448
2025-04-20 16:10:50 -07:00
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 2213139d96 Merge branch 'master' into issue4416 2025-03-27 00:01:29 -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 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 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 01539876b1 Merge branch 'master' into issue4375 2025-02-23 12:28:17 -08: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
oleibman 2b7e6f50a2 Ignore ignoredErrors when Not Applicable
Fix #4375. Do not set ignoredErrors when using readDataOnly, not when the cell to which it applies doesn't exist.
2025-02-19 19:15:01 -08:00
oleibman ae6c92b006 More Tests 2025-02-17 22:45:05 -08:00
oleibman 8930e634a1 Add Some Tests 2025-02-17 17:58:17 -08:00
oleibman 9b07be9a0f Add sheetState to ListWorksheetInfo Data
Fix #4345. Add a new item to the output array. Although the output is changed, this does not seem like a breaking change to me.
2025-02-14 23:40:50 -08:00
oleibman eafbed6ca8 Merge pull request #4314 from oleibman/issue4312
CF Priority Property and Overlapping Ranges
2025-02-04 04:35:13 +00:00
oleibman cfc8b8c26f Merge branch 'master' into issue797 2025-02-03 17:50:15 -08:00
oleibman cde2926a9e Merge commit from fork
* Security Patch

Control characters should not be allowed in protocol.

* Tighten Up Drawing

* Fix Test
2025-01-23 21:25:36 -08:00
oleibman 8d7500b1e2 Merge branch 'master' into issue4312 2025-01-21 19:58:05 -08:00
oleibman 41ca105c88 Handle Overlapping Ranges
Fix #4318. Also make getConditionalStyles more useful, by adding a non-default parameter so that all rules pertaining to a single-cell coordinate can be returned, and in priority order. By default, just the first matching rule will be returned.
2025-01-14 20:57:55 -08:00
oleibman 07fbe9a1fc Merge branch 'master' into issue797 2025-01-11 22:51:54 -08:00
oleibman 56e7422bba Add "Priority" Property for Conditional Formatting
Fix #4311. Excel applies Conditional Formatting rules according to a priority specified in the xml. The priority must be a natural number; the rules are applied in order from lowest priority number to highest. When reading an Xlsx spreadsheet, PhpSpreadsheet has been ignoring the priority, which can result in differences from Excel's behavior, especially when CF cell ranges overlap (note that overlapping ranges are not supported in Xls format).

If an application uses PhpSpreadsheet to add new Conditional Formatting to a worksheet and does not change its priority from the default (0), the Xlsx Writer will assign a priority with a higher value than any of the CF objects which have been assigned a priority (either from reading it or explicitly assigning it).
2025-01-11 17:31:52 -08:00
oleibman f25502d704 Merge branch 'master' into groupby 2025-01-08 14:53:51 -08:00
oleibman 270695ae06 Merge branch 'PHPOffice:master' into issue4280 2024-12-30 16:31:46 -08:00
oleibman 38c4ce4836 Additional Coverage For Xml Reader
No source code changes.
2024-12-30 10:40:01 -08:00