Commit Graph

4600 Commits

Author SHA1 Message Date
oleibman 72f53de761 Update CHANGELOG.md 2024-05-24 21:18:51 -07:00
oleibman a51d3541c0 Php 8.4 Change Affects Test
mime_content_type will recognize files as text/csv rather than text/html.
2024-05-24 21:00:25 -07:00
oleibman 2833ddc22d Csv Reader Allow Use of mimetype=text/html Files Without Extension
Fix #4036. The issue was originally reported as #564 (and #811) and fixed for the most part, but this is a variation that was not covered by the original. Cells with html fragments can cause `mime_content_type` to identify the file as `text\html`. Original fix was to ignore mime_content_type when file extension is 'csv' or 'tsv'. However, if the file does not have one of those extensions, it will be rejected by Csv Reader as invalid mimetype. This PR adds text\html to the list of valid mimetypes.

I imagine that this type of problem might occur for other mimetypes. If any of those are reported in future, it might be better to just add a "suppress mimetype" check option, rather than extending the list forever. Html is unusual in that its rules are so lax, which is why it seems appropriate to add it here.

Note that IOFactory may still identify a file as Html even when intended as Csv. The sample associated with this issue does not fall into this category, but one of the unit tests on this ticket does. The file will still be read correctly by Csv Reader, but IOFactory load may cause it to use Html Reader instead.
2024-05-22 08:24:06 -07:00
oleibman 2ed696f0a2 Merge pull request #4030 from oleibman/condxls
Xls Conditional Format Improvements
2024-05-19 15:36:44 +00:00
oleibman 623efc0211 Update CHANGELOG.md 2024-05-19 08:33:40 -07:00
oleibman 1a187d689b Merge branch 'master' into condxls 2024-05-19 08:15:10 -07:00
oleibman f2a934ae6d Merge pull request #4027 from oleibman/issue4025
Do Not Output Alignment and Protection for Conditional Formats
2024-05-19 15:07:44 +00:00
oleibman f5c1e8796c Merge pull request #4031 from oleibman/powernullarg
POWER Needs to Accept NULL Args
2024-05-16 23:30:15 +00:00
oleibman 989a44d001 Update CHANGELOG.md 2024-05-16 16:26:53 -07:00
oleibman 26d58b4fde Merge branch 'master' into powernullarg 2024-05-16 14:25:03 -07:00
oleibman 1314f82408 Merge pull request #4029 from SchmidtClaudia/issue4028
Incorrect reader used for CSV files with BOM #4028
2024-05-16 19:00:19 +00:00
oleibman f8d994b6e7 POWER Needs to Accept NULL Args
Investigating issue #1622, I found that its extremely complicated formula, which had been leading to an incorrect result, now led to an exception. I am able to fix the exception; unfortunately, I am no closer to resolving the original issue. So I'll apply the baby step while continuing to investigate. Function POWER had changed from untyped args to a defined set of types. The set of types was determined according to the doc block, but that was incomplete - it had neglected to include `null` and `bool`. This PR corrects the function prototype and the doc block, and adds the missing tests for those conditions.
2024-05-16 00:25:47 -07:00
Claudia Schmidt 8091396b52 check HTML syntax on files starting with a BOM 2024-05-16 07:52:41 +02:00
oleibman 5763de4c44 Scrutinizer Recommendation 2024-05-15 19:29:09 -07:00
oleibman 0f515eee0b Xls Conditional Format Improvements
While researching another problem, I noticed that font color was not working as expected for Xls Conditional Formats, at least not when a "non-standard" color is used. In such cases, the color might wind up being rendered as black. The reason is as follows. Xls Writer includes a color palette which is dynamically generated from the (non-Conditional) styles used in the workbook. Any colors used in the workbook are indexes to this dynamic palette. However, Conditional colors use a static palette found in class ColorMap to determine the index, so the determination of index will often not find a match, and, if a match is found, it is not necessarily correct. (Also, the ColorMap method was case-sensitive and needs to be insensitive.)

In order to correct this, the `addColor` method in Xls Writer Workbook needs to be accessible to the Conditional logic which is found in Xls Writer Worksheet. This is accomplished by passing the Workbook in the Worksheet's constructor, and changing the method to public, and changing Conditional Font to use this method rather than ColorMap.

