Commit Graph

26 Commits

Author SHA1 Message Date
jenasnic b2d572c8bb Fix missing font index with some XLS files (#3734)
* Fix missing font index with some XLS files

* Add test case

* Improve Test

---------

Co-authored-by: JC <jcopin@nodevo.com>
Co-authored-by: jenasnic
2023-09-18 01:33:33 -07:00
oleibman 406988e53d SetCalculatedValue Avoid Casting String to Numeric (#3685)
Fix #3658. Readers will call `setCalculatedValue` to save the original calculated value for a cell that contains a formula; this affects the result of `getOldCalculatedValue`. The set routine automatically casts numeric values to float, which is not appropriate when the calculated value is explicitly set to a string type. An optional parameter is added to the set routine to indicate whether a cast is appropriate (default is true so userland uses of this method will remain unaffected). The readers for Xlsx, Xls, Xml, Ods, and Slk are all changed to set the new parameter appropriately. Gnumeric saves the formula, but does not appear to save the result, so no change is needed there. Html and Csv save the result but not the formula (for preCalculateFormulas true - they save the formula but not the result for false), so no change is needed for them.

It is not clear what the use case is for oldCalculatedValue, but it does date back to PhpExcel. A possible use case is demonstrated in the new tests - Excel function INFO is not implemented, so getCalculatedValue will generally return null on such a cell, but will return oldCalculatedValue when it sees that the function is not implemented but oldCalculatedValue has been set (typically by loading an existing spreadsheet), so the result that is on the spreadsheet will be available to the program which loaded it.

Reading a spreadsheet which has been created with preCalculateFormulas false will, or at least should, result in a null oldCalculatedValue. This was true for Xls, Xml, and Slk. Xlsx was actually storing 0 in this situation; that wasn't precisely a problem, but it wasn't necessary and seems misleading. Xlsx Writer is changed to no longer set a value in this situation. This is technically a break, but the existing code was wrong; one unit test needed a very minor modification as a result of this change.
2023-08-26 07:17:55 -07:00
oleibman 37a8a56299 Read Code Page for Xls ListWorksheetInfo/Names for BIFF5 (#3672)
* Read Code Page for Xls ListWorksheetInfo/Names for BIFF5

Fix #3671. Xls reader was not processing Code Page as part of functions ListWorksheetInfo/Names, which was causing them to fail for for BIFF5 (and BIFF7); this was not a problem for BIFF8. There were no unit tests for these functions for either BIFF5 or BIFF8. There are now.

* Add getVersion and getCodePage Methods

These came about because test file for non-standard codepage was supposed to be BIFF5, but turned out to be BIFF8 using UTF-16 with some string data otherwise encoded. Add a BIFF5 equivalent (some hex editing was required), and the means to distinguish one from the other.

* Found MACCENTRALEUROPE Text in BIFF8

It was used for 'Last Modified By' property, even though bulk of spreadsheet uses UTF-16LE. Add a test.
2023-08-16 22:45:55 -07:00
oleibman ac1172810e Another Xls Coverage Change (#3385)
I hadn't noticed some minor corruption in a file. It is fixed. Xls now supports BAHTTEXT as _xlfn.BAHTTEXT, not as an index to a list of built-in functions, so it is no longer suitable for this test and is removed from the spreadsheet. TRANSPOSE changes, e.g. A1:B2 to {1,2;3,4}, and the Xls Writer Parser has trouble with that, so its test is also removed from the test spreadsheet.
2023-02-20 12:15:22 -08:00
oleibman 28fb962cdb Complete Functions Coverage for Xls (except GETPIVOTDATA) (#3383)
Finish the work started in PR #3371 and PR #3340.
2023-02-20 06:07:12 -08:00
oleibman df9e0da514 Additional Functions Coverage for Reader Xls (#3371)
PR #3340 increased coverage in Reader Xls for most functions. Some of the omissions from that PR (see below) were intended from the start. However, the set of (BINOMDIST, EXPONDIST, GAMMADIST, NORMDIST, POISSON, WEIBULL, and FIXED) were not intended to be omitted; they just did not seem to work. Having had time to research, it appears that the problem is not those functions themselves, but rather the use of Boolean constants as function arguments (see issue #3369). Knowing that, it is possible to add those missing functions back in, just taking care to use `0` or `1` or `TRUE()` or `FALSE()` rather than boolean constants as arguments. No update to source or test code; just adding a few new cells to an Xls spreadsheet.

Functions still omitted because they return array results:
- GROWTH
- LINEST
- LOGEST
- MINVERSE
- MMULT
- TRANSPOSE
- TREND

Functions still omitted because they are not implemented in PhpSpreadsheet:
- BAHTTEXT
- CELL
- FREQUENCY
- GETPIVOTDATA
2023-02-15 22:21:15 -08:00
oleibman a2282ecb79 Additional Coverage for Reader Xls (#3340)
* Additional Coverage for Reader Xls

More than 750 lines are newly covered, increasing overall coverage on my machine from 91.14% to 93.09%.

* Update FormulasTest.php
2023-02-03 07:42:43 -08:00
MarkBaker 84d6d98348 Unit tests for correctly handling hidden merged cells in Readers 2022-09-16 12:27:57 +02:00
MarkBaker bb7e083745 Add Hidden Worksheet unit tests for other Readers 2022-05-24 14:40:45 +02:00
MarkBaker fd44f47f62 Fix issue with Xls Reader converting all named ranges from absolute to relative 2022-05-12 12:47:18 +02:00
redforks d593617287 Fix font index problem (#2642)
* Fix font index problem

* Update RichTextSizeTest.php

Eliminate Phpstan failure.

* Update RichTextSizeTest.php

Eliminate now-unused import.
2022-04-17 08:27:28 -07:00
MarkBaker 0a9d15407f Suport fill style and color for reading CF Formats 2022-03-19 19:47:14 +01:00
Mark Baker 23e2d702ff Merge branch 'master' into Xls-Reader-Conditional-Formatting 2022-03-19 16:21:14 +01:00
MarkBaker be8c444951 More minor tweaks 2022-03-19 16:15:48 +01:00
MarkBaker c73bb612e0 Unit tests for Xls Reader DataValidation 2022-03-19 12:04:14 +01:00
MarkBaker 45c08d6cd4 Initial work on reading conditional styles for the Xls Reader
Successfully reading the CF ranges and CF rules; not yet reading the styles
2022-03-18 21:09:32 +01:00
MarkBaker cb5a451aaf Initial work on Reading Conditional Formatting from Xls files 2022-03-15 13:25:23 +01:00
oleibman f24dcc7911 Another Undefined Index in Xls Reader (#2470)
Fix #2463. These continue to dribble in regularly.
2021-12-31 13:43:59 -08:00
Georgiy fea0e34e90 fix #1114 issue (#2308)
* fix #1114 issues

* fixed code style

* update for all version

* add test for bag 1114

* remove comment

Co-authored-by: georgio <georgiokot@gmail.cim>
2021-10-03 09:29:23 -07:00
oleibman d7ac7021c6 Apache OpenOffice Creates Xls Using Wrong Case for Number Format General (#2242)
See issue #2239. Problem is dealt with at the source, by making sure that Reader Xls checks for use of 'GENERAL' rather than 'General'. There doesn't seem to be a reason to test in other places, or to test for other casing variants.
2021-08-08 08:24:03 -07:00
oleibman 8729a68338 Xls Reader Handle MACCENTRALEUROPE With or Without Hyphen (#2213)
* Xls Reader Handle MACCENTRALEUROPE With or Without Hyphen

Fixes issue #549 and https://github.com/Maatwebsite/Laravel-Excel/issues/989 (which is the source of the new test file). Some systems accept MACCENTRALEUROPE as the name for the appropriate encoding, and some accept MAC-CENTRALEUROPE. I fortunately have access to at least one of each type, and have run the tests on each.

CodePage.php has an array of translations from codepage number to string. I now allow the value to itself be an array; if so, the code will test each in turn to see if it can be used in iconv. I did not go fishing for other similar problems. If such show up, they can be dealt with in the same manner as this one. I don't really expect others, since this is a problem not merely for Xls, but, even then, it applies only to BIFF5 and earlier.

I also moved XlsTest from Reader to Reader/Xls.

* Cache Successful Result For Future Use

Per suggestion from @MarkBaker
2021-07-12 03:02:47 +02:00
Mark Baker 74b02fb31c Fix for the BIFF-8 Xls colour mappings in the Reader (#2156)
* Fix for the BIFF-8 Xls colour mappings in the Reader
* Unit test for reading colours, writing hen rereading and ensuring that the RGB values have not changed
2021-06-13 21:46:49 +02:00
Gianluca Giovinazzo 51cb21297d Fix for bug #1592 (UPDATED) (#1623)
* Fix for Xls when BIFF8 SST (FCh) has bad Shared string length
2020-12-17 19:41:07 +01:00
MarkBaker d009347e25 Forgot to check in the test files for the unit tests 2020-07-05 16:28:46 +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
bayzhanov 08b4456641 Xls file threw exception during open by Xls reader
Ignore some exception in property, if stream is empty

Fixes #402
Fixes #659
2018-10-07 18:49:01 +11:00