Commit Graph

2306 Commits

Author SHA1 Message Date
MarkBaker 8629337101 Retrieving print/page setup for the Xml Reader 2020-07-05 16:22:35 +02:00
MarkBaker 84ba21400c Fix datatype conversion for Gnumeric values 2020-07-04 00:28:16 +02:00
MarkBaker aecef1372f Read Ods Margins 2020-07-03 19:26:57 +02:00
MarkBaker c288c11d01 Failed to avoid the void trap 2020-07-01 20:06:36 +02:00
MarkBaker e644cc72d0 Additional print information for Gnumeric 2020-07-01 19:55:25 +02:00
MarkBaker 163da06505 Horizontal an dVertical centering for the Ods Reader 2020-07-01 14:50:13 +02:00
MarkBaker 736d9ffd3b Gotta keep phpcs happy, even if it is only a blank line between property declarations 2020-06-30 22:45:08 +02:00
MarkBaker 4dadf4a5c8 Refactor reading Ods Page Settings into a separate class 2020-06-30 22:23:33 +02:00
MarkBaker 13a3363410 Return void, just to keep phpcs happy 2020-06-30 19:15:08 +02:00
MarkBaker 3780072ae9 Retrieve basic print settings in the Ods Reader 2020-06-30 19:07:56 +02:00
MarkBaker 1f865c84c0 Keep phpcs happy 2020-06-30 07:24:12 +02:00
MarkBaker fbb04c1f82 Xls Writer changes to save print order 2020-06-30 07:01:51 +02:00
MarkBaker 4060cdec7e Fix comment 2020-06-30 01:11:53 +02:00
MarkBaker 362b18ca12 Read Print Settings Page Order in Xls Reader
And eliminate switch for simple boolean portrait/landscape option
2020-06-30 00:53:10 +02:00
MarkBaker 21b34f0afb pageOrder is nullable 2020-06-29 20:27:47 +02:00
MarkBaker a0bba38281 Support pageOrder in page setup for Xlsx Reader and Writer 2020-06-29 20:15:41 +02:00
Adrien Crivelli 8712fb0424
Drop polyfill that are not needed since PHP 7.2 2020-06-29 11:28:05 +09:00
Adrien Crivelli 39f1a61120
CHANGELOG placeholder 2020-06-29 10:52:54 +09:00
Adrien Crivelli 73fe58fdc9
1.14.0 2020-06-29 10:51:21 +09:00
Adrien Crivelli 96e493ca51
Update CHANGELOG 2020-06-29 10:23:33 +09:00
paulkned 7f23ccb69d
Added support for the WEBSERVICE function (#1409)
Co-authored-by: Paul Kievits <kievits@rsm.nl>
2020-06-29 10:17:58 +09:00
Adrien Crivelli e74ef3a802
Generate API doc on tag only
Because it doesn't need to be run on every PR and documenting
only release is exactly what we want
2020-06-29 10:15:42 +09:00
Pavel Alazankin 6caa0cb4f5
add ability to set codepage explicitly for BIFF5 (#1484)
If BIFF5 excel 95 file doesn't have codepage record, the default codepage CP1252 is used and can't be change.
That causes to problems with decoding cyrillic text.
2020-06-28 23:39:38 +09:00
Adrien Crivelli 93fbf8a938
Update CHANGELOG 2020-06-28 22:03:37 +09:00
Adrien Crivelli f1fb8dcf1f
Don't ouput row and columns without any cells in HTML writer
If row or column dimensions are accessed, then HTML writer would
still generate lots of empty cells, to show nothing at all. This
now ignore row and column dimensions to only output cell that
actually exists (even if those cells are empty).

Fixes #1235
Close #1537
2020-06-28 22:03:37 +09:00
Adrien Crivelli a90bf863ab
Merge pull request #1499 from oleibman/htmledit
Add ability to save edited Html/Pdf
2020-06-28 17:46:56 +09:00
Adrien Crivelli 14a0fa4cd0
New members should always be private 2020-06-28 17:35:10 +09:00
Adrien Crivelli 5e64479c06
Document the callback 2020-06-28 17:34:50 +09:00
Adrien Crivelli 2896e6ceb9
Consistent regexp escaping 2020-06-28 17:34:32 +09:00
Adrien Crivelli 321dfc7a3d
Upgrad PHP deps 2020-06-28 16:29:13 +09:00
MarkBaker 65a94abeca And now phpcs is telling me to fix my grammar 2020-06-27 23:10:28 +02:00
Mark Baker a264cafe4c
Helper class for the conversion of cell addresses between A1 and R1C1 formats, and vice-versa (#1558)
* Helper class for the conversion of cell addresses between A1 and R1C1 formats, and vice-versa
2020-06-27 23:03:25 +02:00
Mark Baker 10a4a95d67
Handle Ranges formatted as 3-d ranges, as long as the references are both to the same worksheet (#1540) 2020-06-21 14:41:51 +02:00
MarkBaker d57cce9aa9 Update changelog 2020-06-20 20:27:17 +02:00
Dawid Warmuz 859bef1901
Add support for IFS() logical function (#1442)
* Add support for IFS() logical function

* Use Exception as false value in IFS logical function, so it never collides with string in spreadsheet
2020-06-20 18:21:19 +02:00
Christoph Ziegenberg ca506ba87f
Corrected date time detection (#1492)
* Corrected date time detection

German and Swiss ZIP codes (special formats provided in German Excel versions) were detected as date time value, because the regular expression for date time formats falsely matched their formats ("\C\H\-00000" and "\D-00000").
2020-06-20 17:15:38 +02:00
MarkBaker acd2ba01df Updates to changelog 2020-06-19 22:38:31 +02:00
MarkBaker c04d0185d9 Updates to changelog 2020-06-19 22:11:07 +02:00
oleibman b3d30f4cbc
Xls Writer - Correct Timestamp Bug, Improve Coverage (#1493)
* Xls Writer - Correct Timestamp Bug, Improve Coverage

I believe that Xls Writer is 100% covered now.

The Xls Writer sets its timestamp incorrectly. The problem is actually
in Shared/Ole::localDateToOLE, which converts its timestamp using
gmmktime; mktime is correct. If I save a file at 3:00 p.m. in San Francisco,
this bug means the time is actually recorded as 3:00 p.m. UTC.
A consequence of this is that if you use Phpspreadsheet to read the
file and save it as a new Xls, the creation timestamp goes further
and further back in time with each generation (or further forward
if east of Greenwich). One of the tests added confirms that
the creation timestamp is consistent with the start and end times
of the test.

The major change in coverage is adding tests to save GIF and BMP
images, which aren't supported in Xls, but are converted to PNG
in the PhpSpreadsheet code.
2020-06-19 21:08:36 +02:00
Arne Jørgensen a5a0268050
Fix HLOOKUP on single row (#1512)
Fixes a bug when doing a HLOOKUP on a single row.

```php
<?php

require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;

$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();

/**
 * Single row.
 */
$singleRow = "=HLOOKUP(10, {5, 10, 15}, 1, 0)";
$sheet->getCell('A1')->setValue($singleRow);

// Should echo 10, but echos '#N/A' and some PHP notices and warnings.
echo $sheet->getCell('A1')->getCalculatedValue() . PHP_EOL;

/**
 * Multiple rows.
 */
$multipleRows = "=HLOOKUP(10, {5, 10, 15; 20, 25, 30}, 1, 0)";
$sheet->getCell('A2')->setValue($multipleRows);

// Should echo: 10 and also does.
echo $sheet->getCell('A2')->getCalculatedValue() . PHP_EOL;
```

Co-authored-by: Mark Baker <mark@lange.demon.co.uk>
2020-06-19 21:06:41 +02:00
oleibman 38fab4e632
Fix for #1505 (#1525)
This problem is the same as #1238, which was resolved by #1239.
For that issue, the fix was to check in one place whether
$this->mapCellXfIndex[$xfIndex] was set before using it.
The sample spreadsheet supplied as a description for this
problem had exactly the same problem in 2 other places in the code.
In addition, there were 7 other places in the code where that
particular item was used unchecked. This fix corrects all 9 locations.
The spreadsheet supplied with the problem is used as the basis
for some new tests, which particularly test column dimensions
and styles, the problems involved in this case.
2020-06-19 21:01:18 +02:00
oleibman 3844186397
Fix for Issue 1495 (#1500)
#1495 reports that ActiveSheet can change when calculation
involves jumping around between sheets.
Save index before calculation, restore after, add test.
2020-06-19 20:57:20 +02:00
Arne Jørgensen 1a44ef9109
Fix MATCH when comparing different numeric types (#1521)
Let MATCH compare numerics of different type (e.g. integers and floats).

```php
<?php

require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;

$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();

// Row: 1, 2, 3, 4, 5. MATCH for 4.6.
$sheet->getCell('A1')->setValue(1);
$sheet->getCell('A2')->setValue(2);
$sheet->getCell('A3')->setValue(3);
$sheet->getCell('A4')->setValue(4);
$sheet->getCell('A5')->setValue(5);

$sheet->getCell('B1')->setValue('=MATCH(4.6, A1:A5, 1)');

// Should echo 4, but echos '#N/A'.
echo $sheet->getCell('B1')->getCalculatedValue() . PHP_EOL;

// Row: 1, 2, 3, 3.8, 5. MATCH for 4.
$sheet->getCell('C1')->setValue(1);
$sheet->getCell('C2')->setValue(2);
$sheet->getCell('C3')->setValue(3);
$sheet->getCell('C4')->setValue(3.8);
$sheet->getCell('C5')->setValue(5);

$sheet->getCell('D1')->setValue('=MATCH(4, C1:C5, 1)');

// Should echo 4, but echos 3.
echo $sheet->getCell('D1')->getCalculatedValue() . PHP_EOL;
```

Co-authored-by: Mark Baker <mark@lange.demon.co.uk>
2020-06-19 20:54:04 +02:00
Arne Jørgensen 73c336ac96
Fix exact MATCH on ranges with empty cells (#1520)
Fixes a bug when doing exact match on ranges with empty cells.

```php
<?php

require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;

$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();

// Row: 1, null, 4, null, 8.
$sheet->getCell('A1')->setValue(1);
$sheet->getCell('A3')->setValue(4);
$sheet->getCell('A5')->setValue(8);

$sheet->getCell('B1')->setValue('=MATCH(4, A1:A5, 1)');

// Should echo 3, but echos '#N/A'.
echo $sheet->getCell('B1')->getCalculatedValue() . PHP_EOL;

// Row: 1, null, 4, null, null.
$sheet->getCell('C1')->setValue(1);
$sheet->getCell('C3')->setValue(4);

$sheet->getCell('D1')->setValue('=MATCH(5, C1:C5, 1)');

// Should echo 3, but echos '#N/A'.
echo $sheet->getCell('D1')->getCalculatedValue() . PHP_EOL;
```
2020-06-19 20:51:46 +02:00
oleibman d8b4c3b26e
Fix for #1533 (#1534)
Code assumes that formula whose result starts with # indicates error.
Change to check entire result against error list in Functions.
2020-06-19 20:40:28 +02:00
tyomitch 35c04964cf
#1504: Using non-UTC timezone corrupts dates imported from XML spreadsheet (#1506) 2020-06-19 20:38:06 +02:00
oleibman 262896086a
Improve Coverage for Sylk (#1514)
* Improve Coverage for Sylk

I believe that both BaseReader and Sylk Reader are now 100% covered.

Documentation available for this format is sparse.
It was always incomplete, and in some cases inaccurate.
My goal was to use PhpSpreadsheet to load the test file,
save it as Xlsx, and visually compare the two, then add a test
loaded with assertions. Cell values and calculated values,
and border styles were generally handled pretty well without changes.
Other types of styling were not handled so well. I added a few cells
to exercise some previously uncovered code.

Sylk files must be ASCII. I have deprecated the use of the
setEncoding and getEncoding functions, which had no test cases.
2020-06-19 20:35:44 +02:00
oleibman 73379cdfb1
Improve Coverage for Gnumeric (#1517)
* Improve Coverage for Gnumeric

I believe that both BaseReader and Gnumeric Reader are now 100% covered.

My goal was to use PhpSpreadsheet to load the test file,
save it as Xlsx, and visually compare the two, then add a test
loaded with assertions. Results were generally pretty good,
but there were no tests with assertions. I added a few cells
to exercise some previously uncovered code. Code was extensively
refactored; logic changes are noted below.

Code allowed for specifying document properties in an old format.
I considered removing that, but I found the original spec at
http://www.jfree.org/jworkbook/download/gnumeric-xml.pdf
This allowed me to create an old file, which was not handled
correctly because of namespace differences. The code was corrected
to allow for this difference.

Added support for textRotation.

Mapping of fill types was not correct.

* PHP7.2 Error

One assertion failed under PHP7.2. Apparently there was some change in
the handling of SimpleXMLElement between 7.2 and 7.3. Casting to string
before use eliminates the problem.

* Scrutinizer Recommendations

All minor, solved (hopefully) mostly by casts.

* One Last Scrutinizer Fix

... I hope.
2020-06-19 20:34:02 +02:00
oleibman ce6ac1f040
Fix For #1509 (#1518)
* Fix For #1509

User expected no CSV enclosures after $writer->setEnclosure(''),
which had been changed to be consistent with $reader->setEnclosure('').
Writer will now omit enclosures after code above; no change to Reader.
Tests have been added for this condition.

* Add Option to Write CSV Enclosure Only When Required

Allowing the user to specify no enclosure when writing a CSV can lead to
a situation where PhpSpreadsheet (likewise Excel) will not read the
resulting file as intended, e.g. if any cell contains a delimiter character.
This is demonstrated in new test TestBadReread.
No existing setting will rectify this situation.

A better choice would be to add an option to write the enclosure
only when it is needed, which is what Excel does. The RFC4180 spec at
https://tools.ietf.org/html/rfc4180
states when it is needed - when the cell contains the delimiter,
or the enclosure, or a newline.
New test TestGoodReread demonstrates that the file is read as intended.

The documentation has been updated to describe the new function,
and to change the write example where the enclosure is set to null.

* Scrutinizer Suggestions

3 minor changes, all in tests.
2020-06-19 20:28:57 +02:00
oleibman 82ea1d5596
Fix for #1516 (#1530)
This problem is that ZipStream, in contrast to ZipArchive,
is saving 2 files with the same path. I have opened an issue with
ZipStream, who agree that this appears to be a bug.

For the case in question, PhpSpreadsheet is attempting to save
a file with the same path twice (and unexpectedly succeeding)
because of a clone operation. This fix attempts to rectify the problem
by keeping track of all the paths being saved in the zip file,
and not attempting to save any duplicate paths.

The problem case attempted to save printersettings1.bin twice,
but there are other possible exposures, e.g. by cloning a sheet
with a drawing.The new test cases clone an existing sample which
has both printer settings and drawings.
2020-06-19 20:26:02 +02:00