The logic for Conditional Fill colors is similarly changed. Although Xls Conditional Fill has appeared to just not work, I was finally able to figure out the problem. Excel Xls Conditional Fill with fill type Solid requires that the fill color be specified as startColor, and that endColor be omitted. Our conditional samples used endColor, and are now changed to use startColor instead; the same is true for our online documentation, and for some tests. Xlsx continues to work as expected, and now Xls does at least some of the time. If the condition is one that Excel Xls does not recognize (e.g. cell contains), it will, of course, not work. A surprising situation that also doesn't work is the use of ISODD or ISEVEN in formulas. Those are "add-in functions" which are handled differently than other functions, and I'm not sure how to support them. I will document this in issue #3403.

Samples 08_Conditional_Formatting(_2) had produced corrupt Xls versions. This turned out to be because the code was using hash codes to avoid having to write out duplicate conditionals; this is often a good idea, but not in this case. Allowing the duplicates fixes the corruption problem.

Conditional Border colors also ought to figure in this change, but the current code does not support Border colors, and I have not yet been able to figure out how to implement it (BIFF format can be very messy to figure out).

With this change, I could delete ColorMap altogether. However, it is a public class with a static public method, so maybe someone is using it for a purpose I'm not familiar with. I will just deprecate it.
2024-05-15 17:41:34 -07:00
oleibman 40adbfe2ff Remove 2 Unneeded Statements 2024-05-13 18:01:21 -07:00
oleibman fe2fc36063 Do Not Output Alignment and Protection for Conditional Formats
Fix #4025. With Conditional Formatting, Excel can change Font, Fill, Borders, and NumberFormat. It does not support Alignment nor Protection, at least not natively. This PR removes all code supporting Conditional Alignment or Protection from Xlsx and Xls Writer. Attached to the issue report is a spreadsheet where a conditionally formatted merged cell shows its value twice when Alignment is included with the Conditional Style; it is fixed by this PR. It is not entirely certain which particular combination of CF, Alignment, Merge, AutoFilter, and right-to-left sheet alignment trigger this problem. I am sure that it shows up for Vertical Alignment Center, and I am sure that Xls Writer (which is somewhat buggy anyhow regarding CF support - see issue #3403) has the same problem. The now-unused Xls code is commented out rather than deleted, for documentation purposes.
2024-05-13 17:26:51 -07:00
Adrien Crivelli 563de5f3da Merge pull request #4024 from PHPOffice/php81
Updates dependencies
2024-05-11 07:39:28 +00:00
Adrien Crivelli ab4e834777 Updates dependencies 2024-05-11 14:13:29 +07:00
Adrien Crivelli 8968062e8d Drop PHP 8.0 support
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

Also consolidate documentation in a single place, not in the README,
because it's a pain to maintain almost-duplicated-but-not-really
documentation.
2024-05-11 14:09:30 +07:00
Adrien Crivelli dbed77bd3a 2.1.0 2.1.0 2024-05-11 11:17:56 +07:00
oleibman 791c8cf9a5 Merge pull request #4019 from oleibman/issue3995
Html Reader Non-UTF8 Charsets
2024-05-10 06:28:21 +00:00
oleibman bdcbc0481b Update reading-and-writing-to-file.md 2024-05-09 23:21:26 -07:00
oleibman f8e31b367b Update CHANGELOG.md 2024-05-09 23:07:12 -07:00
oleibman 4577f615c4 Merge branch 'master' into issue3995 2024-05-09 22:49:11 -07:00
oleibman 148165cbe9 Make New Function Static 2024-05-08 23:37:13 -07:00
oleibman d38b7cb35f Merge pull request #4016 from oleibman/stan9a
Better Definitions for Mixed Parameters and Values Part 1 of Many
2024-05-09 06:28:54 +00:00
oleibman b2befb4426 Correct Wrong-Case Directory Name 2024-05-06 16:50:02 -07:00
oleibman 09c9a310a0 Html Reader Non-UTF8 Charsets
Fix #3995. Fix #866. Fix #1681. Php DOM loadhtml defaults to character set ISO-8859-1, but our data is UTF-8. So Html Reader alters its html so that loadhtml will not misinterpret characters outside the ASCII range. This works for UTF-8, but breaks other charsets. However, loadhtml uses the correct non-default charset when charset is specified in a meta tag, or when the html starts with a BOM. So, it is sufficient for us to alter the non-ASCII characters only when (a) the data does not start with a BOM, and (b) there is no charset tag.

