Commit Graph

3422 Commits

Author SHA1 Message Date
Mark Baker 0ef98ac044
Merge branch 'master' into Row/Column_isEmpty-check 2022-06-10 17:34:11 +02:00
Mark Baker e3471f8a0f
Merge pull request #2878 from PHPOffice/Issue-2868_Emphasis-Documentation-for-setValueExplict
Update docblock documentation for setting cell values explicit
2022-06-10 14:37:24 +02:00
MarkBaker 8434189336 Update docblock documentation for setting cell values explicit to indicate that value/datatype matching is the responsibility of the end-user developer making this call; and that values may be changed to reflect the specified datatype.
No doubt some developers will complain that it should be the other way round, that datatpe should be modified to match the specified value; but then they should be using setValue() instead; the use of setValueExplicit() is explicit.
2022-06-10 13:38:41 +02:00
oleibman 4f22b39b89
Add Support to Chart/Axis and Gridlines for Shadow (#2872)
* Add Support to Chart/Axis and Gridlines for Shadow

Continuing the work from #2865. Support is added for Shadow properties for Axis and Gridlines, and Glow and SoftEdges are extended to Gridlines. Tests are added. Some chart tests are moved from Reader/Xlsx and Writer/Xlsx so that most chart tests are under a single directory.

This is a minor breaking change. Since the support for these properties was just added, it can't really affect much in userland. Some properties had been stored in the form which the XML requires them rather than as the user would enter them to Excel. So, for example, setting the Glow size to 10 points would have caused it to be stored internally as 127,000. This change will store the size internally as 10, obviously making the appropriate conversion when reading from or writing to XML. This makes unit tests much simpler, and I think this is also what a user would expect, especially considering the difficulties in keeping track of the trailing zeros.

* More Tests

Confirm value change between internal and xml.

* Still More Tests

Add a little more coverage, and use a neat trick suggested by @MarkBaker in the discussion of PR #2724 to greatly simplify MultiplierTest.
2022-06-09 18:08:56 -07:00
Mark Baker 1f1fc360af
Merge pull request #2877 from PHPOffice/Issue-2776_Allow-Merge-Cells-for-single-cell
Relax validation on merge cells to allow input of a single cell
2022-06-10 01:27:29 +02:00
MarkBaker 00dae1bbda Relax validation on merge cells to allow input of a single cell 2022-06-10 01:15:57 +02:00
MarkBaker b62de98bf7 New functionality to allow checking whether a row or column is "empty", with flags to allow variation in the definition of "empty" 2022-06-07 20:22:33 +02:00
oleibman 5608e05eda
Add Support to Chart/Axis for Glow/SoftEdges (#2865)
* Add Support to Chart/Axis for Glow/SoftEdges

Chart is very under-covered in unit tests. I was hoping to just add some tests and be done with it, but that just won't suffice - many code changes are required. Adding Glow properties for Axis turned out to be a real mixed bag - no support in Xlsx/Reader at all, support in Xlsx/Writer ... for the X-axis only. So we'll just inch forward in many stages.

This change does not address other Axis properties (Fill, Shadow, Line, LineStyle, and maybe others, and their sub-properties). On my to-do list.

GridLines, and maybe other Chart objects, also should support these properties. This change does not address those. On my to-do list.

No support is added for spreadsheet formats other than Xlsx.

* Refactoring

This should make the code easier to follow, and I hope it will also be extensible to other object types (e.g. GridLines).

* More Refactoring

Make scheme/srgb easier to handle.

* Fix Typo

In a very rarely used function.
2022-06-03 16:47:03 -07:00
dependabot[bot] d0ff3d9ca7
Bump phpstan/phpstan from 1.6.3 to 1.7.7 (#2864)
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 1.6.3 to 1.7.7.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Changelog](https://github.com/phpstan/phpstan/blob/1.7.x/CHANGELOG.md)
- [Commits](https://github.com/phpstan/phpstan/compare/1.6.3...1.7.7)

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

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: oleibman <10341515+oleibman@users.noreply.github.com>
2022-06-01 21:22:53 -07:00
oleibman 8bb568c9ac
Prep Work Before Upgrading to Phpstan 1.7.7 (#2867)
Clean up the usual discrepancies which arise between Phpstan releases.
2022-06-01 21:10:41 -07:00
oleibman c936f1d9f8
Coverage Improvements (#2859)
Mostly new tests, some code annotations, some minor code changes:
- RichText clone logic is wrong
- TextElement doesn't have object properties, doesn't need clone
2022-06-01 08:29:56 -07:00
Tomas Votruba 0aedef4902
Update excel migration with sets() method (#2861) 2022-05-31 07:19:43 -07:00
oleibman ab52991dc6
More Bubble Chart Fixes (#2856)
Continuing the work from #2828, #2841, #2846, and #2852. This is probably my last change in this area for a while.

Bubble charts can have bubbles of different sizes. Phpspreadsheet had not supported this. Openpyxl comes with sample code to generate such a chart. I was especially drawn to that solution because its namespace usage would have been unexpected before 2852. And it turned out to come with other surprises - use of absolute paths in the .rels files (PhpSpreadsheet expected only relative), use of a one-cell anchor to place the chart (PhpSpreadsheet expected two-cell anchor or absolute positioning), plaintext in the legend (Phpspreadsheet expected RichText), no cached values for chart data. Excel handles the file okay, and this PR makes sure PhpSpreadsheet does as well. This file is now Samples/Templates/32readwriteBubbleChart2, and is used for both generating a sample output file and in formal tests. A new sample in the 33* series demonstrates how to code these.
2022-05-28 18:45:47 -07:00
Mark Baker 273d16e6a3
Merge pull request #2857 from PHPOffice/Minor-Documentation-Updates
Minor documentation updates
2022-05-26 15:28:35 +02:00
Mark Baker daffce00d6
Merge pull request #2858 from PHPOffice/PhpStan-Cleanups
Declare a few return datatypes
2022-05-26 15:28:07 +02:00
MarkBaker 3302701ae7 Declare a few return datatypes 2022-05-26 15:20:41 +02:00
MarkBaker 8089c9bf20 Declare a few return datatypes 2022-05-25 18:38:54 +02:00
Mark Baker dfd043295e
Merge pull request #2854 from PHPOffice/PHPStan-Cleanup-Regexp-String-Casting
Php stan cleanup regexp string casting
2022-05-25 17:33:17 +02:00
MarkBaker ff8f801043 Use preg_replace() with arrays, where appropriate, because it's more efficient that caling several times 2022-05-25 13:32:06 +02:00
MarkBaker bf46ff1e0c Explicit type-cast result from preg_replace() calls to string, cleans up a few phpstan issues 2022-05-25 12:36:25 +02:00
oleibman 9e4ff929b4
Namespacing Part 3 - Charts (#2852)
* Namespacing Part 3 - Charts

Charts still need some work, but they are now in good enough shape that the code that reads them can handle namespacing properly. Rather than a set of static routines, Reader/Xlsx/Chart needs to be changed to a regular object, with the relevant namespaces passed in the constructor. I am still looking for a test spreadsheet with non-standard namespacing for a full-blown test, but, in the meantime, the existing tests and samples will suffice. When I find a test case, I will certainly add it.

The resulting code is actually simpler than it had been because of the elimination of the need for a NamespacesMeta variable in all the function signatures. Because of that, enough errors disappeared from Phpstan that I decided to just finish that job - its baseline file now dips below 5,000 lines.

* Update Change Log

Need to document many chart changes.
2022-05-25 00:56:26 -07:00
Mark Baker 13e1b9a939
Merge pull request #2853 from PHPOffice/Gnumeric-Reader-Worksheet-Visibility
Add support for reading Worksheet Visibility for Gnumeric
2022-05-24 15:33:34 +02:00
MarkBaker c26215fdab Update Change Log 2022-05-24 14:40:45 +02:00
MarkBaker bb7e083745 Add Hidden Worksheet unit tests for other Readers 2022-05-24 14:40:45 +02:00
MarkBaker 23ce21901d Add support for reading Worksheet Visibility for Gnumeric 2022-05-24 14:08:41 +02:00
Mark Baker 7fff764698
Merge pull request #2847 from PHPOffice/CellRange-Validation-Performance-Tweak
Minor performance tweaks
2022-05-24 09:00:51 +02:00
Mark Baker 4f1d6d2cac
Merge branch 'master' into CellRange-Validation-Performance-Tweak 2022-05-24 08:50:51 +02:00
MarkBaker 8914c61265 Minor performance tweak 2022-05-23 18:32:20 +02:00
oleibman d11152271e
Eliminate Corruption in Surface Chart Samples (#2846)
* Eliminate Corruption in Surface Chart Samples

Fix #2763 (bubble charts were fixed earlier).

* Improvement in Testing for Numeric Values

The original proposal was to test for numeric values by checking whether the format was NUMERIC or DATE. This is pretty inflexible, and left open a wide gap concerning what to do with GENERAL. Changed to allow the user to set a `numeric` property at the same time as `axisNumberProperties`, eliminating these concerns. User can set property when chart is created (new test member Charts32CatAxValAxTest), or can set it when spreadsheet with chart is read (new method testCatAxValAx in Charts32XmlTest). Sample 33_Chart_create_scatter2 creates a slightly wider chart when `numeric` is set to true than it does when unset, but chart is otherwise the same.

Corrected a bug which occured twice in Chart. Methods getChartAxisX and getChartAxisY created a new Axis object if the chart pointer was null, but neglected to attach the new object to the chart. Thus, subsequent calls to the methods return different objects. Code is changed to attach the new Axis to the Chart.
2022-05-23 09:21:52 -07:00
Mark Baker a54d1c14aa
Merge pull request #2850 from PHPOffice/Ods-Writer-Worksheet-Visibility
Add support for writing Worksheet Visibility for Ods
2022-05-23 17:16:02 +02:00
Mark Baker 2de58d4164
Merge branch 'master' into Ods-Writer-Worksheet-Visibility 2022-05-23 17:06:19 +02:00
Mark Baker 6569f725e3
Merge pull request #2851 from PHPOffice/Ods-Reader-Worksheet-Visibility
Add support for reading Worksheet Visibility for Ods
2022-05-23 17:05:27 +02:00
Mark Baker 2f3892788f
Merge branch 'master' into Ods-Reader-Worksheet-Visibility 2022-05-23 16:52:48 +02:00
Mark Baker 12ae0d249f
Merge pull request #2849 from PHPOffice/Issue-2848_Xlsx-Reader-Invalid-Print-Area
Don't load invalid Print Area, because this will corrupt the internal print area definition, and break on Writing
2022-05-23 16:31:54 +02:00
MarkBaker 3fae29d613 Add support for reading Worksheet Visibility for Ods 2022-05-23 15:30:45 +02:00
MarkBaker 2e5ebea110 Add support for writing Worksheet Visibility for Ods 2022-05-23 13:38:08 +02:00
MarkBaker 924ec23eb0 Don't load invalid Print Area, because this will corrupt the internal print area definition, and break on Writing 2022-05-23 12:12:05 +02:00
MarkBaker 8ef9aa8251 Minor performance tweak 2022-05-23 00:08:06 +02:00
oleibman 7c1c896959
Change and Re-enable URLImageTest (#2844)
Disabled it earlier because its reliance on an external site not under our control was causing problems. URL in spreadsheet is now changed to point to an image in phpspreadsheet.readthedocs.io, which should be more reliable. Test is re-enabled.
2022-05-21 08:07:59 -07:00
oleibman 567b9601b0
Allow Csv Reader to Store Null String in Spreadsheet (#2842)
Fix #2840 (and also #2839 but that's Q&A, not an issue). Csv Reader does not populate cells which contain null string. This PR provides an option for the reader to store null strings as it does with any other string.
2022-05-21 07:21:14 -07:00
oleibman ef031e74e1
More Chart Fixes (#2841)
* More Chart Fixes

Taking up where #2828 left off. Most of the following changes are demonstrated in 32readwriteChartWithImages1:
- Adds support for "scheme" colors (because rgb, theme, and index colors just weren't enough for Excel) for DataSeriesValues. See issue #2299.
- For chart titles (including axis labels), rather than a font name, Excel supplies a 3-fold series of font names for Latin, East Asian, and Complex Scripts. New properties `latin`, `eastAsian`, and `complexScript` are added to the Font class. I frankly have no idea how, or even if, you can set these in Excel; my test case (sample 32readwriteScatterChart7) is a result of manually editing the XML.
- Add support for subscript/superscript to chart titles. This requires a new property `baseLine` in Font (positive=superscript negative=subscript baseline value says how high/low).
- Support for underscore with different scheme color than its text, using a new string property `uSchemeClr` in Font.
- Support for extra options for strikethrough, using a new string property `strikeType` in Font.
- Support for extra options for underscore type, using the existing string property `underline` in Font.
- I do not anticipate that any of the new Font properties will be used except for chart titles.
- If no default font overrides are found for a Rich Text element in chart titles, and no explicit font overrides are found for a Run under such an element, the font element of the Run is set to null.
- PhpSpreadsheet will always write a tag `a:pPr` and, underneath that, an empty tag `a:defRPr`, for default font settings for chart titles and axis labels. Combined with the previous bullet item, this will prevent PhpSpreadsheet from inadvertently overriding the Excel defaults (18 point bold Calibri for chart title, 10 point bold Calibri for axis labels).
- Axis labels will now be written to XML in the same manner as chart titles. Among other considerations, this means that they can now have colors. Fix #2700. Supersedes PR #2701. Demonstrated in sample 32readwriteStockChart5.

* Fix Some Chart Corruption

Fix #2817, where @bridgeplayr gives an excellent description of the problem and how it should be solved.

* Fix Bubble Charts

Sample produced corrupt output - see issue #2763. After a lot of research, solution was just re-ordering of parameters in a single function call.

Bubble 3D had not been supported at all. It is now.

Surface Charts remain corrupted.
2022-05-21 07:01:18 -07:00
oleibman 9d36e442e9
Disable URLImageTest (#2843)
This test has always been problematic in that it depends on an external site not under the control of PhpSpreadsheet, and can therefore break at any time. As it has done this morning. Disable it until a better test is available.
2022-05-21 06:46:02 -07:00
Mark Baker b8957205e1
Merge pull request #2835 from PHPOffice/Issue-2833_Null-handling-in-PRODUCT()-Function
Filter null values in PRODUCT() function

> It all looks good to me.

ty
2022-05-17 17:10:32 +02:00
Mark Baker a59b29ae11
Merge branch 'master' into Issue-2833_Null-handling-in-PRODUCT()-Function 2022-05-17 16:53:08 +02:00
oleibman 9aa1708468
Some Fixes for Scatter Charts (#2828)
* Some Fixes for Scatter Charts

Chart issues have been pouring in recently. This is a partial response to issue #2762. It implements "no joins" for scatter charts, as well as having the reader and writer handle "point size", "line width", and "color" for markers. A new boolean property `scatterLines`, with setter and getter, is added to DataSeriesValues to handle joins (default is true which means scatter plot points *are* joined by lines). Some, but not yet all, default font properties for the chart title are handled (color and, surprisingly, font name present challenges).

With these changes, sample 32readwriteScatterChart1.xlsx now looks closer to its source. There are still some differences (x-axis changes), but I think this change is already large enough. I can work on the other problems later.

The code for reading charts has not yet been converted to be namespace aware. Having a tiny island of aware code in a sea of unaware makes no sense to me, so some of the new code is likewise unaware. I hope to be able to get to it eventually, but, among other considerations, it is difficult to generate suitable test cases.

* Add Formal Tests

Essentially the same as the corresponding Samples, but with formal assertions.

* Clean Up Some Code in Reader/Xlsx/Chart

Having added code to support default font attributes as well as element-specific font attributes for chart captions, there was duplicated code between the default and specific sections. I hope that this PR makes the code easier to follow.

* Add Support for Font Name and Color to XLSX Chart Titles

XML layout for these in new files differs from what program was expecting. Not sure if program expectations were wrong, or if this is a change to Excel since initial development.

* Minor Improvement

Handle theoretical case where Chart title has text but no font information.

* Support Bezier Curve and Scaling of X-Axis on Scatter Plot

For Bezier, need to specify `<c:smooth>` tag in addition to already supplied `<c:scatterStyle val="smoothMarker">`

For X-Axis, scatter needs to supply both X and y axis as `<c:valAx>` rather than `<c:catAx>` for X.
2022-05-17 07:48:24 -07:00
MarkBaker db4dac3de9 Filter null values in PRODUCT() function, as they don't affect the calculation in any way, and actually require additional code handling if they're present within the calculation itself 2022-05-17 16:40:14 +02:00
Mark Baker 4df236a688
Merge pull request #2830 from PHPOffice/ChartSheet
Read ChartSheets with the Xlsx Reader if includeCharts is enabled
2022-05-17 16:24:51 +02:00
MarkBaker b4ba57acaa Unit tests for listWorksheetNames() and listWorksheetInfo() with a ChartSheet 2022-05-17 16:11:53 +02:00
MarkBaker e02f25bf48 Update listWorksheetNames() and listWorksheetInfo() to accept ChartSheet information 2022-05-17 15:44:24 +02:00
MarkBaker c66baa44ea Update Change Log 2022-05-17 15:31:44 +02:00