Commit Graph

2393 Commits

Author SHA1 Message Date
Mark Baker 92389c78eb
Ensure that the list of shared formulae is maintained while chunk-reading Xlsx Files (#1680)
* Ensure that the list of shared formulae is maintained while chunk-reading Xlsx files
2020-10-12 13:22:32 +02:00
Adrien Crivelli 1cda811017
Prepare for next version 2020-10-12 08:06:57 +09:00
Adrien Crivelli 6da3f30def
Remove coverage from Travis
Coverage data were not correctly uploaded for a long time now, and it
now is uploaded via GitHub Actions
2020-10-11 22:32:04 +09:00
Adrien Crivelli a8e8068b31
1.15.0 2020-10-11 22:20:59 +09:00
Adrien Crivelli da7adcda80
Update CHANGELOG 2020-10-11 22:11:20 +09:00
oleibman 1741766a9c
Improving Coverage for Excel2003 XML Reader (#1557)
* Improving Coverage for Excel2003 XML Reader

Reader/Xml is now 100% covered.

File templates/Excel2003XMLTest.xml, used in some tests, is *not*
readable by a current version of Excel. I have substituted a new file
excel2003.xml to be used in its place. I have not deleted the original
in case someone in future (possibly me) wants to see what it needs to
make it usable.

There are minimal code changes.
- Unused protected functions pixel2WidthUnits and widthUnits2Pixel
  are deleted.
- One regex looking to convert hex characters is changed from a-z to a-f,
  and made case insensitive.
- No calculation performed for "error" cell (previously calculation
  was attempted and threw exception).
- Empty relative row/cell is now handled correctly.
- Style applied to empty cell when appropriate.
- Support added for textRotation.
- Support added for border styles.
- Support added for diagonal borders.
- Support added for superscript and subscript.
- Support added for fill patterns.

In theory, encodings other than UTF-8 were supported.
In fact, I was unable to get SecurityScanner to pass *any* xml which is
not UTF-8. Eliminating the assumption that strings might not be UTF-8
allowed much of the code to be greatly simplified.
After that, I added some code that would permit the use of
some ASCII-compatible encodings (there is a test of ISO-8859-1).
It would be more difficult to handle other encodings (such as UTF-16).
I am not convinced that even the ISO-8859 effort is worth it,
but am willing to investigate either expanding or eliminating
non-UTF8 support.

I added a number of tests, creating an Xml directory, and moving
XmlTest to that directory.

Pull Request had problems reading old invalid sample in the code
coverage phase, not in any of the other test phases, and not in
the code coverage phase on my local machine.
As it turns out, aside from being invalid, the sample
is much larger than any of the other samples. Tests have been
adjusted accordingly.

* Smaller Test File

Should eliminate need to avoid test during xml coverage.

* Break Up Style Test into Multiple Tests

Per suggestion from Mark Baker.

* Integrate AddressHelper Change

The introduction of AddressHelper introduced a conflict which needed to
be resolved. I wanted to test it locally before resolving. This required
me to add (unchanged) AddressHelper to my local copy. I hope this is
an okay manner of resolving the conflict.

* Weird Travis Error

XmlOddTest works just fine on my local machine, but Travis failed it.
Even worse, the lines which Travis flags don't even make any sense
(one was the empty line between two methods!).
This test is not essential to the rest of the change. I am removing
it from the package, and will attempt to re-add it when I have a chance
to sync up my fork with the main project.
2020-10-11 13:26:56 +02:00
Adrien Crivelli 7545c411f9 Test PHP 8 on GitHub Actions 2020-10-11 19:46:56 +09:00
MarkBaker b53199d7db Update composer suggestions 2020-10-11 12:36:47 +02:00
Adrien Crivelli 591f7cf301
Merge pull request #1675 from PHPOffice/PHP8-Testing
Php8 testing
2020-10-11 18:34:42 +09:00
Adrien Crivelli c3d1ce536b
Publish API docs via GitHub Actions 2020-10-11 12:06:27 +09:00
Adrien Crivelli df2fd911d0
Merge pull request #1676 from PHPOffice/github-actions
Introduce GitHub Actions
2020-10-10 23:20:38 +09:00
Adrien Crivelli 794ac801a5
Annotate problems in code 2020-10-10 22:51:04 +09:00
Adrien Crivelli 44080a1e8b
Introduce GitHub Actions
The plan is to keep Travis for a short while, until we are confident that
GitHub Actions work well enough for us. And after that we can remove Travis
entirely.

There is a bunch of duplicated things but it allows us to maximize
parallelismt to have results as soon as possible.

API documentation generation is still missing.
2020-10-10 21:03:14 +09:00
MarkBaker 2d93c36a1a Update composer suggestions 2020-10-10 12:11:00 +02:00
MarkBaker ebb7569dba Switch from using poser badges to shields.io because poser wasn't picking up the correct license 2020-10-09 17:55:06 +02:00
MarkBaker dcc47fb287 Codestyle clean-ups 2020-10-09 16:08:20 +02:00
MarkBaker 930fdc1b0c Locale-specific float to string is changed in PHP as per https://wiki.php.net/rfc/locale_independent_float_to_string 2020-10-09 15:59:59 +02:00
MarkBaker e3b9b0d29c Need to add `application/csv` to the list of valid CSV mime types 2020-10-09 14:57:45 +02:00
MarkBaker 6e6c68e7b3 Let's try to figure out why we're having an issue with a temp csv file 2020-10-09 14:52:01 +02:00
MarkBaker ee13533db3 Remove tests that include tcPDF and DomPDF libraries when running against PHP8, because neither library is yet PHP8-ready 2020-10-09 14:31:16 +02:00
MarkBaker 87a909aaf8 Use ZipArchive methods as zip_* functions are deprecated in PHP8 2020-10-09 12:58:33 +02:00
MarkBaker 57d1854bae Merge branch 'master' into PHP8-Testing 2020-10-08 15:02:50 +02:00
Roland Eigelsreiter ab4d7413b0
fixed php8 deprecation warning for libxml_disable_entity_loader() (#1625)
* fixed php8 deprecation warning for libxml_disable_entity_loader()
2020-10-08 15:02:14 +02:00
MarkBaker 723ca37530 Allow failures on nightly fails if we remove it from the grid 2020-10-08 06:10:16 +02:00
MarkBaker 8d0bb374e4 Allow failures on nightly 2020-10-08 06:09:16 +02:00
MarkBaker 3db9fb7958 Work with existing composer file; but force a fresh install to require new dependency versions 2020-10-08 05:51:06 +02:00
MarkBaker fdee43cfa1 Merge branch 'master' into PHP8-Testing 2020-10-08 03:09:21 +02:00
MarkBaker f399acccc9 We don't want the composer lock file for PHP8 2020-10-08 03:00:53 +02:00
MarkBaker 71f21fb94a Separate compoer.json for PHP8 to enforce phpunit ^9.3 2020-10-08 02:56:13 +02:00
Adrien Crivelli 12bdcaa783
Sync README 2020-10-05 10:27:27 +09:00
Adrien Crivelli 9f6da8a7c2
Update CHANGELOG 2020-10-05 10:27:19 +09:00
oleibman ef997a0c8e
Bug setting Superscript/Subscript to false (#1567)
If font style Superscript is set to true, Subscript is set to false.
Likewise, setting Subscript to true sets Superscript to false.
Both of these are working as they should. However,
setting Superscript to false causes Subscript to be set to true,
and setting Subscript to false causes Superscript to be set to true.
I believe that is an error in both cases. This change fixes it.

There seem to be no existing tests for Font styles.
I added the tests necessary to validate this change.
I will put adding more on my to-do list.
2020-10-05 10:21:40 +09:00
Arman Hosseini b9ca8a1a7b
Update index.md (#1620) 2020-10-02 18:05:29 +09:00
Simon Podlipsky 3d9867ce95
Drop $this->spreadSheet null check from Xlsx Writer (#1646)
$this->spreadSheet cannot be null
2020-10-02 17:55:50 +09:00
oleibman 416e27b632
ReverseSort bug, exposed but not caused by PHP8 (#1660)
Some tests of ReferenceHelper functions columnReverseSort and
cellReverseSort which passed with PHP7 fail with PHP8.
Both functions use the following construction:
  return 1 - strcasecmp(whatever);
The "1" seems very mysterious. I believe that the correct code should be:
  return -strcasecmp(whatever);
It appears in particular that PHP7 strcasecmp was never returning a
value of 1 for the tests in question, but PHP8 strcasecmp does so.
With the corrected code, the tests pass in both PHP7 and PHP8.
2020-10-02 17:52:28 +09:00
oleibman fe6221fe49
Reader/Gnumeric Failure with PHP8 (#1662)
* Reader/Gnumeric Failure with PHP8

An explicit cast from SimpleXML to int is now needed with PHP8,
where it was performed implicitly with PHP7.
Unit tests run correctly for both PHP7 and PHP8 on corrected code.
2020-10-01 12:38:36 +02:00
MarkBaker b44eb85b9f Merge branch 'master' into PHP8-Testing 2020-10-01 11:30:58 +02:00
MarkBaker 7d05e0557c Update to versions of complex and matrix libraries 2020-10-01 11:30:09 +02:00
oleibman 43db94e94f
Calculation/DateTime Failure With PHP8 (#1661)
The following code generates an error with PHP8:
  if ($t1[1] > 29) {
    $t1[1] += 1900;

Under the "right" conditions, PHP8 evaluates the condition as true
when PHP8 is a non-numeric string and then generates an error trying
to perform += on that non-numeric string. Adding a numeric test
eliminates the problem. All unit tests involving this code now
succeed with both PHP7 and PHP8.
2020-10-01 11:24:53 +02:00
MarkBaker 23e3a09dd3 Update to versions of complex and matrix libraries 2020-09-01 11:02:07 +02:00
MarkBaker adc0e980e1 <>/!= 2020-08-09 14:33:13 +02:00
MarkBaker 9d17408f1d xdebug isn't built into the nightly PHP, so we'll get an error if we try to remove it; nightly should also be allow failures untilany identified issues are resolved 2020-08-09 14:26:44 +02:00
MarkBaker 91185a93dc Starting from scratch again: PHP8 nightly build included in test run, and it should pickup PHPUnit >= 9.3 2020-08-09 14:12:17 +02:00
Mark Baker 9683e5be18
More unit tests for statistical functions, including a bugfix to LARGE() (#1601)
* More unit tests for statistical functions, including a bugfix to LARGE() that was identified in testing
2020-07-29 23:56:37 +02:00
Adrien Crivelli a203c3a7ea
Drop obsolete code 2020-07-27 10:03:26 +09:00
Mark Baker a9c8470b3b
Identify HYPGEOM.DIST() as a separate Excel function, and additional unit tests (including unhappy path) (#1595) 2020-07-26 22:10:53 +02:00
MarkBaker f34cc6cf6e Fix reference to PR in changelog 2020-07-26 13:56:27 +02:00
Mark Baker 8b0aaf7ecf
Named formula implementation, and improved handling of Defined Names generally (#1535)
* Initial work modifying the way named ranges are stored, and handled by the calculation engine
This should provide better support for:
  - both union and intersection operators in composite named range values
  - MS Excel implementation of the union operator duplicating values
  - named formulae
  - named ranges and formulae that reference other named ranges and formulae
  - ranges and formulae that reference multiple ranges across multiple worksheets

* Initial work on handling defined names (named ranges and named formulae) correctly
 - UTF-8 names (already extracted as a separate PR and merged)
 - distinction between named ranges and named formulae
 - correct handling of union and intersection operators in named ranges
 - correct evaluation of named range operators in calculations
 - calculation support for named formulae
 - support for nested ranges and formulae (named ranges and formulae that reference other named ranges/formulae) in calculations

* Minor tweaks before resolving merge conflicts

* Fix extractSheetTitle() method to work on the last ! in a cell reference rather than the first

* Throw exception if a the reference to a defined name in a formula doesn't exist as a defined name

* Properly assess scope for defined names in calculation engine

* Elimination of some redundant code

* Minor tweaks to simplify entries o the stack where we need to check type

* Ensure correct scoping rules are applied when evaluating named ranges and formulae

* Adjustments to Gnumeric Reader for new defined names structure

* Initial work modifying the Ods Reader to handle named ranges, they weren't actually supported previously... this is still ongoing work

* Handle Ranges formatted as 3-d ranges, as long as the references are both to the same worksheet

* Additional testing for Named Ranges formatted as 3-d ranges, as long as the references are both to the same worksheet

* Skip composite named range tests for the moment

* Clean handling for `undefined name` exception when thrown in the calculation engine. Catch and replace with `#NAME?`

* Adjust method we use to determine whether a defined name is a range or a formula

* PHPCS Recommendations

* PHP doesn't support `mixed` yet, at least not at the minium version that we're working with

* More phpcs fixes

* More phpcs appeasements

* Final phpcs fixes for the moment
Still have a lot of echo and var_dump() statements in the code that scrutinizer will hate, but they stay for the moment while this is still WIP

* Please let this be the last of the phpcs fixes

* Unit tests to determine whether a defined name value is a range value or a formula

* phpcs appeasement

* Named tests from provider

* Initial steps for named ranges and formulae in the Ods Reader

* Reading pseudo-3d range addresses in Ods; treat second sheet reference as being identical to the first, which is the majority of cases where this will occur

* Initial work on Gnumeric reader for named ranges and formulae

* Suppress debug logging again

* Remove more debugging displays

* Last minor tweaks before phase two

* Minor refinements

* And all for the want of a space

* A little tidying up

* More tidying up

* phpcs fix

* Modify defined names in rebindParent()

* Renaming variables

* Resolve an issue with locally scoped defined names that don't contain any worksheet reference

* Keep phpcs happy

* Fix quote handling in regexp

* Fix a couple of scrutinizer issues

* Fix a couple of scrutinizer issues

* Update Xlsx Writer to work with the new defined name internal definition
Additional validation checks

* When adding new defined names through the readers, worksheet may not exist if we're only loading selected sheets rather than the full spreadsheet

* If the only thing that phpcs can pickup on is strings in double quotes instead of single quotes, then I know I'm getting close to ready

* Refactor Defined Names logic for Xlsx Writer into its own class

* phpcs keeping me on my toes

* Restore a couple of files that I managed to change without intending to

* Initial work on Ods Write to provide support for saving named ranges and formulae

* Resolve commas to semi-colons s argument separator when writing named formulae for Ods

* Extract Named Expression Writer for Ods into its own class

* Keep phpcs happy

* Refactoring of formula conversion when reading SpreadsheetML; preparation for reading named ranges because they will also need to use the same conversion method

* First pass at reading Named Ranges/Formulae from SpreadsheetML format xml files

* Remove unused namespace reference

* Defined names being written correctly for Xls; but not yet writing cell formulae that reference those defined names... that's the next big step
And I anticipate that defined names that reference other defined names will also be a problem

* Just to keep phpcs happy
... and yes, I know that there are still diagnostic echo statements in the code

* I had to miss some of the phpcs issues didn't I

* Work on the Xls Writer's Parser Tree to identify named range tokens in a formula, and to distinguish them from function tokens

* Still working on packing that d*** defined name reference in the writer

* Throw an exception in the Parser for saving Xls output if we encounter a defined name in a formula... writer will simply write the calculated cell value, and not the formula as at present
Strip out diagnostic output

* Some phpcs appeasement

* Fix a couple of Scrutinizer issues

* Additional verifications to differentiate a formula from a range value
Add explicit getters/setters for named ranges, named formulae and defined names
Additional unit tests

* Styling for closures

* Remove redundant docblocks

* Spaces

* Gah! Namespace use complaints

* Consistency of making calls to DefinedName rather than NamedRange; NamedRange should now be used only for Named Ranges, and should exclude Named Formulae

* Styling

* spurious newline

* No need to test for variable === null when we're typing it in the function argument definition

* Additional unit tests for local/global scoped named ranges and formulae; and a fix to getNamedFormula()

* Fix silly typo that led to breaking test

* Void return signature for unit tests

* Why weren't these picked up in the last pass?

* Refactoring of getNamedRange()/getNamedFormula()

* Eliminate unused constants, and defaults for private method parameters when always called with a value

* Use strict comparisons when comparing object hash codes

* Initial update to documentation for working with named formulae

* Fix for calculation of relative cell references in named ranges/formulae

* Fix current named range tests, because we should be using absolute references; tests for relative named ranges to be added later

* Fix for calculation of relative cell references in named ranges/formulae

* Updates to changelog and documentation for handling of absolute/relative references in named ranges

* Fix last remaining unit test with a named range reference

* Refactor formula conversion for Ods into a separate class; I hadn't realised that it previously wrote formulae as the MS Excel syntax without any conversion to Ods format

* Fix Ods Writer test xml to reflect Ods-native format for formula

* Docblocks

* Drop dollar prefix from Ods formulae and ranges unless it's necessary

* Set the formula convertor in the content writer constructor

* Documentation update

* Minor updates

* Remove var_dumps from file

* Fix the spurious single quote that was breaking named expressions in the Ods Writer... big sigh of relief that I finally spotted it

* Starting work on documentation for Defined Names, and some examples of using Named Ranges and Formulae

* Starting work on documentation for Defined Names, and some examples of using Named Ranges and Formulae

* Example of a relative named range for the documentation

* Mustn't have phpcs problems in sample code either

* More updates to the documentation

* That should conclude the documentation for Named Ranges, now time to move on to documenting Named Formulae

* That should conclude the documentation for Named Ranges, now time to move on to documenting Named Formulae

* PHPCS appeasement in sample code

* Initial documentation on Named Formulae

* PHPCS appeasements

* Additional comments in the documentation, and modify the named range name validation to support a \ as the first character in a name

* Fix breaking build

* Make defined names case-insensitive

* Fix case-insensitivity

* Improved documentation, and additional unit tests

* Additional unit tests, and a fix for removing a globally scoped defined name even if a worksheet is specified in the method call

* Fix unit test for removing named formulae

* Use assertCount instead of assertSame

* Forgotten voids

* Fix arguments for assertCount

* Unit tests for removing defined names, and a fix for removing locally scoped names

* Unit tests for absolute and relative named ranges in calculation engine, and fix an issue with worksheet name in the offset adjustments for relative references

* PHPCS Appeasement

* Additional unit tests, more documentation, and a fix to the calculation engine when no worksheet reference is provided with a named formula

* PHPCS appeasements

* Additional documentation and examples of using Named Formulae

* Additional examples to go with documentation

* A few minor phpcs appeasements

* Minor refactor of updateFormulaReferencesAnyWorksheet() method

* Discard an unused method argument

* Additional unit tests

* Additional unit tests

* Remove unused argument

* Stricter typing

* Fix return typehinting from remove named range/formula; should return the Spreadsheet object

* Use return typehint of self rather than explicit object type

* Redundant code just to keep scrutinizer happy

* Minor change to handle merge conflict

* phpcs fixes after merge

* Namespace usage ordering

* Please let this be the last phpcs fix needed

Co-authored-by: Adrien Crivelli <adrien.crivelli@gmail.com>
2020-07-26 12:00:06 +02:00
Adrien Crivelli 8d788b4dc6
Travis use same config for phpcs 2020-07-26 15:05:54 +09:00
Adrien Crivelli 48f8b5c1f2
Move phpcs config to file 2020-07-26 14:48:06 +09:00