This will allow us to use:
- UTF-8 files or snippets without BOM, with or without charset
- UTF-8 files with BOM (charset should not be specified and will be ignored if it is)
- UTF-16 files with BOM (charset should not be specified and will be ignored if it is)
- all charsets which are ASCII-compatible for 0x00-0x7f when the charset is declared. This applies to ASCII itself, many Windows and Mac charsets, all of ISO-8859, and most CJK and other-language-specific charsets.

We cannot use:
- UTF-16BE or UTF-16LE declared in a meta tag
- UTF-32, with or without a BOM (browser recommendation is to not support UTF-32, and most browsers do not support it)
- unknown (to loadhtml) or non-ASCII-compatible charsets (EBCDIC?)

I will note that the way I detect the `charset` attribute is imperfect (e.g. might find it in text rather than a meta tag). I think we'd need to write a browser to get it perfect. Anyhow, it is about the same as XmlScanner's attempt to find the `encoding` attribute, and, if it's good enough there, it ought to be good enough here.
2024-05-06 16:43:23 -07:00
oleibman 8d5577a3c4 Improved Test for ConvertUOM
Scrutinizer balked at quotes around key 'Unit Name'; no reason not to use 'UnitName' instead.

Having done that, several ConvertUOM tests seemed a little unconvincing. Replaced them with improved versions.
2024-05-05 06:14:28 -07:00
oleibman 64f354eb6e Better Definitions for Mixed Parameters and Values Part 1 of Many
Improve documentation within program by making explicit what types of values are allowed for variables described as "mixed". In order to avoid broken functionality, this is done mainly through doc-blocks. This will get us closer to Phpstan Level 9, but many changes will be needed before we can consider that.

