1965 Commits

Author SHA1 Message Date
oleibman 030ece8666 Merge branch 'master' into listdimensions 2025-10-23 17:36:09 -07:00
oleibman 02090c1d3f Another Test 2025-10-23 17:07:26 -07:00
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
Nebojša Zlatanović adde74b4e6 Fix DIMENSIONS record to use 0-based indices for both rows AND columns
The initial fix only converted column indices to 0-based, but overlooked
that row indices also need the same treatment per BIFF8 specification.

Changes:
- Convert firstRowIndex from 1-based to 0-based (subtract 1)
- Convert lastRowIndex from 1-based to 0-based (subtract 1)
- Update row capping logic for 65536 limit
- Fix test assertions to expect rwMic=0 and rwMac=5 (not 1 and 6)
- Enhanced documentation to clarify all DIMENSIONS indices are 0-based

This now matches the behavior observed in Excel-generated XLS files,
where a file with 3 rows × 5 columns shows: rwMic=0, rwMac=3, colMic=0, colMac=5

All tests pass (53 tests, 244 assertions).
2025-10-20 09:07:39 +02:00
Nebojša Zlatanović f2ea8b6cb9 Fix PHPStan type safety issues in DimensionsRecordTest
Add proper type assertions to handle potential false returns:
- Assert file_get_contents() returns string, not false
- Assert strpos() returns int, not false
- Assert unpack() returns array, not false

This resolves all 7 PHPStan errors reported in CI while maintaining
test functionality (12 assertions, all passing).
2025-10-17 13:35:12 +02:00
Nebojša Zlatanović b9857e53d5 Improve DIMENSIONS record fix with better code coverage and unit tests
This commit refines the BIFF8 DIMENSIONS record fix by:

1. **Optimized column index capping**: Replaced the if-statement with min()
   function to ensure lastColumnIndex never exceeds 255, improving code
   coverage and eliminating unreachable branches in unit tests.

2. **Added comprehensive unit tests**: Created DimensionsRecordTest.php which
   directly parses the binary DIMENSIONS record (0x0200) from XLS files to
   verify correct 0-based column indices.

The tests validate:
- colMic (first column) = 0 for column A (was incorrectly 1 before fix)
- colMac (last column + 1) uses proper 0-based indexing
- Column indices are correctly capped at 255 (BIFF8 limit)

These tests fail without the fix and pass with it, ensuring the DIMENSIONS
record is correctly written for compatibility with legacy XLS parsers that
expect 0-based column indices per the BIFF8 specification.
2025-10-17 13:26:55 +02:00
oleibman fba2a43c8c Merge branch 'master' into issue4673 2025-10-12 15:21:52 -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 d52dbaa632 Merge pull request #4666 from oleibman/tcpdfnodie
Offer Tcpdf Interface Which Throws Exception Rather than Die
2025-10-11 18:47:10 +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 08a6e7549f More Sophisticated Workbook Password Algorithms (Xlsx only)
Fix #4673. Our password hasher can handle different algorithms, but the workbook password (for maintaining the structure of the workbook, not for encrypting the entire workbook) currently supports only the single algorithm that was in place many years ago. Expand it, and Xlsx Reader and Writer, to be able to use, say, SHA-512, which is what Excel itself uses.

The revisions password needs to be expanded in the same way as the workbook password. It is used for file sharing, but MS has deprecated it because it feels that modern technologies introduce better ways to accomplish what it was needed for. You'll need to look pretty hard to even find it in Excel - it's not, for example, on any of the ribbons. Nevertheless, the solution here is pretty much identical to the solution for the workbook password, so I am fixing it at the same time.
2025-10-03 13:07:36 -07:00
oleibman b1c5c64060 Tweak 2025-09-30 07:33:04 -07:00
oleibman a1ffd3473b Offer Tcpdf Interface Which Throws Exception Rather than Die
By default, TCPDF will die sometimes rather than throwing exception. And this is controlled by a defined constant in the global namespace, not by an instance property. Ugh! Using this class instead of the class which it extends will probably be suitable for most users. But not for those who have customized their config file. Which is why this isn't the default, so that there is no breaking change for those users. Note that if both TCPDF and TcpdfNoDie are used in the same process, the first one used "wins" the battle of the defines.
2025-09-29 22:25:20 -07:00
oleibman 0650e78474 Merge branch 'master' into issue850 2025-09-25 09:27:10 -07:00
oleibman 8c70086f0e Html Better Support for Indent 2025-09-20 15:26:49 -07:00
oleibman 9601d879c8 Fix Typo 2025-09-19 14:23:10 -07: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 684c677937 Document NumberFormat Wizard Dependency on Intl Extension
Intl is only a "suggested" extension. A lot of the NumberFormat Wizard code depends on it. That's insufficient reason to make it required, but the suggestion text now mentions this dependency explicitly. Also clean up the Wizard documentation to reflect some changes since PhpSpreadsheet 1.28.
2025-09-17 23:04:31 -07:00
oleibman 9c8f83fcbf Merge pull request #4649 from oleibman/mpdford
Temporary Workaround for Mpdf Php8.5 Deprecation
2025-09-17 17:01:56 +00:00
oleibman a76c9b82cd Upgrade Mitoteam to Beta Version
I had been trapping its errors in test bootstrap, but that no longer seems to work.
2025-09-17 09:42:23 -07:00
oleibman fff2373b39 Merge branch 'master' into issue4584 2025-09-16 23:48:50 -07:00
oleibman 26dfae12e8 Merge branch 'master' into intersect 2025-09-16 17:50:18 -07:00
oleibman 9bb090d64e Found an Untested String Increment Operator 2025-09-16 13:00:09 -07:00
oleibman acba6d1f4a Additional Test 2025-09-16 11:22:05 -07:00
oleibman 07150fc530 Didn't Like My Approach In 2 Places 2025-09-16 10:35:32 -07:00
oleibman 8e4ebd97e1 Final Tweak (I Think) 2025-09-15 21:29:46 -07:00
oleibman f3e2eba517 Additional Coverage 2025-09-15 19:48:43 -07:00
oleibman abf357ea90 1904 Calendar 2025-09-14 08:08:46 -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 38cf7ed656 Merge branch 'master' into lessprecise 2025-09-13 07:36:24 -07:00
oleibman dc25bc1ac4 Coverage Tweaks 2025-09-12 00:41:14 -07:00
oleibman 77eaac2e79 Merge branch 'master' into wakeup 2025-09-11 21:21:49 -07:00
oleibman c07675a59c Merge pull request #4641 from oleibman/issue4638
Proper Output for BASE Function
2025-09-12 03:29:16 +00:00
oleibman 2d9375f847 Wrapped Cells and Default Row Height
Fix #4584. As discussed there, MS has implemented this situation in a way that I frankly do not understand. Marking a row with a wrapped cell to *not* use the default row height seems to affect every other populated row. Very odd. Nevertheless, adding a new `customFormat` boolean property to RowDimension seems to be a way to resolve this problem. Note that the Xml generated by Excel already outputs a `customFormat` attribute when a style is applied to a row. This PR just adds that property for when it is needed for rowHeight. It need not, and should not, be set by the application when a style is applied to the row; PhpSpreadsheet will take care of that on its own.

