Commit Graph

2468 Commits

Author SHA1 Message Date
oleibman ef440dd714 Merge commit from fork 2026-11-01 01:23:38 -07:00
oleibman 636eb70272 Merge commit from fork 2026-10-31 20:56:58 -07:00
oleibman 32ad31dad1 Merge pull request #5072 from n3crosis/fix/agile-encryption-xml-scanner
Scan Agile EncryptionInfo XML before parsing
2026-11-01 03:33:08 +00:00
oleibman a845ef2427 Merge commit from fork 2026-10-31 17:03:50 -07:00
^^ cca3cb94fa Scan Agile EncryptionInfo before XML parsing 2026-10-24 11:47:26 +08:00
oleibman 9565757138 Reorganize Samples and Improve Downloader Class
A follow-on activity to PR #5061. That PR added scrollbars to the dropdown lists when samples were run in a browser. Earlier changes had broken up a number of categories into multiple entries because the dropdown lists were too long and wound up truncated. With the scrollbars, it makes sense to re-consolidate many of those lists, such as ComplexNumbers, which are all essentially the same test as each other. Some break-ups are retained (e.g. Basic/1/2/3/4/5) because they differ substantially from sample to sample; that's kind of an arbitrary decision, but it will have to do for now. I also renamed some of the members so that like members sort together when listing the directory (e.g. all pivot table samples now start with `pvt`). The sample code is mostly unchanged; only the directory and/or member names are changed.

The download samples were moved to their own new directory, and now represent a complete set of all the write formats that we permit. Studying their code, an improvement for `Helper\Downloader` became evident. It had been used merely to copy an existing file to be downloaded. However, by changing the first parameter of `download` to be either the name of the file directory (the existing usage) *or* a `Writer` object poised to issue `save`, you can use it to download your spreadsheet without having to worry about the headers which the browser requires. It then becomes generally useful beyond being used in samples:
```php
$writer = new WriterType($spreadsheet);
$downloader = new Downloader($writer, 'suggestedFileName.xlsx');
$downloader->download();
```
2026-10-22 13:22:48 -07:00
oleibman 35e1009836 Merge pull request #5054 from oleibman/libxmlbreak2
Breaking Changes in libxml Affecting Helper\Html and Reader\Html
2026-10-19 02:31:21 +00:00
oleibman 4ecc20fc05 Merge branch 'master' into fix-branch-pruning-nested-if-condition 2026-10-18 19:25:53 -07:00
oleibman 98ba31713d Merge branch 'master' into wmf 2026-10-18 19:14:23 -07:00
oleibman 89e4fbda9c Merge branch 'master' into fix-remove-column-a 2026-10-17 20:40:04 -07:00
oleibman 07ee137b63 Merge pull request #5048 from BoussonKarel/fix-5047-dv-remove-row-column
Take removed rows/columns out of data validation ranges
2026-10-18 03:20:43 +00:00
oleibman 9485d5a99f Merge pull request #5046 from dkulyk/ods-formula-no-precalc
Ods Writer : No cached value for a formula that is not pre-calculated
2026-10-18 02:50:36 +00:00
oleibman 8a60a5df51 Merge branch 'master' into fix-right-longer-than-text 2026-10-17 01:21:59 -07:00
oleibman f0e66c28da Adjust LIBXML_VERSION Test 2026-10-17 01:01:48 -07:00
oleibman 273fb576a7 Adopt @dkulyk's Suggestion
Drop LIBXML_HTML_NOIMPLIED. Much cleaner, at least as effective.
2026-10-17 00:20:24 -07:00
oleibman e4f74569fd Found a Reproducible Difference
Use it rather than version number to test if libxml loadHtml is buggy.
2026-10-16 15:51:14 -07:00
Dmytro Kulyk 537c856d49 Ods Writer : No cached value for a formula that is not pre-calculated
With setPreCalculateFormulas(false) the formula text was written as the
value of the cell (office:string-value and text:p), and LibreOffice showed
it as the result. The cell now has table:formula alone, as the Xlsx Writer
writes <f> without <v>, so the application that opens the file calculates
it. A hyperlink of the cell is still written.

Ods Reader applied a style only to a cell with content or with a cell
after it, so such a formula cell at the end of its row lost its style;
a cell with a formula now keeps it.
2026-10-16 23:34:53 +03:00
oleibman f375a76fb3 Merge branch 'master' into document-language 2026-10-16 13:18:00 -07:00
oleibman 1495e65cdc Merge branch 'master' into chart-alt-text 2026-10-16 13:07:35 -07:00
oleibman 26c227037f Merge pull request #5037 from dkulyk/drawing-decorative
Xlsx, Ods and Html Reader and Writer : Decorative images
2026-10-16 19:59:38 +00:00
HawkForge a7dbf35f62 Fix branch pruning for IF nested in the condition of a pruned IF
When an IF sits in the condition of another IF, BranchPruner only
looked at the immediately enclosing IF to decide which branch the
condition tokens depend on. If that enclosing IF was itself still in
its condition, nothing was recorded, so the link to an outer IF whose
branch is being pruned was lost. Those tokens were then evaluated and
left on the stack while the rest of the branch was pruned, and the
calculation ended with "internal error".