Executable code change is to add 2 new methods to Cell - `getValueString` and `getCalculatedValueString`, which are the same as the methods without the String suffix, except that they always return a string result. These are invoked at several places in the code where it makes sense, in particular by Writer code.
2024-05-05 04:37:46 -07:00
oleibman c56a58358e Merge pull request #4006 from oleibman/issue4004
RTL Text Alignment in Xlsx Comment
2024-05-05 11:17:55 +00:00
oleibman 5d1d8671a6 Update CHANGELOG.md 2024-05-05 04:14:24 -07:00
oleibman 4a7fa143f7 Merge pull request #4007 from oleibman/issue4001
Xml Reader Rich Text
2024-05-05 04:26:34 +00:00
oleibman d2a69aec9d Update CHANGELOG.md 2024-05-04 21:13:31 -07:00
oleibman db602bde89 Merge branch 'master' into issue4001 2024-05-04 21:05:15 -07:00
oleibman 8485cd195f Merge pull request #4003 from oleibman/issue3999
Improvements to Xml Reader
2024-05-05 03:55:44 +00:00
oleibman 8441d3d899 Merge pull request #4011 from PHPOffice/dependabot/composer/phpstan/phpstan-1.10.67
Bump phpstan/phpstan from 1.10.66 to 1.10.67
2024-05-01 18:15:03 +00:00
oleibman e64d99a91f Merge branch 'master' into dependabot/composer/phpstan/phpstan-1.10.67 2024-05-01 10:57:17 -07:00
oleibman 18bc613ec8 Update Slk.php 2024-05-01 10:50:52 -07:00
dependabot[bot] f012091c81 Bump phpstan/phpstan from 1.10.66 to 1.10.67
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 1.10.66 to 1.10.67.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Changelog](https://github.com/phpstan/phpstan/blob/1.11.x/CHANGELOG.md)
- [Commits](https://github.com/phpstan/phpstan/compare/1.10.66...1.10.67)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-01 17:49:27 +00:00
oleibman 13fe27182c Merge pull request #4012 from PHPOffice/dependabot/composer/tecnickcom/tcpdf-6.7.5
Bump tecnickcom/tcpdf from 6.7.4 to 6.7.5
2024-05-01 17:46:44 +00:00
oleibman ae59fe429e Merge pull request #4010 from PHPOffice/dependabot/composer/friendsofphp/php-cs-fixer-3.54.0
Bump friendsofphp/php-cs-fixer from 3.53.0 to 3.54.0
2024-05-01 17:45:38 +00:00
oleibman 1eaadb3643 Merge pull request #4009 from PHPOffice/dependabot/composer/squizlabs/php_codesniffer-3.9.2
Bump squizlabs/php_codesniffer from 3.9.1 to 3.9.2
2024-05-01 17:45:17 +00:00
oleibman 1d83e38ad1 Merge pull request #4008 from PHPOffice/dependabot/composer/dompdf/dompdf-2.0.8
Bump dompdf/dompdf from 2.0.4 to 2.0.8
2024-05-01 17:44:56 +00:00
dependabot[bot] 0543c1ff8d Bump tecnickcom/tcpdf from 6.7.4 to 6.7.5
Bumps [tecnickcom/tcpdf](https://github.com/tecnickcom/TCPDF) from 6.7.4 to 6.7.5.
- [Changelog](https://github.com/tecnickcom/TCPDF/blob/main/CHANGELOG.TXT)
- [Commits](https://github.com/tecnickcom/TCPDF/compare/6.7.4...6.7.5)

---
updated-dependencies:
- dependency-name: tecnickcom/tcpdf
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-01 11:42:11 +00:00
dependabot[bot] d0198b8720 Bump friendsofphp/php-cs-fixer from 3.53.0 to 3.54.0
Bumps [friendsofphp/php-cs-fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) from 3.53.0 to 3.54.0.
- [Release notes](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases)
- [Changelog](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/CHANGELOG.md)
- [Commits](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.53.0...v3.54.0)

---
updated-dependencies:
- dependency-name: friendsofphp/php-cs-fixer
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-01 11:41:59 +00:00
dependabot[bot] f19eac78d6 Bump squizlabs/php_codesniffer from 3.9.1 to 3.9.2
Bumps [squizlabs/php_codesniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer) from 3.9.1 to 3.9.2.
- [Release notes](https://github.com/PHPCSStandards/PHP_CodeSniffer/releases)
- [Changelog](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/CHANGELOG.md)
- [Commits](https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.9.1...3.9.2)

---
updated-dependencies:
- dependency-name: squizlabs/php_codesniffer
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-01 11:41:53 +00:00
dependabot[bot] 9167f00278 Bump dompdf/dompdf from 2.0.4 to 2.0.8
Bumps [dompdf/dompdf](https://github.com/dompdf/dompdf) from 2.0.4 to 2.0.8.
- [Release notes](https://github.com/dompdf/dompdf/releases)
- [Commits](https://github.com/dompdf/dompdf/compare/v2.0.4...v2.0.8)

---
updated-dependencies:
- dependency-name: dompdf/dompdf
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-01 11:41:48 +00:00
oleibman d40a1cfa52 Xml Reader Rich Text
Fix #4001. Thanks to @SlowFox71 who reported the problem and developed most of the solution. This PR adds Rich Text support to the XML reader. The Xml Spreadsheet stores Rich Text as Html tags, children of the ss:Data tag using a specific namespace. These can be parsed into a RichText object using existing method Helper/Html::toRichTextObject. There are 2 items which need special attention.

First, for attributes like bold or italic, Excel uses the appropriate Html tag (e.g. `<B>`). However, for an attribute like color, Excel uses `<Font html:Color="#FF0000">`, with a prefix on the Color tag. PhpSpreadsheet's Html parser cannot cope with the prefix. The parser is changed to strip `html:` from attribute names for the Font tag.

The example cited by the user used a `<BR />` to indicate a line break in the data. However, it appears that, at least some of the time, Excel will instead use `&#10;` to indicate a line break. The existing parser reduces one or more whitespace characters in the text to a single space, and so `&#10;` will wind up disappearing. I am not sure why the existing code does this, but I do know that I am not willing to break it. Instead, I've added an optional boolean parameter `$preserveWhiteSpace` to `toRichTextObject`. If false (default), the existing logic will be used; but if true, substitution for whitespace characters in the text will not happen.
2024-04-30 23:51:13 -07:00