281 Commits

Author SHA1 Message Date
oleibman afc0e9c225 Changes to WEBSERVICE R390 (#4755) 2025-12-22 22:01:12 -08:00
oleibman a72b206950 Merge branch 'master' into crstyle 2025-01-19 20:45:42 -08:00
oleibman c878fa174f Merge branch 'master' into crstyle 2025-01-13 20:19:10 -08:00
oleibman 0fe14cfd5e Update recipes.md 2025-01-13 20:18:15 -08:00
oleibman 7c1a65e17c Add Spreadsheet Method for Duplicating Worksheet
Cloning a worksheet attached to a spreadsheet creates a clone which is detached from the spreadsheet. This can have its uses, but I think it would also be useful to have the ability to duplicate the worksheet and keep the duplicate attached to the spreadsheet. You can do that in Excel and LibreOffice, and you can now do it in PhpSpreadsheet as well. The duplicated worksheet will come immediately after its source.

The worksheet being duplicated could be identified in a number of ways - by passing the worksheet itself to the new method, by passing the worksheet title, or by passing the index of the worksheet within the spreadsheet. For now, I am just implementing the one I think is most useful (title).
2025-01-11 22:20:40 -08:00
oleibman f25502d704 Merge branch 'master' into groupby 2025-01-08 14:53:51 -08:00
oleibman c58a8e37bc Merge pull request #4289 from oleibman/doc4285
Document Styling Whole Columns and Rows
2025-01-03 01:23:55 +00:00
oleibman 872dfd4714 Merge branch 'master' into choosecols 2024-12-30 19:53:49 -08:00
oleibman 2c95ec3bc8 Document Styling Whole Columns and Rows
Fix #4285. Documentation change only - no changed code. It is not clear to me why using individual set options when styling an entire column works differently than applyFromArray, but the latter produces the expected result and the former doesn't. I will continue to research why. However, in the meantime, we can at least document that applyFromArray is preferred for this operation.
2024-12-26 23:07:30 -08:00
oleibman ee7ddf7ca8 CHOOSECOLS, CHOOSEROWS, DROP, TAKE, and EXPAND
These are 5 closely related functions for manipulating arrays. Now that dynamic arrays are part of PhpSpreadsheet, this PR implements those previously-unimplemented functions. Documentation undergoes a very minor change, since they are re-categorized as "Lookup and Reference", which is how Excel classifies them, rather than "Math and Trig".
2024-12-22 09:00:33 -08:00
oleibman 9fc8e501b8 Extremely Limited Support for GROUPBY Function
This is a partial response to issue #4282. The actual logic to implement GROUPBY is probably very complicated. And, even worse, Excel has thrown a whole new way of (internally) specifying one of the arguments into the mix. That argument is a function name, expressed not as a mapped integer (as SUBTOTAL does), nor even as a string, but as the unquoted function name prefixed by `_xleta.`. And, unlike its `_xlfn.` and `_xlws.` predecessors, it is difficult to figure out when the new prefix needs to be added, and when it needs to be ignored. I am not even going to attempt that task with this ticket.

So, what does this change do? Like earlier attempts to introduce limited functionality (such as with form controls), it is there so that using GROUPBY can be passed through - you can load a spreadsheet that contains it, and save it to a new spreadsheet, and the function and its results are preserved. Some cautionary notes. Dynamic arrays must be enabled (the function makes no sense without doing that). Changing any of the inputs used in the function may result in internal inconsistencies between PhpSpreadsheet and Excel; this is especially so if the dimensions of the returned array change as a result of changes to the input data. The programmer can avoid some of these problems by changing the formulatAttributes of the cell where the function is used; this may be difficult to do in practice. Oh, yes, using the GROUPBY cell as an argument in another formula will probably lead to problems. Finally, I confess that part of this solution looks awfully kludgey to me.

With its limitations and those cautions, is it worth proceeding with this change? My gut feel is that it is more useful to proceed than not. However, I will give others the opportunity to weigh in. I will wait at least a couple of weeks into the new year before proceeding with this.
2024-12-18 17:28:36 -08:00
oleibman 08c5ff071b Add forceFullCalc Option to Xlsx Writer
Fix #4269. In response to issue #456 PR #515, `forceFullCalc` was added to workbook.xml whenever `preCalculateFormulas` was set to false. It is not clear why this should have been needed; attempts to reproduce the error in the original 6.5-year-old issue are unable to reproduce it today. Nevertheless, it is, or was, there for a reason.

Today, the forceFullCalc option sets an option where formulas *might* not be recalculated when a cell used in the formula changes. I have not succeeded in finding a situation where it doesn't automatically recalculate, but it probably exists on complicated spreadsheets. To overcome this possibility, Excel offers a button which can be used to recalculate on demand. By itself, this might not be a terrible problem. However, it seems to come with the strange property that any spreadsheets opened at the same time as a forceFullCalc spreadsheet operate as if they too specified forceFullCalc. That *is* a problem, especially since users when closing a spreasheet affected in this way will be prompted to save it even when they haven't changed anything.

I am not willing to make a BC change at this time, although I might consider it in future (PR #4240). For now, I am adding a new property `forceFullCalc` with setter (no getter needed) to Xlsx Writer. That property can be `null` (default, in which case the Xml attribute is set as today), or `false` or `true` (in which case the Xml attribute will be set to the Writer attribute). I think that, when `preCalculateFormulas` is set to false, the calling application should give consideration to setting `forceFullCalc` to false as well. All other situations should just use the default.
2024-12-11 04:37:05 -08:00
Blacknife 1fe3626dac fix Conditional formatting a cell documentation 2024-11-23 11:12:34 +03:00
oleibman 9ab866f409 Ignore Settings::libXmlLoaderOptions
Having addressed several security advisories, one evident *theoretical* problem remains. This is an attempt to future-proof our code against similar vulnerabilities. It all begins with our implementation of libXmlLoaderOptions, which uses as a default LIBXML_DTDLOAD. This unfortunate choice opens us to XXE problems, many recently solved. I do not believe that there is a legitimate use case for allowing this, and will therefore ignore and deprecate that option.

Although this might seem to be a breaking change, it is not. The setting is used only after the Xml has been subject to a security scan, and the security scan throws an exception if it detects the use of `<!DOCTYPE` within the Xml. Therefore, the setting will be effective only on Xml which does not contain that tag, and will consequently have no effect on most Xml. The only exception would be Xml which has been crafted to avoid detection by the security scanner in a manner which has not been disclosed to us. Although we hope that we've now blocked all such avenues, this provides additional protection just in case.

With this change in place, we could relax certain restrictions, e.g. the use of EBCDIC or even UTF-7. For now, these will remain in place. I will need to be convinced that there is a legitimate use case for easing the restrictions before doing so. We might even consider the elimination of the Security Scanner altogether. However, it does allow for early detection, and, in any case, provides a method to correct Xml which most Xml readers would fail but which Excel accepts.

My plan is to merge this within the next few days, and tag a new release immediately after. It will also be backported to all active branches.
2024-11-18 22:28:35 -08:00
oleibman 9fe3d71518 Merge branch 'master' into valuebinder 2024-10-09 17:34:48 -07:00
oleibman 1b64b42481 Add Dynamic valueBinder Property to Spreadsheet and Readers
Fix #1395, a 2020 issue which had been marked stale and is now re-opened. Static valueBinder property of Cell isn't ideal. It would be more flexible to make it a dynamic property of the spreadsheet. Static property will continue to be used, but dynamic property will be used first if it is set. Readers will also be changed to add a valueBinder property which they pass to the spreadsheet; however, it will make a difference only for Csv/Html/Slk, since the other readers use setValueExplicit which ignores valueBinder.

Documentation is updated in several places to note that dynamic property is preferred over static.
2024-10-05 23:59:44 -07:00
Guillaume dd56df2b23 🗑️ Deprecate IReader::SKIP_EMPTY_CELLS
This is an alias to `IGNORE_EMPTY_CELLS` there is no point to have both.
2024-09-10 23:30:13 +02:00
oleibman e1dae99a70 Merge pull request #4141 from oleibman/svbignoreerrors2
String Value Binder Allow Setting "Ignore Number Stored As Text"
2024-08-24 23:46:49 +00:00
oleibman 0152f57e44 String Value Binder Allow Setting "Ignore Number Stored As Text"
When String Value Binder converts a numeric value to text, the resulting spreadsheet will be full of little green triangles to indicate to the end user that something might be wrong. It is unlikely that a spreadsheet created in this manner needs that visual clutter. This PR adds a property and setter (I can't really think of a good use case for a getter) to suppress it. Suppression should arguably be the default, but, for now, I will avoid any BC problems by leaving non-suppression as the default.
2024-08-13 14:36:45 -07:00
murongshaozong ef34a8680a chore: remove repetitive words
Signed-off-by: murongshaozong <netease163@icloud.com>
2024-08-13 15:05:26 +08:00
oleibman e5e6bde299 Update Changelog and Docs Prior to Merge Next Week
This will, I hope, be my last change prior to merge on August 7. PR is fully synced with master (except for this change), and, except for an emergency, I do not intend to merge anything else before this.
2024-08-02 10:48:13 -07:00
oleibman 312cd5a6a0 Merge branch 'master' into atsign 2024-07-23 06:25:08 -07:00
oleibman b00dd47c28 Instance Variable for Array Return Type
Till now we have used a static variable/getter/setter to decide what type of result should be returned when a formula is evaluated and an array is the result. This is messy; it would be much better to use an instance variable instead. We cannot eliminate `setArrayReturnType` and `getArrayReturnType` because that would be a BC break. I am considering whether they should be deprecated. In the meantime, I have added a new instance property `instanceArrayReturnType` with getter and setter methods. The property is initially null, and, if it remains so when needed, the static property will be used instead. However, if it is set, its value will be used.
2024-07-10 09:19:51 -07:00
oleibman f6823c79e8 More Doc Updates 2024-07-06 20:26:15 -07:00
oleibman 98ba95eac1 Update features-cross-reference.md 2024-07-04 20:36:29 -07:00
oleibman 2897c4de33 Missed One Doc Change 2024-07-04 20:18:25 -07:00
oleibman 7d8bec828b Documentation Updates
Mostly in response to issue #3961, which noted some discrepancies, both positive and negative, between documentation and reality concerning ODS support.
2024-07-04 20:06:17 -07:00
oleibman edf7f71e2a Merge branch 'master' into atsign 2024-06-30 00:28:18 -07:00
oleibman e8bb091f3b Merge branch 'master' into pr1415 2024-06-29 19:32:02 -07: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
oleibman ef2b5b9e00 Mostly Docs and Tests
Also support for Xml format.
2024-06-21 21:55:05 -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
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 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 0f515eee0b Xls Conditional Format Improvements
While researching another problem, I noticed that font color was not working as expected for Xls Conditional Formats, at least not when a "non-standard" color is used. In such cases, the color might wind up being rendered as black. The reason is as follows. Xls Writer includes a color palette which is dynamically generated from the (non-Conditional) styles used in the workbook. Any colors used in the workbook are indexes to this dynamic palette. However, Conditional colors use a static palette found in class ColorMap to determine the index, so the determination of index will often not find a match, and, if a match is found, it is not necessarily correct. (Also, the ColorMap method was case-sensitive and needs to be insensitive.)

In order to correct this, the `addColor` method in Xls Writer Workbook needs to be accessible to the Conditional logic which is found in Xls Writer Worksheet. This is accomplished by passing the Workbook in the Worksheet's constructor, and changing the method to public, and changing Conditional Font to use this method rather than ColorMap.

The logic for Conditional Fill colors is similarly changed. Although Xls Conditional Fill has appeared to just not work, I was finally able to figure out the problem. Excel Xls Conditional Fill with fill type Solid requires that the fill color be specified as startColor, and that endColor be omitted. Our conditional samples used endColor, and are now changed to use startColor instead; the same is true for our online documentation, and for some tests. Xlsx continues to work as expected, and now Xls does at least some of the time. If the condition is one that Excel Xls does not recognize (e.g. cell contains), it will, of course, not work. A surprising situation that also doesn't work is the use of ISODD or ISEVEN in formulas. Those are "add-in functions" which are handled differently than other functions, and I'm not sure how to support them. I will document this in issue #3403.

Samples 08_Conditional_Formatting(_2) had produced corrupt Xls versions. This turned out to be because the code was using hash codes to avoid having to write out duplicate conditionals; this is often a good idea, but not in this case. Allowing the duplicates fixes the corruption problem.

Conditional Border colors also ought to figure in this change, but the current code does not support Border colors, and I have not yet been able to figure out how to implement it (BIFF format can be very messy to figure out).

With this change, I could delete ColorMap altogether. However, it is a public class with a static public method, so maybe someone is using it for a purpose I'm not familiar with. I will just deprecate it.
2024-05-15 17:41:34 -07:00
Adrien Crivelli 8968062e8d Drop PHP 8.0 support
This is according to our formal, published, policy to only support
EOL PHP after 6 months.

See https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support

Also consolidate documentation in a single place, not in the README,
because it's a pain to maintain almost-duplicated-but-not-really
documentation.
2024-05-11 14:09:30 +07:00
oleibman bdcbc0481b Update reading-and-writing-to-file.md 2024-05-09 23:21:26 -07:00
oleibman e63e8a9bbf Merge pull request #3959 from oleibman/docrector
Update Rector Documentation
2024-03-25 02:22:10 +00:00
oleibman 6208887c12 Update Rector Documentation
Rector no longer supports conversion from PhpExcel (issue #3953). Documentation is updated to suggest using a non-current release of Rector for conversion.
2024-03-24 19:17:22 -07:00
oleibman f64e0ecd79 Merge branch 'master' into issue3951 2024-03-24 17:40:54 -07:00
oleibman 891180e13d Protect Sheet But Allow Sort
Fix #3951. When an Excel sheet is protected, even when sorting is explicitly allowed without a password, sorts are permitted only on "protected ranges" within the sheet. PhpSpreadsheet already supports protected ranges, and only minor tinkering is necessary for that (e.g. the protected range can have, but does not require, a password). The more important part of this change is documenting the far-from-intuitive way that Excel handles this. To that end, documentation is updated, and a new sample is added.

A new class, `Worksheet\ProtectedRange` is added in place of the string array which had been used. `Worksheet::getProtectedCells` is deprecated in favor of the new `Worksheet::getProtectedCellRanges`.
2024-03-20 07:04:24 -07: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 5587ca0cd5 Merge branch 'master' into issue3918 2024-03-08 19:14:49 -08: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 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
Adrien Crivelli c677a2f1c8 Never mention a specific PhpSpreadsheet version in documentation 2024-02-11 14:39:49 +08:00