Commit Graph

2233 Commits

Author SHA1 Message Date
Adrien Crivelli b07cd2028d
Don't patch PHPUnit for phpcov 2020-04-27 20:21:07 +09:00
Adrien Crivelli f1a019e492
Upgrad PHP deps 2020-04-27 19:29:45 +09:00
Gennadiy Litvinyuk a7986520f9
Removed unnecessary object creation. (#1430) 2020-04-27 12:02:49 +02:00
Collie-IT 973011921d
Add Missing Operator NOTBETWEEN (#1390) 2020-04-27 12:01:36 +02:00
Adrien Crivelli 03c587fe0b
Drop PHP 7.1
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
2020-04-27 18:42:32 +09:00
Adrien Crivelli 8ea48ecb40
Run code style and coverage with PHP 7.4 2020-04-27 18:33:44 +09:00
Adrien Crivelli 4e6d6838e0
Deploy doc only when tags on master 2020-04-27 18:29:05 +09:00
Adrien Crivelli b1a7863485
Force doc deploy just for this once 2020-04-27 18:27:45 +09:00
Adrien Crivelli f79611d6dc
1.12.0 2020-04-27 17:12:48 +09:00
n-longcape f9f9f4cacf
Fix ROUNDUP and ROUNDDOWN for negative number
Closes #1417
2020-04-27 17:03:07 +09:00
bbinotto e2f87e8b7a
Load with styles should not default to black fill color
Fixes #1353
Closes #1361
2020-04-26 22:33:30 +09:00
Paul Kievits a6c56d0f81
Added support for the FLOOR.MATH and FLOOR.PRECISE functions 2020-04-26 22:19:33 +09:00
Owen Leibman c4895b9468
MATCH with a static array should return the position of the found value based on the values submitted.
Returns #N/A, unless the element searched for is at the end of the array.

The problem is in Calculation.php line 4231:
                    if (!is_array($functionCall)) {
                        foreach ($args as &$arg) {
                            $arg = Functions::flattenSingleValue($arg);
                        }
                        unset($arg);
                    }

I believe this code is intended to handle functions where PhpSpreadsheet just passes
the call on to PHP without implementing the code on its own, e.g. for atan or acos.
In the bug report, the following code fails:
  $flat_rate = "=MATCH(6,{4,5,6,2}, 0)";
  $sheet->getCell('A1')->setValue($flat_rate);
The expected value is 3, but the actual result is "#N/A".
The reason for this result is that the parser replaces the braces with calls
to the MKMATRIX internal function, whose value for functioncall was:
'self::MKMATRIX'. Since this isn't an array, the flattening code is executed,
and the unintended result occurs. The fix is to change the definition for
functioncall in that case to [__CLASS__, 'mkMatrix'], avoiding the flattening.

However, there is also another part to this bug. The flattening should be
returning the first entry in the array, but is in fact returning the last.
This explains why the bug report specified "unless ... end of the array".
I confirmed that Excel does use the first item in the array rather than the last,
e.g. =atan({1,2,3}) entered into a cell will return atan(1), not atan(3).
The problem here is that flattenSingleValue, which says in its comments that
it is supposed to be returning the first item, uses array_pop rather than array_shift.
I have changed that as well. The same mistake was also present in
Cell.php function getCalculatedValue. The correct behavior can be verified
by entering =minverse({-2.5,1.5;2,-1}) into an Excel cell'
Excel flattens the result ({2,3;4,5}) to 2, and so should PhpSpreadsheet.

Fixes #1271
Closes #1332
2020-04-26 22:09:31 +09:00
Jon Dufresne 6788869a40
Fix typo: occured → occurred (#1435) 2020-04-26 21:09:56 +09:00
Tim Gavryutenko 3dcc5ca753
Fix removing last row incorrect behavior
`$highestRow = $this->getHighestDataRow();` was calculated after `$this->getCellCollection()->removeRow($pRow + $r);` - this is the root reason for incorrect rows removal because removing last row will change '$this->getHighestDataRow()' value, but removing row from the middle will not change it. So, removing last row causes incorrect `$highestRow` value that is used for wiping out empty rows from the bottom of the table:
```php
for ($r = 0; $r < $pNumRows; ++$r) {
    $this->getCellCollection()->removeRow($highestRow);
    --$highestRow;
}
```
To prevent this incorrect behavior I've moved highest row calculation before row removal.
But this still doesn't solve another problem when trying remove non existing rows: in this case the code above will remove `$pNumRows` rows from below of the table, e.g. if `$highestRow=4` and `$pNumRows=6`, than rows 4, 3, 2, 1, 0, -1 will be deleted. Obviously, this is not good, that is why I've added `$removedRowsCounter` to fix this issue.
And finally, moved Exception to early if statement to get away from unnecessary 'if-else'.

Fixes #1364
Closes #1365
2020-04-26 11:00:43 +09:00
Adrien Crivelli 6e76d4e8b5
Cleanup CHANGELOG accidental changes 2020-04-26 10:24:14 +09:00
Matthijs Alles 87f71e1930 Support whitespaces in CSS style in Xlsx
Indentation in the xml leaves spaces in style string even after
replacing newlines. Replacing the spaces ensures no spaces in keys
of the resulting style-array

Fixes #1347
2020-04-05 19:50:57 +09:00
Adrien Crivelli 57c36e01d5
Replace Sami with phpDocumentor 3
Because Sami is deprecated and now raise errors. We lose API
docs for multiple versions but we still have latest version with low
maintenance cost.
2020-04-05 17:47:25 +09:00
Adrien Crivelli 5daa38f456
Add missing sections 2020-03-07 21:04:37 +07:00
youkan a79b344d53
Fix ROUNDUP and ROUNDDOWN for floating-point rounding error (#1404)
Closes #1404
2020-03-07 12:48:54 +07:00
Paul Kievits a08415a7b5 Improved the ARABIC function to handle short-form roman numerals 2020-03-07 12:43:59 +07:00
Adrien Crivelli 560e672b30
Merge pull request #1385 from ikeyan/feature/update-document
Update docs/references/function-list-by-*.md
2020-03-07 09:25:16 +07:00
Marius 50d78ce789 update doc on how to run the migrate tool
as per this https://stackoverflow.com/questions/53215313/phpspreadsheet-how-do-i-use-auto-migration-tool clarify how to run the tool
2020-03-07 09:20:30 +07:00
Adrien Crivelli c2a205e82f
1.10.1 2020-03-02 20:09:03 +07:00
Claas Augner ffb0d21cec PHPDoc: use @return $this for fluent methods
Fluent methods, especially setters, return the object on which are
called. This is documented in PHPDoc using the `$this` keyword, which
is equivalent to `static` with the additional notion of object identity.
This helps IDEs and static analysis tools provide more meaningful output.
2020-03-02 19:11:00 +07:00
Stronati Andrea 9f5a472426 Fix XLSX file loading with autofilter containing '$'
The `setRange` method of the `Xlsx/AutoFilter` class expects a filter
range format like "A1:E10". The returned value from
`$this->worksheetXml->autoFilter['ref']` could contain "$" and returning
a value like "$A$1:$E$10".

Fixes #687
Fixes #1325
Closes #1326
2020-03-02 18:43:27 +07:00
Owen Leibman fb379385e0
Fix active cell when freeze pane is used
When freeze pane is in use on a worksheet, PhpSpreadsheet saves to Xlsx in such
a way that the active cell is always set to the top left cell below the freeze
pane. I find it difficult to understand why:

  1. You have given users the setSelectedCells function, but then choose to
     ignore it.
  2. Excel itself does not act in this manner.
  3. PHPExcel did not act in this manner.
  4. PhpSpreadsheet when writing to Xls does not act in this manner.
     This is especially emphasized because the one test in FreezePaneTest which
     would expose the difference is the only test in that member which is
     not made for both Xls and Xlsx.
  5. It is *really* useful to be able to open a spreadsheet anywhere, even when
     it has header rows.

Closes #1323
2020-03-02 18:11:37 +07:00
Jimmy4o4 06d9dc03e9 Fix for Xls writer wrong selected cells and active sheet 2020-03-02 17:50:46 +07:00
池下克彦 23f26fa616 phpcs fix 2020-02-25 10:41:00 +09:00
池下克彦 32a8ef5e33 DocumentGeneratorTest 2020-02-25 09:52:32 +09:00
池下克彦 fe83f070aa improve testability 2020-02-24 23:24:47 +09:00
池下克彦 e11202168f bin/generate-document generates function-list-by-* 2020-02-21 14:56:43 +09:00
池下克彦 b98c19ca28 update function-list-by-* to sync with $phpSpreadsheetFunctions 2020-02-21 14:49:42 +09:00
池下克彦 80f5e8fd1e added IFS, NETWORKDAYS.INTL and WORKDAY.INTL as dummy EXCEL function
they are listed on the doc
2020-02-21 14:48:33 +09:00
oleibman cb18163a1d
Changes to WEEKNUM and YEARFRAC (#1316)
* Changes to WEEKNUM and YEARFRAC

The optional second parameter for WEEKNUM can take any of 10 values
(1, 2, 11-17, and 21), but currently only 1 and 2 are supported.
This change adds support for the other 8 possibilities.

YEARFRAC in Excel does not require that end date be before start date,
but PhpSpreadsheet was returning an error in that situation.

YEARFRAC third parameter (method) of 1 was not correctly implemented.
I was able to find a description of the algorithm, and documented
that location in the code, and implemented according to that spec.
PHPExcel had a (failing) test to assert the result of
YEARFRAC("1960-12-19", "2008-06-28", 1). This test had been dropped
from PhpSpreadsheet, and is now restored; several new tests have
been added, and verified against Excel.

* Add YEARFRAC Tests

Scrutinizer reported a very mysterious failure with no details.
project.metric_change("scrutinizer.test_coverage", < 0),
without even a link to explain what it is reporting.
It is possible that it was a complaint about code coverage.
If so, I have added some tests which will, I hope, eliminate the problem.

* Make Array Constant

Responding to review from Mark Baker.

* Merge with PR 1362 Bugfix 1161

Travis CI reported problem with Calculation.php (which is not part
  of this change).
That was changed in master a few days ago
(delete some unused code).
Perhaps the lack of that change is the problem here.
Merging it manually.
2020-02-19 20:22:31 +01:00
paulkned 0c52f173aa
Added support for the base function (#1344) 2020-02-19 20:12:30 +01:00
paulkned 25e3e45eb6
Added support for the ARABIC excel function (#1343)
Updated changelog

Updated docprops

Fixed stylci
2020-02-11 22:59:19 +01:00
Jon Link 14d807c2c4 BUGFIX for issue #1161 (#1328)
Removed broken unused code that tried to set a constant multiple times.

Fixes #1161
Closes #1328
2020-01-24 06:40:30 +01:00
Mark Baker 83a50537b2
Return type docblock fixes (#1305)
* Return type docblock fixes
2020-01-04 22:17:40 +01:00
MarkBaker f8cfff058f Update ChangeLog 2020-01-04 18:55:03 +01:00
oleibman 082266aacd Conditionals - Extend Support for (NOT)CONTAINSBLANKS (#1278)
Support for the CONTAINSBLANKS conditional style was added a while ago.
However, that support was on write only; any cells which used
CONTAINSBLANKS on a file being read would drop that style.

I am also adding support for NOTCONTAINSBLANKS, on read and write.
2020-01-04 18:50:04 +01:00
oleibman 1c6dd8923e Handle Error in Formula Processing Better for Xls (#1267)
* Handle Error in Formula Processing Better for Xls

When there is an error writing a formula to an Xls file,
which seems to happen when a defined name is part of a formula,
the cell is currently left blank. A better result would be to
write the calculated value of the formula.

* Making Changes Suggested in Review

Per comment from Mark Baker:
   1. Made return codes from writeFormula into constants.
   2. Skipped redundant call to getCellValue when possible.
   3. Added support for bool type, adding additional tests
      for bool and string.
Per comment from PowerKiki:
   1. Used standardized convention for assigning file name in test.
      Since before this change, save would throw Exception, I kept
      the unlink for the file in tearDown.
2020-01-04 18:34:21 +01:00
Mark Baker 1b2c99b190
Initial unit test for locale floats (#1304)
* Initial unit test for locale floats
This will require potential modification of the TravisCI environment to support other locales

* var_dump to check output on TravisCI

* Fix assertions for double/float and with/without line reference

* Style in unit test
2020-01-04 18:09:46 +01:00
MarkBaker 596aecab68 Update changelog 2020-01-04 00:32:27 +01:00
oleibman afd070a756 Handle ConditionalStyle NumberFormat When Reading Xlsx File (#1296)
* Handle ConditionalStyle NumberFormat When Reading Xlsx File

ReadStyle in Reader/Xlsx/Styles.php expects numberFormat to be a string.
However, when reading conditional style in Xlsx file, NumberFormat
   is actually a SimpleXMLElement, so is not handled correctly.
While testing this change, it turned out that reader always expects
   that there is a "SharedString" portion of the XML, which is not
   true for spreadsheets with no string data, which causes a
   run-time message.
Likewise, when conditional number format is not one of the built-in
   formats, a run-time message is issued because 'isset' is used
   to determine existence rather than 'array_key_exists'.
The new workbook added to the testing data demonstrates both those
   problems (prior to the code changes).

* Move Comment to Resolve Conflict

Github reports conflict involving placement of one comment statement.

* Respond to Scrutinizer Style Suggestion

Change detection for empty SimpleXMLElement.
2020-01-04 00:10:41 +01:00
Mark Baker ed78a02119
Addition cell datatype tests (#1303)
* Additional cell datatype unit tests

* Codestyle appeasement
2020-01-03 23:44:38 +01:00
Mark Baker e19228ecb0
Additional cell datatype unit tests (#1301) 2020-01-03 23:29:53 +01:00
Mark Baker 0417c8cc2b
Fix date tests withut specified year for current year 2020 (#1302) 2020-01-03 23:24:45 +01:00
Markus Salmijärvi ab4c6602cf Fix Xlsx Writer's handling of decimal commas (#1282)
Perform the comma -> period substitution in Xlsx Writer writeCell()
before checking if the decimal value has a period in it. The previous
behavior led to decimals of the form "1,1" to become "1.1.0".
2020-01-03 22:34:10 +01:00
Adrien Crivelli 9fab8900ef
Use latest available Ubuntu 2019-12-19 11:44:12 +01:00