Walk up the stack of enclosing IFs to the closest one whose then or
else branch contains the nested IF instead.

Fixes #3790
Fixes #3755
2026-10-16 20:36:20 +06:00
Progi1984 9d09ae0c31 Support for Windows Metafiles images (WMF, EMF and EMF+) 2026-10-16 07:02:20 +02:00
oleibman 7e4c6bf83b Merge branch 'master' into fix-remove-column-a 2026-10-15 17:45:56 -07:00
oleibman 8dcba68ab3 Merge branch 'master' into fix-5047-dv-remove-row-column 2026-10-15 17:45:17 -07:00
oleibman 9ce8dea874 Breaking Changes in libxml Affecting Helper\Html and Reader\Html
These have made it to the nightly Php8.6 for Windows, though it hasn't yet affected that release on Github Ubuntu.

- A string like `xyz` has historically been treated as if it were `<p>xyz</p>` by `Dom->loadHtml()`. No more - recent changes cause it to be dropped altogether, treating it as an empty string.
- `Dom->loadHtml()` seems to have stopped issuing warning messages altogether, so there is no longer any clue that anything untoward has happened.
- There seem to have been some changes regarding how line endings are generated.
- There are doubtless other differences that I haven't stumbled upon yet.

Documentation on these changes is available at https://gitlab.gnome.org/GNOME/libxml2/-/work_items/211

Php says there's nothing they can do about this. Their recommendation is to move to the new Dom\HTMLDocument class. Which is a fine idea, except that we still need to support Php 8.2 and 8.3, and the new class wasn't introduced until Php 8.4. So this PR kludges up our code a bit to use the existing code for libxml releases before the one where these problems were discovered, and the new class for later releases. I think, or at least hope, that this is safe - I don't think the problematic libxml release will be applied to anything earlier than Php8.6.
2026-10-14 11:28:50 -07:00
oleibman e59617c899 Another Test 2026-10-12 20:32:30 -07:00
oleibman 85606d69df Fix Numeric String Comparisons 2026-10-12 18:51:07 -07:00
oleibman e95a97b6f6 Merge branch 'master' into fix-comparison-type-ordering 2026-10-12 14:33:00 -07:00
oleibman 68645cbf34 Add Some Tests 2026-10-12 11:55:46 -07:00
oleibman 09a318952c Merge branch 'master' into fix-countif-boolean-criterion 2026-10-12 10:14:11 -07:00
Dmytro Kulyk 32e444162c Html Reader and Writer : The language is the lang of the html element 2026-10-11 17:34:46 +03:00
Dmytro Kulyk b88a7eb3c3 Xlsx and Ods Reader and Writer : Document language
Properties gains a language (a BCP 47 tag), written as dc:language to
Xlsx core.xml and Ods meta.xml and read back from both. Screen readers
and spell checkers use it to pick the voice and the dictionary.

LibreOffice ignores dc:language for the text and keeps a spreadsheet's
language on the default cell style, so the Ods writer puts it there as
LibreOffice does: in the Western, Asian or complex slot by script, with
style:rfc-language-tag for a tag that fo:language and fo:country cannot
hold. The Ods reader falls back to that style when meta.xml has no
dc:language, as in the files LibreOffice saves.
2026-10-11 17:34:46 +03:00
Dmytro Kulyk 3b297c2421 Html Reader and Writer : A decorative image is an empty alt 2026-10-11 17:34:44 +03:00
Dmytro Kulyk 1e7c380677 Read the decorative flag of ODF 1.4 and with readDataOnly
ODF 1.4 has draw:decorative in the graphic properties, besides the
loext:decorative LibreOffice writes. The flag is now read even with
readDataOnly, which still loads the drawings: a decorative image read
that way was saved as a figure without alternative text.
2026-10-11 17:34:44 +03:00
Dmytro Kulyk 98f938fbe6 Xlsx and Ods Reader and Writer : Decorative images
An image that only decorates had no way to say so, and was tagged in a
PDF as a figure without alternative text. Excel and LibreOffice mark it
decorative, and LibreOffice leaves it out of a tagged PDF as an artifact.

BaseDrawing::setDecorative() is written and read in the forms Excel and
LibreOffice use: in Xlsx, adec:decorative in an extension of the image's
cNvPr; in Ods, loext:decorative in the frame's graphic style. The Ods
writer now defines the graphic style its frames named but never wrote.
2026-10-11 17:34:44 +03:00
oleibman c04c2e56b9 Merge branch 'master' into issue5032 2026-10-09 12:05:36 -07:00
oleibman 35b6826efa Merge branch 'master' into fix/ole-pps-conformance 2026-10-09 11:27:32 -07:00
oleibman 845d708486 Merge pull request #5005 from guy-black-box/fix-min-max-literal-text
MIN and MAX: count logical values and numeric text typed as arguments, error on other text
2026-10-09 17:51:11 +00:00
Karel Bousson 7ff49af244 Fix removeColumn() throwing when it removes column A
The loop at the end of Worksheet::removeColumn() removes the leftover
columns from the highest data column leftwards. After each removal it
computed the column to its left, also after the last one, so when the
last column removed was A it called stringFromColumnIndex(0), which
throws "Invalid column index 0". This happened for removeColumn('A', n)
whenever n reached the highest data column, including a plain
removeColumn('A') on an empty sheet, and left the worksheet
half-updated because ReferenceHelper had already shifted the cells.