Although the problem was raised for Xlsx format (I think), I investigated other relevant output formats as well. Html tends to do its own cell wrapping. I think the results after this change match the results before.

Xls already handled the output side of this situation without difficulty. A change was needed on the input side, and is included as part of this PR.

Ods did not handle default row height at all. As with other style properties, it is difficult to handle this on the input side, and this PR does nothing to improve that situation. However, we are, at least, able to provide some relief on the output side. Not complete relief - in order to apply the default size to unpopulated rows, we'd need to at least populate them with the `table:number-rows-repeated` attribute, and that has often been a source of problems, so I'm not willing to go there yet. This PR just ensures that all populated rows will have the correct height.
2025-09-11 20:13:21 -07:00
oleibman 9b28b9e9c1 Merge pull request #4644 from oleibman/phpstan2123
Upgrade Phpstan
2025-09-12 03:08:23 +00:00
oleibman 4b8f4e8d66 Upgrade Phpstan
A lot of changes since its last update, including one that I requested.
2025-09-11 20:02:57 -07:00
oleibman 43754a130e Bug in Uncovered Code in XMLWriter
Add test, fix bug.
2025-09-10 08:19:57 -07:00
oleibman f19a73fdd6 Proper Output for BASE Function
Fix #4638. Microsoft does not document BASE as being introduced in Excel 2010 or later, but apparently it was.
2025-09-10 07:34:50 -07:00
oleibman ebdbdd41ba Option To Display Numbers With Less Precision
Fix #4626. Previous changes had increased the precision of floating point numbers when cast to string, making for greater accuracy after save and load operations, without affecting the values displayed by Excel. Although the results of the cast are now more accurate computationally, they can appear unexpected to humans. A new boolean parameter `lessFloatPrecision` (defaulting to false) is added to `StringHelper::convertToString`, to `NumberFormat::toFormattedString` and `NumberFormat\Formatter::toFormattedString`, and to the entire `Worksheet::toArray` family of functions. When the new parameter is set to true, the result can be less surprising to humans. It should not, however, be used in subsequent computations.

In the case of the NumberFormat functions, the new parameter will be considered only when the NumberFormat for the cell in question is `General` or equivalent. Setting an actual numeric format for the cell is probably a better solution than using the new parameter.
2025-09-10 00:32:26 -07:00
oleibman 00191100ba Deprecate Worksheet::getHashInt and Spreadsheet::getId
Php8.5 *may* deprecate the use of `__wakeup` (it is planned, but not yet implemented, and it is convtroversial). We use it only twice. In the first instance, it just throws an exception to prevent a security exploit. This can be trivially replaced with `__unserialize`.

The other instance is merely to initialize a Worksheet instance variable. Converting this use to `__unserialize` is *not* trivial (one of the reasons for the controversy). However, I see no useful purpose for that variable. Since it has no use, there is no real need for `__wakeup`, so we will just remove the routine altogether, and deprecate the variable's getter (there is no setter).

A similar instance variable in Spreadsheet also serves no useful purpose, so we will deprecate its getter as well (again no setter).
2025-09-10 00:27:22 -07:00
oleibman 3ace47ad4d Merge branch 'master' into issue4629 2025-09-07 00:37: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 b7d48e687d More Minor Tweaks 2025-09-05 10:28:48 -07:00
oleibman eec235765c Merge branch 'master' into calccov 2025-09-05 00:46:28 -07:00