Loop over the column index instead, so no column left of A is ever
computed. removeRow() already steps down with an integer and is not
affected.

Fixes #5049

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 14:40:01 +02:00
Karel Bousson 77fbb61077 Take removed rows/columns out of data validation ranges
When removing columns or rows, ReferenceHelper::adjustDataValidations()
only shifted the addresses after the removed columns/rows. It never took
the removed columns/rows themselves out of a validation range. So a
validation that lay only on a removed column/row kept its address and
then applied to the column/row that slid into its place, and a range
that ended on a removed column/row kept its size and covered one extra
column/row.

Ranges are now adjusted like Excel does: the removed columns/rows are
taken out of every part of the sqref, a part left empty is dropped,
and a validation with no parts left is deleted. Whole column (B:C) and
whole row (2:3) ranges are supported. Insertion is unchanged.

Fixes #5047

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 14:28:59 +02:00
oleibman b3511404e0 Merge pull request #5043 from oleibman/realpath
File::realpath should not issue file_exists
2026-10-08 06:59:14 +00:00
kevin9327 d767ea2336 RIGHT: return all of the text when asked for more characters than it has
RIGHT("abc",5) returned "bc" because the start offset went negative and
mb_substr then counted it from the end of the string. Excel returns the
whole text when num_chars is greater than its length, so clamp the offset
at 0.
2026-10-05 12:32:24 +09:00
oleibman 2527575636 Bounded Ranges on Missing Sheet
@dkulyk noticed a case which wasn't handled properly. I believe the fix works for everything ... except `COLUMNS` and `ROWS`, where Excel seems to ignore the sheet, and I just can't figure out how to do it.
2026-10-04 20:24:47 -07:00
oleibman 5b5b12647e File::realpath should not issue file_exists
Fix #5042. `Shared\File::realpath` is used to normalize file name references in a zip file. It can be used for non-zip file names as well, but zip members is its primary use, and `file_exists` does not work with zip file members. Such usage leads to the issue to which this PR is linked, and there have been other instances in past. In particular, issue #3553 was addressed by editing it out a leading slash in such references; it is not needed, and neither Excel nor PhpSpreadsheet generate one, but it's legal. The fix for 3553 addressed only loading a spreadsheet; but `listWorksheetInfo` and `listWorksheetNames` are subject to the same problem, which is this issue.

The normalization that `realpath` does is already built into `File::realpath` using a well-documented algorithm. So neither `filepath` nor `file_exists` is needed there, and they are removed. There are other problems with the current implementation. It looks only for Unix, not Windows, file separators. And a very peculiar problem arises when the zip entry name matches a file path in the current working directory. These problems all go away with this PR.

It is very likely that some manipulation of the zip entry names can be removed entirely from `Reader\Xlsx`. I may look into this in future, but I'm not going looking for trouble now. The fix for 3553 remains in place, even though no changes are made to match it in `listWorksheet...`, so, chances are the 3553 change could be dropped. As I say, maybe some day.
2026-10-04 16:16:38 -07:00
Dmytro Kulyk 0cef9c2a13 Xlsx Reader and Writer : Chart description as alternative text
A chart's frame had no descr and was always named "Chart N", so a chart
written by PhpSpreadsheet had no alternative text: LibreOffice exports
the frame's descr as /Alt of the chart's /Figure in a tagged PDF, and
Excel shows it as the chart's alt text.

Chart::setDescription() is written as descr of the frame, which now also
takes the chart's name, and is read back from all three anchor types.
The reader keeps naming a chart after its part file, which
getChartByName() callers rely on.
2026-10-04 03:53:20 +03:00
oleibman ad62b91558 Merge pull request #5023 from dkulyk/ods-table
Ods Reader and Writer : Tables as named database ranges
2026-10-04 00:05:01 +00:00
oleibman bb904a2e23 Merge branch 'master' into fix-xls-palette-color-index 2026-10-03 16:53:48 -07:00
oleibman b67630b614 Merge pull request #5018 from dkulyk/ods-style-hyperlink
Ods Reader : Read the hyperlink LibreOffice keeps in a cell style
2026-10-03 23:47:05 +00:00
oleibman ebfea1db9b Merge pull request #5016 from dkulyk/ods-sheet-rtl
Ods Reader and Writer : Keep the direction of a right-to-left sheet
2026-10-03 23:39:00 +00:00
oleibman 9278e8c146 Don't Iterate Cell Ranges on Non-existent Sheets
Fix #5032. When evaluating formulas, stop iterating a cell range when the sheet on which the range is located does not exist.

While testing, discovered some commented-out tests in `ParseFormulaTest`, having nothing to do with this change, that could now be commented back in.
2026-10-03 07:57:58 -07:00