commit
cca43f0b5b
|
@ -0,0 +1,29 @@
|
|||
name: GithHub Pages
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
github-pages:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP, with composer and extensions
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.4
|
||||
coverage: none # remove xdebug
|
||||
|
||||
- name: Build API documentation
|
||||
run: |
|
||||
curl -LO https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.0.0-rc/phpDocumentor.phar
|
||||
php phpDocumentor.phar --directory src/ --target docs/api
|
||||
|
||||
- name: Deploy to GithHub Pages
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./docs/api
|
|
@ -0,0 +1,150 @@
|
|||
name: Build
|
||||
on: [ push, pull_request ]
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
php-version:
|
||||
- '7.2'
|
||||
- '7.3'
|
||||
- '7.4'
|
||||
- '8.0'
|
||||
|
||||
name: PHP ${{ matrix.php-version }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP, with composer and extensions
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-version }}
|
||||
extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
|
||||
coverage: none
|
||||
|
||||
- name: Get composer cache directory
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: ${{ runner.os }}-composer-
|
||||
|
||||
- name: Delete composer lock file
|
||||
id: composer-lock
|
||||
if: ${{ matrix.php-version == '8.0' }}
|
||||
run: |
|
||||
rm composer.lock
|
||||
echo "::set-output name=flags::--ignore-platform-reqs"
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --no-progress --prefer-dist --optimize-autoloader ${{ steps.composer-lock.outputs.flags }}
|
||||
|
||||
- name: Setup problem matchers for PHP
|
||||
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
|
||||
|
||||
- name: Setup problem matchers for PHPUnit
|
||||
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
||||
|
||||
- name: Test with PHPUnit
|
||||
run: ./vendor/bin/phpunit
|
||||
|
||||
php-cs-fixer:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP, with composer and extensions
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.4
|
||||
extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
|
||||
coverage: none
|
||||
tools: cs2pr
|
||||
|
||||
- name: Get composer cache directory
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: ${{ runner.os }}-composer-
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --no-progress --prefer-dist --optimize-autoloader
|
||||
|
||||
- name: Code style with PHP-CS-Fixer
|
||||
run: ./vendor/bin/php-cs-fixer fix --format=checkstyle | cs2pr
|
||||
|
||||
phpcs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP, with composer and extensions
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.4
|
||||
extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
|
||||
coverage: none
|
||||
tools: cs2pr
|
||||
|
||||
- name: Get composer cache directory
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: ${{ runner.os }}-composer-
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --no-progress --prefer-dist --optimize-autoloader
|
||||
|
||||
- name: Code style with PHP_CodeSniffer
|
||||
run: ./vendor/bin/phpcs -q --report=checkstyle | cs2pr
|
||||
|
||||
coverage:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP, with composer and extensions
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.4
|
||||
extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
|
||||
coverage: pcov
|
||||
|
||||
- name: Get composer cache directory
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: ${{ runner.os }}-composer-
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --no-progress --prefer-dist --optimize-autoloader
|
||||
|
||||
- name: Coverage
|
||||
run: |
|
||||
./vendor/bin/phpunit --coverage-clover coverage-clover.xml
|
||||
curl -LO https://scrutinizer-ci.com/ocular.phar
|
||||
php ocular.phar code-coverage:upload --format=php-clover coverage-clover.xml
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer"
|
||||
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
|
||||
|
||||
<file>samples</file>
|
||||
<file>src</file>
|
||||
<file>tests</file>
|
||||
|
||||
<exclude-pattern>samples/Header.php</exclude-pattern>
|
||||
<exclude-pattern>*/tests/Core/*/*Test\.(inc|css|js)$</exclude-pattern>
|
||||
|
||||
<arg name="report-width" value="200"/>
|
||||
<arg name="parallel" value="80"/>
|
||||
<arg name="cache" value="/tmp/.phpspreadsheet.phpcs-cache"/>
|
||||
<arg name="colors"/>
|
||||
<arg value="np"/>
|
||||
|
||||
<!-- Include the whole PSR12 standard -->
|
||||
<rule ref="PSR12">
|
||||
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
|
||||
</rule>
|
||||
</ruleset>
|
33
.travis.yml
33
.travis.yml
|
@ -5,6 +5,7 @@ php:
|
|||
- 7.2
|
||||
- 7.3
|
||||
- 7.4
|
||||
- nightly
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
@ -13,11 +14,15 @@ cache:
|
|||
|
||||
before_script:
|
||||
# Deactivate xdebug
|
||||
- phpenv config-rm xdebug.ini
|
||||
- if [[ $TRAVIS_PHP_VERSION != nightly ]]; then phpenv config-rm xdebug.ini; fi
|
||||
- if [[ $TRAVIS_PHP_VERSION == nightly ]]; then rm composer.lock; fi
|
||||
- composer install --ignore-platform-reqs
|
||||
|
||||
script:
|
||||
- ./vendor/bin/phpunit
|
||||
- ./vendor/bin/phpunit --color=always --coverage-text
|
||||
|
||||
allow_failures:
|
||||
- php: nightly
|
||||
|
||||
jobs:
|
||||
include:
|
||||
|
@ -26,26 +31,4 @@ jobs:
|
|||
php: 7.4
|
||||
script:
|
||||
- ./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run
|
||||
- ./vendor/bin/phpcs --report-width=200 samples/ src/ tests/ --ignore=samples/Header.php --standard=PSR2 -n
|
||||
|
||||
- stage: Coverage
|
||||
php: 7.4
|
||||
script:
|
||||
- pecl install pcov
|
||||
- ./vendor/bin/phpunit --coverage-clover coverage-clover.xml
|
||||
after_script:
|
||||
- wget https://scrutinizer-ci.com/ocular.phar
|
||||
- php ocular.phar code-coverage:upload --format=php-clover tests/coverage-clover.xml
|
||||
|
||||
- stage: API documentations
|
||||
if: tag is present AND branch = master
|
||||
php: 7.4
|
||||
before_script:
|
||||
- curl -LO https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.0.0-rc/phpDocumentor.phar
|
||||
script:
|
||||
- php phpDocumentor.phar --directory src/ --target docs/api
|
||||
deploy:
|
||||
provider: pages
|
||||
skip-cleanup: true
|
||||
local-dir: docs/api
|
||||
github-token: $GITHUB_TOKEN
|
||||
- ./vendor/bin/phpcs
|
||||
|
|
164
CHANGELOG.md
164
CHANGELOG.md
|
@ -5,12 +5,125 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com)
|
||||
and this project adheres to [Semantic Versioning](https://semver.org).
|
||||
|
||||
## [Unreleased]
|
||||
## Unreleased - TBD
|
||||
|
||||
### Added
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Changed
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Removed
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Ensure that the list of shared formulae is maintained when an xlsx file is chunked with readFilter[Issue #169](https://github.com/PHPOffice/PhpSpreadsheet/issues/1669).
|
||||
- Fix for notice during accessing "cached magnification factor" offset [#1354](https://github.com/PHPOffice/PhpSpreadsheet/pull/1354)
|
||||
|
||||
## 1.15.0 - 2020-10-11
|
||||
|
||||
### Added
|
||||
|
||||
- Implemented Page Order for Xlsx and Xls Readers, and provided Page Settings (Orientation, Scale, Horizontal/Vertical Centering, Page Order, Margins) support for Ods, Gnumeric and Xls Readers [#1559](https://github.com/PHPOffice/PhpSpreadsheet/pull/1559)
|
||||
- Implementation of the Excel `LOGNORM.DIST()`, `NORM.S.DIST()`, `GAMMA()` and `GAUSS()` functions. [#1588](https://github.com/PHPOffice/PhpSpreadsheet/pull/1588)
|
||||
- Named formula implementation, and improved handling of Defined Names generally [#1535](https://github.com/PHPOffice/PhpSpreadsheet/pull/1535)
|
||||
- Defined Names are now case-insensitive
|
||||
- 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
|
||||
- fix resolution of relative named range values in the calculation engine; previously all named range values had been treated as absolute.
|
||||
- Calculation support for named formulae
|
||||
- Support for nested ranges and formulae (named ranges and formulae that reference other named ranges/formulae) in calculations
|
||||
- Introduction of a helper to convert address formats between R1C1 and A1 (and the reverse)
|
||||
- Proper support for both named ranges and named formulae in all appropriate Readers
|
||||
- **Xlsx** (Previously only simple named ranges were supported)
|
||||
- **Xls** (Previously only simple named ranges were supported)
|
||||
- **Gnumeric** (Previously neither named ranges nor formulae were supported)
|
||||
- **Ods** (Previously neither named ranges nor formulae were supported)
|
||||
- **Xml** (Previously neither named ranges nor formulae were supported)
|
||||
- Proper support for named ranges and named formulae in all appropriate Writers
|
||||
- **Xlsx** (Previously only simple named ranges were supported)
|
||||
- **Xls** (Previously neither named ranges nor formulae were supported) - Still not supported, but some parser issues resolved that previously failed to differentiate between a defined name and a function name
|
||||
- **Ods** (Previously neither named ranges nor formulae were supported)
|
||||
- Support for PHP 8.0
|
||||
|
||||
### Changed
|
||||
|
||||
- Improve Coverage for ODS Reader [#1545](https://github.com/phpoffice/phpspreadsheet/pull/1545)
|
||||
- Named formula implementation, and improved handling of Defined Names generally [#1535](https://github.com/PHPOffice/PhpSpreadsheet/pull/1535)
|
||||
- fix resolution of relative named range values in the calculation engine; previously all named range values had been treated as absolute.
|
||||
- Drop $this->spreadSheet null check from Xlsx Writer [#1646](https://github.com/phpoffice/phpspreadsheet/pull/1646)
|
||||
- Improving Coverage for Excel2003 XML Reader [#1557](https://github.com/phpoffice/phpspreadsheet/pull/1557)
|
||||
|
||||
### Deprecated
|
||||
|
||||
- **IMPORTANT NOTE:** This Introduces a **BC break** in the handling of named ranges. Previously, a named range cell reference of `B2` would be treated identically to a named range cell reference of `$B2` or `B$2` or `$B$2` because the calculation engine treated then all as absolute references. These changes "fix" that, so the calculation engine now handles relative references in named ranges correctly.
|
||||
This change that resolves previously incorrect behaviour in the calculation may affect users who have dynamically defined named ranges using relative references when they should have used absolute references.
|
||||
|
||||
### Removed
|
||||
|
||||
- Nothing.
|
||||
|
||||
### Fixed
|
||||
|
||||
- PrintArea causes exception [#1544](https://github.com/phpoffice/phpspreadsheet/pull/1544)
|
||||
- Calculation/DateTime Failure With PHP8 [#1661](https://github.com/phpoffice/phpspreadsheet/pull/1661)
|
||||
- Reader/Gnumeric Failure with PHP8 [#1662](https://github.com/phpoffice/phpspreadsheet/pull/1662)
|
||||
- ReverseSort bug, exposed but not caused by PHP8 [#1660](https://github.com/phpoffice/phpspreadsheet/pull/1660)
|
||||
- Bug setting Superscript/Subscript to false [#1567](https://github.com/phpoffice/phpspreadsheet/pull/1567)
|
||||
|
||||
## 1.14.1 - 2020-07-19
|
||||
|
||||
### Added
|
||||
|
||||
- nothing
|
||||
|
||||
### Fixed
|
||||
|
||||
- WEBSERVICE is HTTP client agnostic and must be configured via `Settings::setHttpClient()` [#1562](https://github.com/PHPOffice/PhpSpreadsheet/issues/1562)
|
||||
- Borders were not complete on rowspanned columns using HTML reader [#1473](https://github.com/PHPOffice/PhpSpreadsheet/pull/1473)
|
||||
|
||||
### Changed
|
||||
|
||||
## 1.14.0 - 2020-06-29
|
||||
|
||||
### Added
|
||||
|
||||
- Add support for IFS() logical function [#1442](https://github.com/PHPOffice/PhpSpreadsheet/pull/1442)
|
||||
- Add Cell Address Helper to provide conversions between the R1C1 and A1 address formats [#1558](https://github.com/PHPOffice/PhpSpreadsheet/pull/1558)
|
||||
- Add ability to edit Html/Pdf before saving [#1499](https://github.com/PHPOffice/PhpSpreadsheet/pull/1499)
|
||||
- Add ability to set codepage explicitly for BIFF5 [#1018](https://github.com/PHPOffice/PhpSpreadsheet/issues/1018)
|
||||
- Added support for the WEBSERVICE function [#1409](https://github.com/PHPOffice/PhpSpreadsheet/pull/1409)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Resolve evaluation of utf-8 named ranges in calculation engine [#1522](https://github.com/PHPOffice/PhpSpreadsheet/pull/1522)
|
||||
- Fix HLOOKUP on single row [#1512](https://github.com/PHPOffice/PhpSpreadsheet/pull/1512)
|
||||
- Fix MATCH when comparing different numeric types [#1521](https://github.com/PHPOffice/PhpSpreadsheet/pull/1521)
|
||||
- Fix exact MATCH on ranges with empty cells [#1520](https://github.com/PHPOffice/PhpSpreadsheet/pull/1520)
|
||||
- Fix for Issue [#1516](https://github.com/PHPOffice/PhpSpreadsheet/issues/1516) (Cloning worksheet makes corrupted Xlsx) [#1530](https://github.com/PHPOffice/PhpSpreadsheet/pull/1530)
|
||||
- Fix For Issue [#1509](https://github.com/PHPOffice/PhpSpreadsheet/issues/1509) (Can not set empty enclosure for CSV) [#1518](https://github.com/PHPOffice/PhpSpreadsheet/pull/1518)
|
||||
- Fix for Issue [#1505](https://github.com/PHPOffice/PhpSpreadsheet/issues/1505) (TypeError : Argument 4 passed to PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet::writeAttributeIf() must be of the type string) [#1525](https://github.com/PHPOffice/PhpSpreadsheet/pull/1525)
|
||||
- Fix for Issue [#1495](https://github.com/PHPOffice/PhpSpreadsheet/issues/1495) (Sheet index being changed when multiple sheets are used in formula) [#1500]((https://github.com/PHPOffice/PhpSpreadsheet/pull/1500))
|
||||
- Fix for Issue [#1533](https://github.com/PHPOffice/PhpSpreadsheet/issues/1533) (A reference to a cell containing a string starting with "#" leads to errors in the generated xlsx.) [#1534](https://github.com/PHPOffice/PhpSpreadsheet/pull/1534)
|
||||
- Xls Writer - Correct Timestamp Bug [#1493](https://github.com/PHPOffice/PhpSpreadsheet/pull/1493)
|
||||
- Don't ouput row and columns without any cells in HTML writer [#1235](https://github.com/PHPOffice/PhpSpreadsheet/issues/1235)
|
||||
|
||||
## 1.13.0 - 2020-05-31
|
||||
|
||||
### Added
|
||||
|
||||
- Support writing to streams in all writers [#1292](https://github.com/PHPOffice/PhpSpreadsheet/issues/1292)
|
||||
- Support CSV files with data wrapping a lot of lines [#1468](https://github.com/PHPOffice/PhpSpreadsheet/pull/1468)
|
||||
- Support protection of worksheet by a specific hash algorithm [#1485](https://github.com/PHPOffice/PhpSpreadsheet/pull/1485)
|
||||
|
||||
### Fixed
|
||||
|
||||
|
@ -21,6 +134,8 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- Several improvements in HTML writer [#1464](https://github.com/PHPOffice/PhpSpreadsheet/pull/1464)
|
||||
- Fix incorrect behaviour when saving XLSX file with drawings [#1462](https://github.com/PHPOffice/PhpSpreadsheet/pull/1462),
|
||||
- Fix Crash while trying setting a cell the value "123456\n" [#1476](https://github.com/PHPOffice/PhpSpreadsheet/pull/1481)
|
||||
- Improved DATEDIF() function and reduced errors for Y and YM units [#1466](https://github.com/PHPOffice/PhpSpreadsheet/pull/1466)
|
||||
- Stricter typing for mergeCells [#1494](https://github.com/PHPOffice/PhpSpreadsheet/pull/1494)
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -28,7 +143,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- Drop partial migration tool in favor of complete migration via RectorPHP [#1445](https://github.com/PHPOffice/PhpSpreadsheet/issues/1445)
|
||||
- Limit composer package to `src/` [#1424](https://github.com/PHPOffice/PhpSpreadsheet/pull/1424)
|
||||
|
||||
## [1.12.0] - 2020-04-27
|
||||
## 1.12.0 - 2020-04-27
|
||||
|
||||
### Added
|
||||
|
||||
|
@ -44,7 +159,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- MATCH with a static array should return the position of the found value based on the values submitted [#1332](https://github.com/PHPOffice/PhpSpreadsheet/pull/1332)
|
||||
- Fix Xlsx Reader's handling of undefined fill color [#1353](https://github.com/PHPOffice/PhpSpreadsheet/pull/1353)
|
||||
|
||||
## [1.11.0] - 2020-03-02
|
||||
## 1.11.0 - 2020-03-02
|
||||
|
||||
### Added
|
||||
|
||||
|
@ -63,7 +178,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- Fix XLSX file loading with autofilter containing '$' [#1326](https://github.com/PHPOffice/PhpSpreadsheet/pull/1326)
|
||||
- PHPDoc - Use `@return $this` for fluent methods [#1362](https://github.com/PHPOffice/PhpSpreadsheet/pull/1362)
|
||||
|
||||
## [1.10.1] - 2019-12-02
|
||||
## 1.10.1 - 2019-12-02
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -78,7 +193,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- ODS writer prevent invalid numeric value if locale decimal separator is comma [#1268](https://github.com/PHPOffice/PhpSpreadsheet/pull/1268)
|
||||
- Xlsx writer actually writes plotVisOnly and dispBlanksAs from chart properties [#1266](https://github.com/PHPOffice/PhpSpreadsheet/pull/1266)
|
||||
|
||||
## [1.10.0] - 2019-11-18
|
||||
## 1.10.0 - 2019-11-18
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -103,7 +218,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- Validate XIRR inputs and return correct error values [#1120](https://github.com/PHPOffice/PhpSpreadsheet/issues/1120)
|
||||
- Allow to read xlsx files with exotic workbook names like "workbook2.xml" [#1183](https://github.com/PHPOffice/PhpSpreadsheet/pull/1183)
|
||||
|
||||
## [1.9.0] - 2019-08-17
|
||||
## 1.9.0 - 2019-08-17
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -134,20 +249,20 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- Fix `getCalculatedValue()` error with more than two INDIRECT [#1115](https://github.com/PHPOffice/PhpSpreadsheet/pull/1115)
|
||||
- Writer\Html did not hide columns [#985](https://github.com/PHPOffice/PhpSpreadsheet/pull/985)
|
||||
|
||||
## [1.8.2] - 2019-07-08
|
||||
## 1.8.2 - 2019-07-08
|
||||
|
||||
### Fixed
|
||||
|
||||
- Uncaught error when opening ods file and properties aren't defined [#1047](https://github.com/PHPOffice/PhpSpreadsheet/issues/1047)
|
||||
- Xlsx Reader Cell datavalidations bug [#1052](https://github.com/PHPOffice/PhpSpreadsheet/pull/1052)
|
||||
|
||||
## [1.8.1] - 2019-07-02
|
||||
## 1.8.1 - 2019-07-02
|
||||
|
||||
### Fixed
|
||||
|
||||
- Allow nullable theme for Xlsx Style Reader class [#1043](https://github.com/PHPOffice/PhpSpreadsheet/issues/1043)
|
||||
|
||||
## [1.8.0] - 2019-07-01
|
||||
## 1.8.0 - 2019-07-01
|
||||
|
||||
### Security Fix (CVE-2019-12331)
|
||||
|
||||
|
@ -170,7 +285,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- Fix a SUMIF warning with some versions of PHP when having different length of arrays provided as input [#873](https://github.com/PHPOffice/PhpSpreadsheet/pull/873)
|
||||
- Fix incorrectly handled backslash-escaped space characters in number format
|
||||
|
||||
## [1.7.0] - 2019-05-26
|
||||
## 1.7.0 - 2019-05-26
|
||||
|
||||
- Added support for inline styles in Html reader (borders, alignment, width, height)
|
||||
- QuotedText cells no longer treated as formulae if the content begins with a `=`
|
||||
|
@ -184,7 +299,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- Fix VLOOKUP
|
||||
- Fix return type hint
|
||||
|
||||
## [1.6.0] - 2019-01-02
|
||||
## 1.6.0 - 2019-01-02
|
||||
|
||||
### Added
|
||||
|
||||
|
@ -212,13 +327,13 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
|
||||
- `master` is the new default branch, `develop` does not exist anymore
|
||||
|
||||
## [1.5.2] - 2018-11-25
|
||||
## 1.5.2 - 2018-11-25
|
||||
|
||||
### Security
|
||||
|
||||
- Improvements to the design of the XML Security Scanner [#771](https://github.com/PHPOffice/PhpSpreadsheet/issues/771)
|
||||
|
||||
## [1.5.1] - 2018-11-20
|
||||
## 1.5.1 - 2018-11-20
|
||||
|
||||
### Security
|
||||
|
||||
|
@ -238,7 +353,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- Mpdf export can exceed pcre.backtrack_limit [#637](https://github.com/PHPOffice/PhpSpreadsheet/issues/637)
|
||||
- Fix index overflow on data values array [#748](https://github.com/PHPOffice/PhpSpreadsheet/pull/748)
|
||||
|
||||
## [1.5.0] - 2018-10-21
|
||||
## 1.5.0 - 2018-10-21
|
||||
|
||||
### Added
|
||||
|
||||
|
@ -253,7 +368,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- OFFSET should allow omitted height and width [#561](https://github.com/PHPOffice/PhpSpreadsheet/issues/561)
|
||||
- Correctly determine delimiter when CSV contains line breaks inside enclosures [#716](https://github.com/PHPOffice/PhpSpreadsheet/issues/716)
|
||||
|
||||
## [1.4.1] - 2018-09-30
|
||||
## 1.4.1 - 2018-09-30
|
||||
|
||||
### Fixed
|
||||
|
||||
|
@ -262,7 +377,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- Fix warning when reading xlsx without styles [#631](https://github.com/PHPOffice/PhpSpreadsheet/pull/631)
|
||||
- Fix broken sample links on windows due to $baseDir having backslash [#653](https://github.com/PHPOffice/PhpSpreadsheet/pull/653)
|
||||
|
||||
## [1.4.0] - 2018-08-06
|
||||
## 1.4.0 - 2018-08-06
|
||||
|
||||
### Added
|
||||
|
||||
|
@ -326,13 +441,13 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- Migration tool keep variables containing $PHPExcel untouched [#598](https://github.com/PHPOffice/PhpSpreadsheet/issues/598)
|
||||
- Rowspans/colspans were incorrect when adding worksheet using loadIntoExisting [#619](https://github.com/PHPOffice/PhpSpreadsheet/issues/619)
|
||||
|
||||
## [1.3.1] - 2018-06-12
|
||||
## 1.3.1 - 2018-06-12
|
||||
|
||||
### Fixed
|
||||
|
||||
- Ranges across Z and AA columns incorrectly threw an exception [#545](https://github.com/PHPOffice/PhpSpreadsheet/issues/545)
|
||||
|
||||
## [1.3.0] - 2018-06-10
|
||||
## 1.3.0 - 2018-06-10
|
||||
|
||||
### Added
|
||||
|
||||
|
@ -351,13 +466,13 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- Fixed parsing of conditionals in COUNTIF functions [#526](https://github.com/PHPOffice/PhpSpreadsheet/issues/526)
|
||||
- Corruption errors for saved Xlsx docs with frozen panes [#532](https://github.com/PHPOffice/PhpSpreadsheet/issues/532)
|
||||
|
||||
## [1.2.1] - 2018-04-10
|
||||
## 1.2.1 - 2018-04-10
|
||||
|
||||
### Fixed
|
||||
|
||||
- Plain text and richtext mixed in same cell can be read [#442](https://github.com/PHPOffice/PhpSpreadsheet/issues/442)
|
||||
|
||||
## [1.2.0] - 2018-03-04
|
||||
## 1.2.0 - 2018-03-04
|
||||
|
||||
### Added
|
||||
|
||||
|
@ -375,7 +490,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- Select correct cell when calling freezePane [#389](https://github.com/PHPOffice/PhpSpreadsheet/issues/389)
|
||||
- `setStrikethrough()` did not set the font [#403](https://github.com/PHPOffice/PhpSpreadsheet/issues/403)
|
||||
|
||||
## [1.1.0] - 2018-01-28
|
||||
## 1.1.0 - 2018-01-28
|
||||
|
||||
### Added
|
||||
|
||||
|
@ -393,7 +508,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- Support XML file without styles [#331](https://github.com/PHPOffice/PhpSpreadsheet/pull/331)
|
||||
- Cell coordinates which are already a range cause an exception [#319](https://github.com/PHPOffice/PhpSpreadsheet/issues/319)
|
||||
|
||||
## [1.0.0] - 2017-12-25
|
||||
## 1.0.0 - 2017-12-25
|
||||
|
||||
### Added
|
||||
|
||||
|
@ -412,7 +527,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
|
||||
- Constant `TYPE_DOUGHTNUTCHART` is now `TYPE_DOUGHNUTCHART`.
|
||||
|
||||
## [1.0.0-beta2] - 2017-11-26
|
||||
## 1.0.0-beta2 - 2017-11-26
|
||||
|
||||
### Added
|
||||
|
||||
|
@ -450,7 +565,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- `PhpSpreadsheet\Style` => `PhpSpreadsheet\Style\Style`
|
||||
- `PhpSpreadsheet\Worksheet` => `PhpSpreadsheet\Worksheet\Worksheet`
|
||||
|
||||
## [1.0.0-beta] - 2017-08-17
|
||||
## 1.0.0-beta - 2017-08-17
|
||||
|
||||
### Added
|
||||
|
||||
|
@ -470,6 +585,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
- Ignore inlineStr type if formula element exists - @ncrypthic [#570](https://github.com/PHPOffice/PHPExcel/issues/570)
|
||||
- Excel 2007 Reader freezes because of conditional formatting - @rentalhost [#575](https://github.com/PHPOffice/PHPExcel/issues/575)
|
||||
- Readers will now parse files containing worksheet titles over 31 characters [#176](https://github.com/PHPOffice/PhpSpreadsheet/pull/176)
|
||||
- Fixed PHP8 deprecation warning for libxml_disable_entity_loader() [#1625](https://github.com/phpoffice/phpspreadsheet/pull/1625)
|
||||
|
||||
### General
|
||||
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
[![Build Status](https://travis-ci.org/PHPOffice/PhpSpreadsheet.svg?branch=master)](https://travis-ci.org/PHPOffice/PhpSpreadsheet)
|
||||
[![Code Quality](https://scrutinizer-ci.com/g/PHPOffice/PhpSpreadsheet/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/PHPOffice/PhpSpreadsheet/?branch=master)
|
||||
[![Code Coverage](https://scrutinizer-ci.com/g/PHPOffice/PhpSpreadsheet/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/PHPOffice/PhpSpreadsheet/?branch=master)
|
||||
[![Total Downloads](https://poser.pugx.org/phpoffice/phpspreadsheet/downloads.png)](https://packagist.org/packages/phpoffice/phpspreadsheet)
|
||||
[![Latest Stable Version](https://poser.pugx.org/phpoffice/phpspreadsheet/v/stable.png)](https://packagist.org/packages/phpoffice/phpspreadsheet)
|
||||
[![License](https://poser.pugx.org/phpoffice/phpspreadsheet/license.png)](https://packagist.org/packages/phpoffice/phpspreadsheet)
|
||||
[![Total Downloads](https://img.shields.io/packagist/dt/PHPOffice/PhpSpreadsheet)](https://packagist.org/packages/phpoffice/phpspreadsheet)
|
||||
[![Latest Stable Version](https://img.shields.io/github/v/release/PHPOffice/PhpSpreadsheet)](https://packagist.org/packages/phpoffice/phpspreadsheet)
|
||||
[![License](https://img.shields.io/github/license/PHPOffice/PhpSpreadsheet)](https://packagist.org/packages/phpoffice/phpspreadsheet)
|
||||
[![Join the chat at https://gitter.im/PHPOffice/PhpSpreadsheet](https://img.shields.io/badge/GITTER-join%20chat-green.svg)](https://gitter.im/PHPOffice/PhpSpreadsheet)
|
||||
|
||||
PhpSpreadsheet is a library written in pure PHP and providing a set of classes that allow you to read from and to write to different spreadsheet file formats, like Excel and LibreOffice Calc.
|
||||
PhpSpreadsheet is a library written in pure PHP and offers a set of classes that
|
||||
allow you to read and write various spreadsheet file formats such as Excel and LibreOffice Calc.
|
||||
|
||||
## Documentation
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
"scripts": {
|
||||
"check": [
|
||||
"php-cs-fixer fix --ansi --dry-run --diff",
|
||||
"phpcs --report-width=200 samples/ src/ tests/ --ignore=samples/Header.php --standard=PSR2 -n",
|
||||
"phpcs",
|
||||
"phpunit --color=always"
|
||||
],
|
||||
"fix": [
|
||||
|
@ -39,7 +39,7 @@
|
|||
]
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2",
|
||||
"php": "^7.2|^8.0",
|
||||
"ext-ctype": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-gd": "*",
|
||||
|
@ -53,10 +53,12 @@
|
|||
"ext-xmlwriter": "*",
|
||||
"ext-zip": "*",
|
||||
"ext-zlib": "*",
|
||||
"markbaker/complex": "^1.4",
|
||||
"markbaker/matrix": "^1.2",
|
||||
"maennchen/zipstream-php": "^2.1",
|
||||
"markbaker/complex": "^1.5|^2.0",
|
||||
"markbaker/matrix": "^1.2|^2.0",
|
||||
"psr/simple-cache": "^1.0",
|
||||
"maennchen/zipstream-php": "^2.0"
|
||||
"psr/http-client": "^1.0",
|
||||
"psr/http-factory": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"dompdf/dompdf": "^0.8.5",
|
||||
|
@ -64,14 +66,14 @@
|
|||
"jpgraph/jpgraph": "^4.0",
|
||||
"mpdf/mpdf": "^8.0",
|
||||
"phpcompatibility/php-compatibility": "^9.3",
|
||||
"phpunit/phpunit": "^8.5",
|
||||
"phpunit/phpunit": "^8.5|^9.3",
|
||||
"squizlabs/php_codesniffer": "^3.5",
|
||||
"tecnickcom/tcpdf": "^6.3"
|
||||
},
|
||||
"suggest": {
|
||||
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
|
||||
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
|
||||
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer",
|
||||
"dompdf/dompdf": "Option for rendering PDF with PDF Writer (doesn't yet support PHP8)",
|
||||
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer (doesn't yet support PHP8)",
|
||||
"jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers"
|
||||
},
|
||||
"autoload": {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,9 +2,8 @@
|
|||
|
||||
![Logo](./assets/logo.svg)
|
||||
|
||||
PhpSpreadsheet is a library written in pure PHP and providing a set of
|
||||
classes that allow you to read from and to write to different
|
||||
spreadsheet file formats, like Excel and LibreOffice Calc.
|
||||
PhpSpreadsheet is a library written in pure PHP and offers a set of classes that
|
||||
allow you to read and write various spreadsheet file formats such as Excel and LibreOffice Calc.
|
||||
|
||||
## File formats supported
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ FALSE | \PhpOffice\PhpSpreadsheet\Calculation\Logical::FALSE
|
|||
IF | \PhpOffice\PhpSpreadsheet\Calculation\Logical::statementIf
|
||||
IFERROR | \PhpOffice\PhpSpreadsheet\Calculation\Logical::IFERROR
|
||||
IFNA | \PhpOffice\PhpSpreadsheet\Calculation\Logical::IFNA
|
||||
IFS | **Not yet Implemented**
|
||||
IFS | \PhpOffice\PhpSpreadsheet\Calculation\Logical::IFS
|
||||
NOT | \PhpOffice\PhpSpreadsheet\Calculation\Logical::NOT
|
||||
OR | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalOr
|
||||
SWITCH | \PhpOffice\PhpSpreadsheet\Calculation\Logical::statementSwitch
|
||||
|
@ -229,6 +229,7 @@ AREAS | **Not yet Implemented**
|
|||
CHOOSE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::CHOOSE
|
||||
COLUMN | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::COLUMN
|
||||
COLUMNS | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::COLUMNS
|
||||
FILTER | **Not yet Implemented**
|
||||
FORMULATEXT | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::FORMULATEXT
|
||||
GETPIVOTDATA | **Not yet Implemented**
|
||||
HLOOKUP | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::HLOOKUP
|
||||
|
@ -241,8 +242,13 @@ OFFSET | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::OFFSET
|
|||
ROW | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::ROW
|
||||
ROWS | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::ROWS
|
||||
RTD | **Not yet Implemented**
|
||||
SORT | **Not yet Implemented**
|
||||
SORTBY | **Not yet Implemented**
|
||||
TRANSPOSE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::TRANSPOSE
|
||||
UNIQUE | **Not yet Implemented**
|
||||
VLOOKUP | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::VLOOKUP
|
||||
XLOOKUP | **Not yet Implemented**
|
||||
XMATCH | **Not yet Implemented**
|
||||
|
||||
## CATEGORY_MATH_AND_TRIG
|
||||
|
||||
|
@ -253,6 +259,7 @@ ACOS | acos
|
|||
ACOSH | acosh
|
||||
ACOT | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ACOT
|
||||
ACOTH | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ACOTH
|
||||
AGGREGATE | **Not yet Implemented**
|
||||
ARABIC | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ARABIC
|
||||
ASIN | asin
|
||||
ASINH | asinh
|
||||
|
@ -261,13 +268,17 @@ ATAN2 | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ATAN2
|
|||
ATANH | atanh
|
||||
BASE | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::BASE
|
||||
CEILING | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::CEILING
|
||||
CEILING.MATH | **Not yet Implemented**
|
||||
CEILING.PRECISE | **Not yet Implemented**
|
||||
COMBIN | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::COMBIN
|
||||
COMBINA | **Not yet Implemented**
|
||||
COS | cos
|
||||
COSH | cosh
|
||||
COT | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::COT
|
||||
COTH | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::COTH
|
||||
CSC | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::CSC
|
||||
CSCH | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::CSCH
|
||||
DECIMAL | **Not yet Implemented**
|
||||
DEGREES | rad2deg
|
||||
EVEN | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::EVEN
|
||||
EXP | exp
|
||||
|
@ -278,6 +289,7 @@ FLOOR.MATH | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::FLOORMATH
|
|||
FLOOR.PRECISE | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::FLOORPRECISE
|
||||
GCD | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::GCD
|
||||
INT | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::INT
|
||||
ISO.CEILING | **Not yet Implemented**
|
||||
LCM | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::LCM
|
||||
LN | log
|
||||
LOG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::logBase
|
||||
|
@ -288,6 +300,7 @@ MMULT | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::MMULT
|
|||
MOD | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::MOD
|
||||
MROUND | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::MROUND
|
||||
MULTINOMIAL | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::MULTINOMIAL
|
||||
MUNIT | **Not yet Implemented**
|
||||
ODD | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ODD
|
||||
PI | pi
|
||||
POWER | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::POWER
|
||||
|
@ -295,6 +308,7 @@ PRODUCT | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::PRODUCT
|
|||
QUOTIENT | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::QUOTIENT
|
||||
RADIANS | deg2rad
|
||||
RAND | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::RAND
|
||||
RANDARRAY | **Not yet Implemented**
|
||||
RANDBETWEEN | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::RAND
|
||||
ROMAN | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ROMAN
|
||||
ROUND | round
|
||||
|
@ -303,6 +317,7 @@ ROUNDUP | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ROUNDUP
|
|||
SEC | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::SEC
|
||||
SECH | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::SECH
|
||||
SERIESSUM | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::SERIESSUM
|
||||
SEQUENCE | **Not yet Implemented**
|
||||
SIGN | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::SIGN
|
||||
SIN | sin
|
||||
SINH | sinh
|
||||
|
@ -324,19 +339,31 @@ TRUNC | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::TRUNC
|
|||
## CATEGORY_STATISTICAL
|
||||
|
||||
Excel Function | PhpSpreadsheet Function
|
||||
--------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------------------
|
||||
AVEDEV | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::AVEDEV
|
||||
AVERAGE | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::AVERAGE
|
||||
AVERAGEA | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::AVERAGEA
|
||||
AVERAGEIF | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::AVERAGEIF
|
||||
AVERAGEIFS | **Not yet Implemented**
|
||||
BETADIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::BETADIST
|
||||
BETA.DIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::BETADIST
|
||||
BETAINV | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::BETAINV
|
||||
BETA.INV | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::BETAINV
|
||||
BINOMDIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::BINOMDIST
|
||||
BINOM.DIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::BINOMDIST
|
||||
BINOM.DIST.RANGE | **Not yet Implemented**
|
||||
BINOM.INV | **Not yet Implemented**
|
||||
CHIDIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CHIDIST
|
||||
CHISQ.DIST | **Not yet Implemented**
|
||||
CHISQ.DIST.RT | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CHIDIST
|
||||
CHIINV | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CHIINV
|
||||
CHISQ.INV | **Not yet Implemented**
|
||||
CHISQ.INV.RT | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CHIINV
|
||||
CHITEST | **Not yet Implemented**
|
||||
CHISQ.TEST | **Not yet Implemented**
|
||||
CONFIDENCE | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CONFIDENCE
|
||||
CONFIDENCE.NORM | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CONFIDENCE
|
||||
CONFIDENCE.T | **Not yet Implemented**
|
||||
CORREL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CORREL
|
||||
COUNT | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::COUNT
|
||||
COUNTA | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::COUNTA
|
||||
|
@ -344,19 +371,37 @@ COUNTBLANK | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::COUNTBL
|
|||
COUNTIF | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::COUNTIF
|
||||
COUNTIFS | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::COUNTIFS
|
||||
COVAR | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::COVAR
|
||||
COVARIANCE.P | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::COVAR
|
||||
COVARIANCE.S | **Not yet Implemented**
|
||||
CRITBINOM | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CRITBINOM
|
||||
DEVSQ | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::DEVSQ
|
||||
EXPONDIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::EXPONDIST
|
||||
EXPON.DIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::EXPONDIST
|
||||
FDIST | **Not yet Implemented**
|
||||
F.DIST | **Not yet Implemented**
|
||||
F.DIST.RT | **Not yet Implemented**
|
||||
FINV | **Not yet Implemented**
|
||||
F.INV | **Not yet Implemented**
|
||||
F.INV.RT | **Not yet Implemented**
|
||||
F.TEST | **Not yet Implemented**
|
||||
FISHER | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::FISHER
|
||||
FISHERINV | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::FISHERINV
|
||||
FORECAST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::FORECAST
|
||||
FORECAST.ETS | **Not yet Implemented**
|
||||
FORECAST.ETS.CONFINT | **Not yet Implemented**
|
||||
FORECAST.ETS.SEASONALITY | **Not yet Implemented**
|
||||
FORECAST.ETS.STAT | **Not yet Implemented**
|
||||
FORECAST.LINEAR | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::FORECAST
|
||||
FREQUENCY | **Not yet Implemented**
|
||||
FTEST | **Not yet Implemented**
|
||||
GAMMA | **Not yet Implemented**
|
||||
GAMMADIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::GAMMADIST
|
||||
GAMMA.DIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::GAMMADIST
|
||||
GAMMAINV | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::GAMMAINV
|
||||
GAMMA.INV | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::GAMMAINV
|
||||
GAMMALN | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::GAMMALN
|
||||
GAMMALN.PRECISE | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::GAMMALN
|
||||
GAUSS | **Not yet Implemented**
|
||||
GEOMEAN | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::GEOMEAN
|
||||
GROWTH | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::GROWTH
|
||||
HARMEAN | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::HARMEAN
|
||||
|
@ -368,6 +413,8 @@ LINEST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::LINEST
|
|||
LOGEST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::LOGEST
|
||||
LOGINV | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::LOGINV
|
||||
LOGNORMDIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::LOGNORMDIST
|
||||
LOGNORM.DIST | **Not yet Implemented**
|
||||
LOGNORM.INV | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::LOGINV
|
||||
MAX | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::MAX
|
||||
MAXA | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::MAXA
|
||||
MAXIFS | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::MAXIFS
|
||||
|
@ -377,22 +424,40 @@ MIN | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::MIN
|
|||
MINA | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::MINA
|
||||
MINIFS | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::MINIFS
|
||||
MODE | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::MODE
|
||||
MODE.MULT | **Not yet Implemented**
|
||||
MODE.SNGL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::MODE
|
||||
NEGBINOMDIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NEGBINOMDIST
|
||||
NEGBINOM.DIST | **Not yet Implemented**
|
||||
NORMDIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NORMDIST
|
||||
NORM.DIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NORMDIST
|
||||
NORMINV | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NORMINV
|
||||
NORM.INV | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NORMINV
|
||||
NORMSDIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NORMSDIST
|
||||
NORM.S.DIST | **Not yet Implemented**
|
||||
NORMSINV | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NORMSINV
|
||||
NORM.S.INV | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NORMSINV
|
||||
PEARSON | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CORREL
|
||||
PERCENTILE | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::PERCENTILE
|
||||
PERCENTILE.EXC | **Not yet Implemented**
|
||||
PERCENTILE.INC | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::PERCENTILE
|
||||
PERCENTRANK | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::PERCENTRANK
|
||||
PERCENTRANK.EXC | **Not yet Implemented**
|
||||
PERCENTRANK.INC | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::PERCENTRANK
|
||||
PERMUT | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::PERMUT
|
||||
PERMUTATIONA | **Not yet Implemented**
|
||||
PHI | **Not yet Implemented**
|
||||
POISSON | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::POISSON
|
||||
POISSON.DIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::POISSON
|
||||
PROB | **Not yet Implemented**
|
||||
QUARTILE | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::QUARTILE
|
||||
QUARTILE.EXC | **Not yet Implemented**
|
||||
QUARTILE.INC | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::QUARTILE
|
||||
RANK | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::RANK
|
||||
RANK.AVG | **Not yet Implemented**
|
||||
RANK.EQ | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::RANK
|
||||
RSQ | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::RSQ
|
||||
SKEW | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::SKEW
|
||||
SKEW.P | **Not yet Implemented**
|
||||
SLOPE | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::SLOPE
|
||||
SMALL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::SMALL
|
||||
STANDARDIZE | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STANDARDIZE
|
||||
|
@ -404,10 +469,16 @@ STDEVP | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEVP
|
|||
STDEVPA | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEVPA
|
||||
STEYX | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STEYX
|
||||
TDIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::TDIST
|
||||
T.DIST | **Not yet Implemented**
|
||||
T.DIST.2T | **Not yet Implemented**
|
||||
T.DIST.RT | **Not yet Implemented**
|
||||
TINV | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::TINV
|
||||
T.INV | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::TINV
|
||||
T.INV.2T | **Not yet Implemented**
|
||||
TREND | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::TREND
|
||||
TRIMMEAN | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::TRIMMEAN
|
||||
TTEST | **Not yet Implemented**
|
||||
T.TEST | **Not yet Implemented**
|
||||
VAR | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::VARFunc
|
||||
VAR.P | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::VARP
|
||||
VAR.S | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::VARFunc
|
||||
|
@ -415,7 +486,9 @@ VARA | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::VARA
|
|||
VARP | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::VARP
|
||||
VARPA | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::VARPA
|
||||
WEIBULL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::WEIBULL
|
||||
WEIBULL.DIST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::WEIBULL
|
||||
ZTEST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::ZTEST
|
||||
Z.TEST | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::ZTEST
|
||||
|
||||
## CATEGORY_TEXT_AND_DATA
|
||||
|
||||
|
@ -428,6 +501,7 @@ CLEAN | \PhpOffice\PhpSpreadsheet\Calculation\TextData::TRIMNONPRI
|
|||
CODE | \PhpOffice\PhpSpreadsheet\Calculation\TextData::ASCIICODE
|
||||
CONCAT | \PhpOffice\PhpSpreadsheet\Calculation\TextData::CONCATENATE
|
||||
CONCATENATE | \PhpOffice\PhpSpreadsheet\Calculation\TextData::CONCATENATE
|
||||
DBCS | **Not yet Implemented**
|
||||
DOLLAR | \PhpOffice\PhpSpreadsheet\Calculation\TextData::DOLLAR
|
||||
EXACT | \PhpOffice\PhpSpreadsheet\Calculation\TextData::EXACT
|
||||
FIND | \PhpOffice\PhpSpreadsheet\Calculation\TextData::SEARCHSENSITIVE
|
||||
|
@ -460,3 +534,11 @@ UNICHAR | \PhpOffice\PhpSpreadsheet\Calculation\TextData::CHARACTER
|
|||
UNICODE | \PhpOffice\PhpSpreadsheet\Calculation\TextData::ASCIICODE
|
||||
UPPER | \PhpOffice\PhpSpreadsheet\Calculation\TextData::UPPERCASE
|
||||
VALUE | \PhpOffice\PhpSpreadsheet\Calculation\TextData::VALUE
|
||||
|
||||
## CATEGORY_WEB
|
||||
|
||||
Excel Function | PhpSpreadsheet Function
|
||||
--------------------|-------------------------------------------
|
||||
ENCODEURL | **Not yet Implemented**
|
||||
FILTERXML | **Not yet Implemented**
|
||||
WEBSERVICE | \PhpOffice\PhpSpreadsheet\Calculation\Web::WEBSERVICE
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
## A
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
ABS | CATEGORY_MATH_AND_TRIG | abs
|
||||
ACCRINT | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::ACCRINT
|
||||
ACCRINTM | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::ACCRINTM
|
||||
|
@ -12,6 +12,7 @@ ACOSH | CATEGORY_MATH_AND_TRIG | acosh
|
|||
ACOT | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ACOT
|
||||
ACOTH | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ACOTH
|
||||
ADDRESS | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::cellAddress
|
||||
AGGREGATE | CATEGORY_MATH_AND_TRIG | **Not yet Implemented**
|
||||
AMORDEGRC | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::AMORDEGRC
|
||||
AMORLINC | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::AMORLINC
|
||||
AND | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalAnd
|
||||
|
@ -32,7 +33,7 @@ AVERAGEIFS | CATEGORY_STATISTICAL | **Not yet Implemented**
|
|||
## B
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
BAHTTEXT | CATEGORY_TEXT_AND_DATA | **Not yet Implemented**
|
||||
BASE | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::BASE
|
||||
BESSELI | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BESSELI
|
||||
|
@ -40,11 +41,16 @@ BESSELJ | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet
|
|||
BESSELK | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BESSELK
|
||||
BESSELY | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BESSELY
|
||||
BETADIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::BETADIST
|
||||
BETA.DIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::BETADIST
|
||||
BETAINV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::BETAINV
|
||||
BETA.INV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::BETAINV
|
||||
BIN2DEC | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BINTODEC
|
||||
BIN2HEX | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BINTOHEX
|
||||
BIN2OCT | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BINTOOCT
|
||||
BINOMDIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::BINOMDIST
|
||||
BINOM.DIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::BINOMDIST
|
||||
BINOM.DIST.RANGE | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
BINOM.INV | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
BITAND | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITAND
|
||||
BITLSHIFT | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITLSHIFT
|
||||
BITOR | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITOR
|
||||
|
@ -54,12 +60,19 @@ BITXOR | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet
|
|||
## C
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
CEILING | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::CEILING
|
||||
CEILING.MATH | CATEGORY_MATH_AND_TRIG | **Not yet Implemented**
|
||||
CEILING.PRECISE | CATEGORY_MATH_AND_TRIG | **Not yet Implemented**
|
||||
CELL | CATEGORY_INFORMATION | **Not yet Implemented**
|
||||
CHAR | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::CHARACTER
|
||||
CHIDIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CHIDIST
|
||||
CHIINV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CHIINV
|
||||
CHISQ.DIST | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
CHISQ.DIST.RT | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CHIDIST
|
||||
CHISQ.INV | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
CHISQ.INV.RT | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CHIINV
|
||||
CHISQ.TEST | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
CHITEST | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
CHOOSE | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::CHOOSE
|
||||
CLEAN | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::TRIMNONPRINTABLE
|
||||
|
@ -67,10 +80,13 @@ CODE | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet
|
|||
COLUMN | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::COLUMN
|
||||
COLUMNS | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::COLUMNS
|
||||
COMBIN | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::COMBIN
|
||||
COMBINA | CATEGORY_MATH_AND_TRIG | **Not yet Implemented**
|
||||
COMPLEX | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::COMPLEX
|
||||
CONCAT | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::CONCATENATE
|
||||
CONCATENATE | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::CONCATENATE
|
||||
CONFIDENCE | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CONFIDENCE
|
||||
CONFIDENCE.NORM | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CONFIDENCE
|
||||
CONFIDENCE.T | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
CONVERT | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::CONVERTUOM
|
||||
CORREL | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CORREL
|
||||
COS | CATEGORY_MATH_AND_TRIG | cos
|
||||
|
@ -89,6 +105,8 @@ COUPNCD | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet
|
|||
COUPNUM | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::COUPNUM
|
||||
COUPPCD | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::COUPPCD
|
||||
COVAR | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::COVAR
|
||||
COVARIANCE.P | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::COVAR
|
||||
COVARIANCE.S | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
CRITBINOM | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CRITBINOM
|
||||
CSC | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::CSC
|
||||
CSCH | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::CSCH
|
||||
|
@ -105,7 +123,7 @@ CUMPRINC | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet
|
|||
## D
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
DATE | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DATE
|
||||
DATEDIF | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DATEDIF
|
||||
DATEVALUE | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DATEVALUE
|
||||
|
@ -114,12 +132,14 @@ DAY | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet
|
|||
DAYS | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DAYS
|
||||
DAYS360 | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DAYS360
|
||||
DB | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::DB
|
||||
DBCS | CATEGORY_TEXT_AND_DATA | **Not yet Implemented**
|
||||
DCOUNT | CATEGORY_DATABASE | \PhpOffice\PhpSpreadsheet\Calculation\Database::DCOUNT
|
||||
DCOUNTA | CATEGORY_DATABASE | \PhpOffice\PhpSpreadsheet\Calculation\Database::DCOUNTA
|
||||
DDB | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::DDB
|
||||
DEC2BIN | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::DECTOBIN
|
||||
DEC2HEX | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::DECTOHEX
|
||||
DEC2OCT | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::DECTOOCT
|
||||
DECIMAL | CATEGORY_MATH_AND_TRIG | **Not yet Implemented**
|
||||
DEGREES | CATEGORY_MATH_AND_TRIG | rad2deg
|
||||
DELTA | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::DELTA
|
||||
DEVSQ | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::DEVSQ
|
||||
|
@ -141,31 +161,39 @@ DVARP | CATEGORY_DATABASE | \PhpOffice\PhpSpreadsheet
|
|||
## E
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
EDATE | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::EDATE
|
||||
EFFECT | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::EFFECT
|
||||
ENCODEURL | CATEGORY_TEXT_AND_DATA | **Not yet Implemented**
|
||||
EOMONTH | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::EOMONTH
|
||||
ERF | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::ERF
|
||||
ERF.PRECISE | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::ERFPRECISE
|
||||
ERFC | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::ERFC
|
||||
ERFC.PRECISE | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::ERFC
|
||||
ERF.PRECISE | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::ERFPRECISE
|
||||
ERROR.TYPE | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::errorType
|
||||
EVEN | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::EVEN
|
||||
EXACT | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::EXACT
|
||||
EXP | CATEGORY_MATH_AND_TRIG | exp
|
||||
EXPONDIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::EXPONDIST
|
||||
EXPON.DIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::EXPONDIST
|
||||
|
||||
## F
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
FACT | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::FACT
|
||||
FACTDOUBLE | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::FACTDOUBLE
|
||||
FALSE | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::FALSE
|
||||
FDIST | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
F.DIST | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
F.DIST.RT | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
FILTER | CATEGORY_LOOKUP_AND_REFERENCE | **Not yet Implemented**
|
||||
FILTERXML | CATEGORY_TEXT_AND_DATA | **Not yet Implemented**
|
||||
FIND | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::SEARCHSENSITIVE
|
||||
FINDB | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::SEARCHSENSITIVE
|
||||
FINV | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
F.INV | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
F.INV.RT | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
FISHER | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::FISHER
|
||||
FISHERINV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::FISHERINV
|
||||
FIXED | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::FIXEDFORMAT
|
||||
|
@ -173,19 +201,30 @@ FLOOR | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet
|
|||
FLOOR.MATH | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::FLOORMATH
|
||||
FLOOR.PRECISE | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::FLOORPRECISE
|
||||
FORECAST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::FORECAST
|
||||
FORECAST.ETS | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
FORECAST.ETS.CONFINT | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
FORECAST.ETS.SEASONALITY | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
FORECAST.ETS.STAT | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
FORECAST.LINEAR | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::FORECAST
|
||||
FORMULATEXT | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::FORMULATEXT
|
||||
FREQUENCY | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
FTEST | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
F.TEST | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
FV | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::FV
|
||||
FVSCHEDULE | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::FVSCHEDULE
|
||||
|
||||
## G
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
GAMMA | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
GAMMADIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::GAMMADIST
|
||||
GAMMA.DIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::GAMMADIST
|
||||
GAMMAINV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::GAMMAINV
|
||||
GAMMA.INV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::GAMMAINV
|
||||
GAMMALN | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::GAMMALN
|
||||
GAMMALN.PRECISE | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::GAMMALN
|
||||
GAUSS | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
GCD | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::GCD
|
||||
GEOMEAN | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::GEOMEAN
|
||||
GESTEP | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::GESTEP
|
||||
|
@ -195,7 +234,7 @@ GROWTH | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet
|
|||
## H
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
HARMEAN | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::HARMEAN
|
||||
HEX2BIN | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::HEXTOBIN
|
||||
HEX2DEC | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::HEXTODEC
|
||||
|
@ -208,11 +247,11 @@ HYPGEOMDIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet
|
|||
## I
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
IF | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::statementIf
|
||||
IFERROR | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::IFERROR
|
||||
IFNA | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::IFNA
|
||||
IFS | CATEGORY_LOGICAL | **Not yet Implemented**
|
||||
IFS | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::IFS
|
||||
IMABS | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMABS
|
||||
IMAGINARY | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMAGINARY
|
||||
IMARGUMENT | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMARGUMENT
|
||||
|
@ -255,6 +294,7 @@ ISLOGICAL | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet
|
|||
ISNA | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isNa
|
||||
ISNONTEXT | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isNonText
|
||||
ISNUMBER | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isNumber
|
||||
ISO.CEILING | CATEGORY_MATH_AND_TRIG | **Not yet Implemented**
|
||||
ISODD | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isOdd
|
||||
ISOWEEKNUM | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::ISOWEEKNUM
|
||||
ISPMT | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::ISPMT
|
||||
|
@ -264,19 +304,19 @@ ISTEXT | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet
|
|||
## J
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
JIS | CATEGORY_TEXT_AND_DATA | **Not yet Implemented**
|
||||
|
||||
## K
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
KURT | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::KURT
|
||||
|
||||
## L
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
LARGE | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::LARGE
|
||||
LCM | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::LCM
|
||||
LEFT | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::LEFT
|
||||
|
@ -290,13 +330,15 @@ LOG10 | CATEGORY_MATH_AND_TRIG | log10
|
|||
LOGEST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::LOGEST
|
||||
LOGINV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::LOGINV
|
||||
LOGNORMDIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::LOGNORMDIST
|
||||
LOGNORM.DIST | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
LOGNORM.INV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::LOGINV
|
||||
LOOKUP | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::LOOKUP
|
||||
LOWER | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::LOWERCASE
|
||||
|
||||
## M
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
MATCH | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::MATCH
|
||||
MAX | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::MAX
|
||||
MAXA | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::MAXA
|
||||
|
@ -316,25 +358,32 @@ MIRR | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet
|
|||
MMULT | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::MMULT
|
||||
MOD | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::MOD
|
||||
MODE | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::MODE
|
||||
MODE.MULT | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
MODE.SNGL | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::MODE
|
||||
MONTH | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::MONTHOFYEAR
|
||||
MROUND | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::MROUND
|
||||
MULTINOMIAL | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::MULTINOMIAL
|
||||
MUNIT | CATEGORY_MATH_AND_TRIG | **Not yet Implemented**
|
||||
|
||||
## N
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
N | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::n
|
||||
NA | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::NA
|
||||
NEGBINOMDIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NEGBINOMDIST
|
||||
NEGBINOM.DIST | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
NETWORKDAYS | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::NETWORKDAYS
|
||||
NETWORKDAYS.INTL | CATEGORY_DATE_AND_TIME | **Not yet Implemented**
|
||||
NOMINAL | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::NOMINAL
|
||||
NORMDIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NORMDIST
|
||||
NORM.DIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NORMDIST
|
||||
NORMINV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NORMINV
|
||||
NORM.INV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NORMINV
|
||||
NORMSDIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NORMSDIST
|
||||
NORM.S.DIST | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
NORMSINV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NORMSINV
|
||||
NORM.S.INV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NORMSINV
|
||||
NOT | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::NOT
|
||||
NOW | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DATETIMENOW
|
||||
NPER | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::NPER
|
||||
|
@ -344,7 +393,7 @@ NUMBERVALUE | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet
|
|||
## O
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
OCT2BIN | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::OCTTOBIN
|
||||
OCT2DEC | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::OCTTODEC
|
||||
OCT2HEX | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::OCTTOHEX
|
||||
|
@ -359,16 +408,23 @@ OR | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet
|
|||
## P
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
PDURATION | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::PDURATION
|
||||
PEARSON | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::CORREL
|
||||
PERCENTILE | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::PERCENTILE
|
||||
PERCENTILE.EXC | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
PERCENTILE.INC | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::PERCENTILE
|
||||
PERCENTRANK | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::PERCENTRANK
|
||||
PERCENTRANK.EXC | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
PERCENTRANK.INC | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::PERCENTRANK
|
||||
PERMUT | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::PERMUT
|
||||
PERMUTATIONA | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
PHI | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
PHONETIC | CATEGORY_TEXT_AND_DATA | **Not yet Implemented**
|
||||
PI | CATEGORY_MATH_AND_TRIG | pi
|
||||
PMT | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::PMT
|
||||
POISSON | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::POISSON
|
||||
POISSON.DIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::POISSON
|
||||
POWER | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::POWER
|
||||
PPMT | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::PPMT
|
||||
PRICE | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::PRICE
|
||||
|
@ -382,18 +438,23 @@ PV | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet
|
|||
## Q
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
QUARTILE | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::QUARTILE
|
||||
QUARTILE.EXC | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
QUARTILE.INC | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::QUARTILE
|
||||
QUOTIENT | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::QUOTIENT
|
||||
|
||||
## R
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
RADIANS | CATEGORY_MATH_AND_TRIG | deg2rad
|
||||
RAND | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::RAND
|
||||
RANDARRAY | CATEGORY_MATH_AND_TRIG | **Not yet Implemented**
|
||||
RANDBETWEEN | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::RAND
|
||||
RANK | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::RANK
|
||||
RANK.AVG | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
RANK.EQ | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::RANK
|
||||
RATE | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::RATE
|
||||
RECEIVED | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::RECEIVED
|
||||
REPLACE | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::REPLACE
|
||||
|
@ -414,12 +475,13 @@ RTD | CATEGORY_LOOKUP_AND_REFERENCE | **Not yet Implemented**
|
|||
## S
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
SEARCH | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::SEARCHINSENSITIVE
|
||||
SEARCHB | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::SEARCHINSENSITIVE
|
||||
SEC | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::SEC
|
||||
SECH | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::SECH
|
||||
SECOND | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::SECOND
|
||||
SEQUENCE | CATEGORY_MATH_AND_TRIG | **Not yet Implemented**
|
||||
SERIESSUM | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::SERIESSUM
|
||||
SHEET | CATEGORY_INFORMATION | **Not yet Implemented**
|
||||
SHEETS | CATEGORY_INFORMATION | **Not yet Implemented**
|
||||
|
@ -427,18 +489,21 @@ SIGN | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet
|
|||
SIN | CATEGORY_MATH_AND_TRIG | sin
|
||||
SINH | CATEGORY_MATH_AND_TRIG | sinh
|
||||
SKEW | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::SKEW
|
||||
SKEW.P | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
SLN | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::SLN
|
||||
SLOPE | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::SLOPE
|
||||
SMALL | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::SMALL
|
||||
SORT | CATEGORY_LOOKUP_AND_REFERENCE | **Not yet Implemented**
|
||||
SORTBY | CATEGORY_LOOKUP_AND_REFERENCE | **Not yet Implemented**
|
||||
SQRT | CATEGORY_MATH_AND_TRIG | sqrt
|
||||
SQRTPI | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::SQRTPI
|
||||
STANDARDIZE | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STANDARDIZE
|
||||
STDEV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEV
|
||||
STDEV.P | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEVP
|
||||
STDEV.S | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEV
|
||||
STDEVA | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEVA
|
||||
STDEVP | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEVP
|
||||
STDEV.P | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEVP
|
||||
STDEVPA | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEVPA
|
||||
STDEV.S | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEV
|
||||
STEYX | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STEYX
|
||||
SUBSTITUTE | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::SUBSTITUTE
|
||||
SUBTOTAL | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::SUBTOTAL
|
||||
|
@ -456,7 +521,7 @@ SYD | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet
|
|||
## T
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
T | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::RETURNSTRING
|
||||
TAN | CATEGORY_MATH_AND_TRIG | tan
|
||||
TANH | CATEGORY_MATH_AND_TRIG | tanh
|
||||
|
@ -464,11 +529,16 @@ TBILLEQ | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet
|
|||
TBILLPRICE | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::TBILLPRICE
|
||||
TBILLYIELD | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::TBILLYIELD
|
||||
TDIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::TDIST
|
||||
T.DIST | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
T.DIST.2T | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
T.DIST.RT | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
TEXT | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::TEXTFORMAT
|
||||
TEXTJOIN | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::TEXTJOIN
|
||||
TIME | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::TIME
|
||||
TIMEVALUE | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::TIMEVALUE
|
||||
TINV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::TINV
|
||||
T.INV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::TINV
|
||||
T.INV.2T | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
TODAY | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::DATENOW
|
||||
TRANSPOSE | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::TRANSPOSE
|
||||
TREND | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::TREND
|
||||
|
@ -477,53 +547,59 @@ TRIMMEAN | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet
|
|||
TRUE | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::TRUE
|
||||
TRUNC | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::TRUNC
|
||||
TTEST | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
T.TEST | CATEGORY_STATISTICAL | **Not yet Implemented**
|
||||
TYPE | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::TYPE
|
||||
|
||||
## U
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
UNICHAR | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::CHARACTER
|
||||
UNICODE | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::ASCIICODE
|
||||
UNIQUE | CATEGORY_LOOKUP_AND_REFERENCE | **Not yet Implemented**
|
||||
UPPER | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::UPPERCASE
|
||||
USDOLLAR | CATEGORY_FINANCIAL | **Not yet Implemented**
|
||||
|
||||
## V
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
VALUE | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::VALUE
|
||||
VAR | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::VARFunc
|
||||
VAR.P | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::VARP
|
||||
VAR.S | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::VARFunc
|
||||
VARA | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::VARA
|
||||
VARP | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::VARP
|
||||
VAR.P | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::VARP
|
||||
VARPA | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::VARPA
|
||||
VAR.S | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::VARFunc
|
||||
VDB | CATEGORY_FINANCIAL | **Not yet Implemented**
|
||||
VLOOKUP | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::VLOOKUP
|
||||
|
||||
## W
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
WEBSERVICE | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\Web::WEBSERVICE
|
||||
WEEKDAY | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::WEEKDAY
|
||||
WEEKNUM | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::WEEKNUM
|
||||
WEIBULL | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::WEIBULL
|
||||
WEIBULL.DIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::WEIBULL
|
||||
WORKDAY | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::WORKDAY
|
||||
WORKDAY.INTL | CATEGORY_DATE_AND_TIME | **Not yet Implemented**
|
||||
|
||||
## X
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
XIRR | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::XIRR
|
||||
XLOOKUP | CATEGORY_LOOKUP_AND_REFERENCE | **Not yet Implemented**
|
||||
XMATCH | CATEGORY_LOOKUP_AND_REFERENCE | **Not yet Implemented**
|
||||
XNPV | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::XNPV
|
||||
XOR | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalXor
|
||||
|
||||
## Y
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
YEAR | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::YEAR
|
||||
YEARFRAC | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::YEARFRAC
|
||||
YIELD | CATEGORY_FINANCIAL | **Not yet Implemented**
|
||||
|
@ -533,5 +609,6 @@ YIELDMAT | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet
|
|||
## Z
|
||||
|
||||
Excel Function | Category | PhpSpreadsheet Function
|
||||
--------------------|--------------------------------|-------------------------------------------
|
||||
-------------------------|-------------------------------|-------------------------
|
||||
ZTEST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::ZTEST
|
||||
Z.TEST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::ZTEST
|
||||
|
|
|
@ -56,7 +56,7 @@ the cell object will still retain its data values.
|
|||
|
||||
What does this mean? Consider the following code:
|
||||
|
||||
```
|
||||
```php
|
||||
$spreadSheet = new Spreadsheet();
|
||||
$workSheet = $spreadSheet->getActiveSheet();
|
||||
|
||||
|
@ -153,7 +153,7 @@ was a formula.
|
|||
|
||||
To do this, you need to "escape" the value by setting it as "quoted text".
|
||||
|
||||
```
|
||||
```php
|
||||
// Set cell A4 with a formula
|
||||
$spreadsheet->getActiveSheet()->setCellValue(
|
||||
'A4',
|
||||
|
|
|
@ -55,7 +55,7 @@ However, there may be times when you don't want this, perhaps you've changed
|
|||
the underlying data and need to re-evaluate the same formula with that new
|
||||
data.
|
||||
|
||||
```
|
||||
```php
|
||||
Calculation::getInstance($spreadsheet)->disableCalculationCache();
|
||||
```
|
||||
|
||||
|
@ -63,7 +63,7 @@ Will disable calculation caching, and flush the current calculation cache.
|
|||
|
||||
If you want only to flush the cache, then you can call
|
||||
|
||||
```
|
||||
```php
|
||||
Calculation::getInstance($spreadsheet)->clearCalculationCache();
|
||||
```
|
||||
|
||||
|
@ -456,7 +456,7 @@ has not yet been implemented in PhpSpreadsheet.
|
|||
|
||||
#### DCOUNTA
|
||||
|
||||
The DCOUNT function returns the count of cells that aren’t blank in a
|
||||
The DCOUNTA function returns the count of cells that aren’t blank in a
|
||||
column of a list or database and that match conditions that you specify.
|
||||
|
||||
##### Syntax
|
||||
|
|
|
@ -0,0 +1,593 @@
|
|||
# Defined Names
|
||||
|
||||
There are two types of Defined Names in MS Excel and other Spreadsheet formats: Named Ranges and Named Formulae. Between them, they can add a lot of power to your Spreadsheets, but they need to be used correctly.
|
||||
|
||||
Working examples for all the code shown in this document can be found in the `/samples/DefinedNames` folder.
|
||||
|
||||
## Named Ranges
|
||||
|
||||
A Named Range provides a name reference to a cell or a range of cells. You can then reference that cell or cells by that name within a formula.
|
||||
|
||||
As an example, I'll create a simple Calculator that adds Tax to a Price.
|
||||
|
||||
```php
|
||||
// Set up some basic data
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Tax Rate:')
|
||||
->setCellValue('B1', '=19%')
|
||||
->setCellValue('A3', 'Net Price:')
|
||||
->setCellValue('B3', 12.99)
|
||||
->setCellValue('A4', 'Tax:')
|
||||
->setCellValue('A5', 'Price including Tax:');
|
||||
|
||||
// Define named ranges
|
||||
$spreadsheet->addNamedRange( new \PhpOffice\PhpSpreadsheet\NamedRange('TAX_RATE', $worksheet, '=$B$1') );
|
||||
$spreadsheet->addNamedRange( new \PhpOffice\PhpSpreadsheet\NamedRange('PRICE', $worksheet, '=$B$3') );
|
||||
|
||||
// Reference that defined name in a formula
|
||||
$worksheet
|
||||
->setCellValue('B4', '=PRICE*TAX_RATE')
|
||||
->setCellValue('B5', '=PRICE*(1+TAX_RATE)');
|
||||
|
||||
echo sprintf(
|
||||
'With a Tax Rate of %.2f and a net price of %.2f, Tax is %.2f and the gross price is %.2f',
|
||||
$worksheet->getCell('B1')->getCalculatedValue(),
|
||||
$worksheet->getCell('B3')->getValue(),
|
||||
$worksheet->getCell('B4')->getCalculatedValue(),
|
||||
$worksheet->getCell('B5')->getCalculatedValue()
|
||||
), PHP_EOL;
|
||||
```
|
||||
`/samples/DefinedNames/SimpleNamedRange.php`
|
||||
|
||||
This makes formulae in the generated spreadsheet easier to understand when viewing it them MS Excel. Using these Named Ranges (providing meaningful human-readable names for cells) makes the purpose of the formula immediately clear. We don't need to look for cell `B2` to see what it is, the name tells us.
|
||||
|
||||
And, if the Tax Rate changes to 16%, then we only need to change the value in cell `B1` to the new Tax rate (`=16%`), or if we want to calculate the Tax Charges for a different net price, that will immediately be reflected in all the calculations that reference those Named Ranges. No matter whereabouts in the worksheet I used that Named Range, it always references the value in cell `B1`.
|
||||
|
||||
In fact, because we were required to specify a worksheet when we defined the name, that name is available from any worksheet within the spreadsheet, and always means cell `B2` in this worksheet (but see the notes on Named Range Scope below).
|
||||
|
||||
### Absolute Named Ranges
|
||||
|
||||
In the above example, when I define the Named Range values (e.g. `'=$B$1'`), I used a `$` before both the row and the column. This made the Named Range an Absolute Reference.
|
||||
|
||||
Another example:
|
||||
```php
|
||||
// Set up some basic data for a timesheet
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Charge Rate/hour:')
|
||||
->setCellValue('B1', '7.50')
|
||||
->setCellValue('A3', 'Date')
|
||||
->setCellValue('B3', 'Hours')
|
||||
->setCellValue('C3', 'Charge');
|
||||
|
||||
// Define named range using an absolute cell reference
|
||||
$spreadsheet->addNamedRange( new NamedRange('CHARGE_RATE', $worksheet, '=$B$1') );
|
||||
|
||||
$workHours = [
|
||||
'2020-0-06' => 7.5,
|
||||
'2020-0-07' => 7.25,
|
||||
'2020-0-08' => 6.5,
|
||||
'2020-0-09' => 7.0,
|
||||
'2020-0-10' => 5.5,
|
||||
];
|
||||
|
||||
// Populate the Timesheet
|
||||
$startRow = 4;
|
||||
$row = $startRow;
|
||||
foreach ($workHours as $date => $hours) {
|
||||
$worksheet
|
||||
->setCellValue("A{$row}", $date)
|
||||
->setCellValue("B{$row}", $hours)
|
||||
->setCellValue("C{$row}", "=B{$row}*CHARGE_RATE");
|
||||
$row++;
|
||||
}
|
||||
$endRow = $row - 1;
|
||||
|
||||
++$row;
|
||||
$worksheet
|
||||
->setCellValue("B{$row}", "=SUM(B{$startRow}:B{$endRow})")
|
||||
->setCellValue("C{$row}", "=SUM(C{$startRow}:C{$endRow})");
|
||||
|
||||
|
||||
echo sprintf(
|
||||
'Worked %.2f hours at a rate of %.2f - Charge to the client is %.2f',
|
||||
$worksheet->getCell("B{$row}")->getCalculatedValue(),
|
||||
$worksheet->getCell('B1')->getValue(),
|
||||
$worksheet->getCell("C{$row}")->getCalculatedValue()
|
||||
), PHP_EOL;
|
||||
```
|
||||
`/samples/DefinedNames/AbsoluteNamedRange.php`
|
||||
|
||||
Because the Named Range `CHARGE_RATE` is defined as an Absolute cell reference, then it always references cell `B2` no matter where it is referenced in a formula in the spreadsheet.
|
||||
|
||||
### Relative Named Ranges
|
||||
|
||||
The previous example showed a simple timesheet using an Absolute Reference for the Charge Rate, used to calculate our billed charges to client.
|
||||
|
||||
The use of `B{$row}` in our formula (at least it will appear as an actual cell reference in MS Excel if we save the file and open it) requires a bit of mental agility to remember that column `B` is our hours for that day. Why can't we use another Named Range called something like `HOURS_PER_DAY` to make the formula more easily readable and meaningful.
|
||||
|
||||
But if we used an Absolute Named Range for `HOURS_PER_DAY`, then we'd need a different Named Range for each day (`MONDAY_HOURS_PER_DAY`, `TUESDAY_HOURS_PER_DAY`, etc), and a different formula for each day of the week; if we kept a monthly timesheet, we would have to defined a different Named Range for every day of the month... and that's a lot more trouble than it's worth, and quickly becomes unmanageable.
|
||||
|
||||
This is where Relative Named Ranges are very useful.
|
||||
|
||||
```php
|
||||
// Set up some basic data for a timesheet
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Charge Rate/hour:')
|
||||
->setCellValue('B1', '7.50')
|
||||
->setCellValue('A3', 'Date')
|
||||
->setCellValue('B3', 'Hours')
|
||||
->setCellValue('C3', 'Charge');
|
||||
|
||||
// Define named ranges
|
||||
// CHARGE_RATE is an absolute cell reference that always points to cell B1
|
||||
$spreadsheet->addNamedRange( new NamedRange('CHARGE_RATE', $worksheet, '=$B$1') );
|
||||
// HOURS_PER_DAY is a relative cell reference that always points to column B, but to a cell in the row where it is used
|
||||
$spreadsheet->addNamedRange( new NamedRange('HOURS_PER_DAY', $worksheet, '=$B1') );
|
||||
|
||||
$workHours = [
|
||||
'2020-0-06' => 7.5,
|
||||
'2020-0-07' => 7.25,
|
||||
'2020-0-08' => 6.5,
|
||||
'2020-0-09' => 7.0,
|
||||
'2020-0-10' => 5.5,
|
||||
];
|
||||
|
||||
// Populate the Timesheet
|
||||
$startRow = 4;
|
||||
$row = $startRow;
|
||||
foreach ($workHours as $date => $hours) {
|
||||
$worksheet
|
||||
->setCellValue("A{$row}", $date)
|
||||
->setCellValue("B{$row}", $hours)
|
||||
->setCellValue("C{$row}", "=HOURS_PER_DAY*CHARGE_RATE");
|
||||
$row++;
|
||||
}
|
||||
$endRow = $row - 1;
|
||||
|
||||
++$row;
|
||||
$worksheet
|
||||
->setCellValue("B{$row}", "=SUM(B{$startRow}:B{$endRow})")
|
||||
->setCellValue("C{$row}", "=SUM(C{$startRow}:C{$endRow})");
|
||||
|
||||
|
||||
echo sprintf(
|
||||
'Worked %.2f hours at a rate of %.2f - Charge to the client is %.2f',
|
||||
$worksheet->getCell("B{$row}")->getCalculatedValue(),
|
||||
$worksheet->getCell('B1')->getValue(),
|
||||
$worksheet->getCell("C{$row}")->getCalculatedValue()
|
||||
), PHP_EOL;
|
||||
```
|
||||
`/samples/DefinedNames/RelativeNamedRange.php`
|
||||
|
||||
The difference in the cell definition for `HOURS_PER_DAY` (`'=$B1'`) is that we have a `$` in front of the column `B`, but not in front of the row number. The `$` makes the column absolute: no matter where in the worksheet we use this name, it always references column `B`. Without a `$`in front of the row number, we make the row number relative, relative to the row where the name appears in a formula, so it effectively replaces the `1` with its own row number when it executes the calculation.
|
||||
|
||||
When it is used in the formula in row 4, then it references cell `B4`, when it appears in row 5, it references cell `B5`, and so on. Using a Relative Named Range, we can use the same Named Range to refer to cells in different rows (and/or different columns), so we can re-use the same Named Range to refer to different cells relative to the row (or column) where we use them.
|
||||
|
||||
---
|
||||
|
||||
Named Ranges aren't limited to a single cell, but can point to a range of cells. A common use case might be to provide a series of column totals at the bottom of a dataset. Let's take our timesheet, and modify it just slightly to use a Relative column range for that purpose.
|
||||
|
||||
I won't replicate the entire code from the previous example, because I'm only changing a few lines; but we just replace the block:
|
||||
```php
|
||||
++$row;
|
||||
$worksheet
|
||||
->setCellValue("B{$row}", "=SUM(B{$startRow}:B{$endRow})")
|
||||
->setCellValue("C{$row}", "=SUM(C{$startRow}:C{$endRow})");
|
||||
```
|
||||
with:
|
||||
```php
|
||||
// COLUMN_TOTAL is another relative cell reference that always points to the same range of rows but to cell in the column where it is used
|
||||
$spreadsheet->addNamedRange( new NamedRange('COLUMN_DATA_VALUES', $worksheet, "=A\${$startRow}:A\${$endRow}") );
|
||||
|
||||
++$row;
|
||||
$worksheet
|
||||
->setCellValue("B{$row}", "=SUM(COLUMN_DATA_VALUES)")
|
||||
->setCellValue("C{$row}", "=SUM(COLUMN_DATA_VALUES)");
|
||||
```
|
||||
`/samples/DefinedNames/RelativeNamedRange2.php`
|
||||
|
||||
Now that I've specified column as relative in the definition of `COLUMN_DATA_VALUES` with an address of column `A`, and the rows are absolute. When the same Relative Named Range is used in column `B`,it references cells in column `B` rather than `A`; and when it is used in column `C`, it references cells in column `C`.
|
||||
|
||||
While we still have a piece of code (`"=A\${$startRow}:A\${$endRow}"`) that isn't easily human-readable, when we open the generated spreadsheet in MS Excel, the displayed formula in for the cells for the totals is immediately understandable.
|
||||
|
||||
### Named Range Scope
|
||||
|
||||
Whenever we define a Named Range, we are required to specify a worksheet, and that name is then available from any worksheet within the spreadsheet, and always means that cell or cell range in the specified worksheet.
|
||||
|
||||
```php
|
||||
// Set up some basic data for a timesheet
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Charge Rate/hour:')
|
||||
->setCellValue('B1', '7.50');
|
||||
|
||||
// Define a global named range on the first worksheet for our Charge Rate
|
||||
// CHARGE_RATE is an absolute cell reference that always points to cell B1
|
||||
// Because it is defined globally, it will still be usable from any worksheet in the spreadsheet
|
||||
$spreadsheet->addNamedRange( new NamedRange('CHARGE_RATE', $worksheet, '=$B$1') );
|
||||
|
||||
// Create a second worksheet as our client timesheet
|
||||
$worksheet = $spreadsheet->addSheet(new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet($spreadsheet, 'Client Timesheet'));
|
||||
|
||||
// Define named ranges
|
||||
// HOURS_PER_DAY is a relative cell reference that always points to column B, but to a cell in the row where it is used
|
||||
$spreadsheet->addNamedRange( new NamedRange('HOURS_PER_DAY', $worksheet, '=$B1') );
|
||||
|
||||
// Set up some basic data for a timesheet
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Date')
|
||||
->setCellValue('B1', 'Hours')
|
||||
->setCellValue('C1', 'Charge');
|
||||
|
||||
$workHours = [
|
||||
'2020-0-06' => 7.5,
|
||||
'2020-0-07' => 7.25,
|
||||
'2020-0-08' => 6.5,
|
||||
'2020-0-09' => 7.0,
|
||||
'2020-0-10' => 5.5,
|
||||
];
|
||||
|
||||
// Populate the Timesheet
|
||||
$startRow = 2;
|
||||
$row = $startRow;
|
||||
foreach ($workHours as $date => $hours) {
|
||||
$worksheet
|
||||
->setCellValue("A{$row}", $date)
|
||||
->setCellValue("B{$row}", $hours)
|
||||
->setCellValue("C{$row}", "=HOURS_PER_DAY*CHARGE_RATE");
|
||||
$row++;
|
||||
}
|
||||
$endRow = $row - 1;
|
||||
|
||||
// COLUMN_TOTAL is another relative cell reference that always points to the same range of rows but to cell in the column where it is used
|
||||
$spreadsheet->addNamedRange( new NamedRange('COLUMN_DATA_VALUES', $worksheet, "=A\${$startRow}:A\${$endRow}") );
|
||||
|
||||
++$row;
|
||||
$worksheet
|
||||
->setCellValue("B{$row}", "=SUM(COLUMN_DATA_VALUES)")
|
||||
->setCellValue("C{$row}", "=SUM(COLUMN_DATA_VALUES)");
|
||||
|
||||
echo sprintf(
|
||||
'Worked %.2f hours at a rate of %s - Charge to the client is %.2f',
|
||||
$worksheet->getCell("B{$row}")->getCalculatedValue(),
|
||||
$chargeRateCellValue = $spreadsheet
|
||||
->getSheetByName($spreadsheet->getNamedRange('CHARGE_RATE')->getWorksheet()->getTitle())
|
||||
->getCell($spreadsheet->getNamedRange('CHARGE_RATE')->getCellsInRange()[0])->getValue(),
|
||||
$worksheet->getCell("C{$row}")->getCalculatedValue()
|
||||
), PHP_EOL;
|
||||
```
|
||||
`/samples/DefinedNames/ScopedNamedRange.php`
|
||||
|
||||
Even though `CHARGE_RATE` references a cell on a different worksheet, because is set as global (the default) it is accessible from any worksheet in the spreadsheet. so when we reference it in formulae on the second timesheet worksheet, we are able to access the value from that first worksheet and use it in our calculations.
|
||||
|
||||
---
|
||||
|
||||
However, a Named Range can be locally scoped so that it is only available when referenced from a specific worksheet, or it can be globally scoped. This means that you can use the same Named Range name with different values on different worksheets.
|
||||
|
||||
Building further on our timesheet, perhaps we use a different worksheet for each client, and we use the same hourly rate when billing most of our clients; but for one particular client (perhaps doing work for a a friend) we use a lower rate.
|
||||
|
||||
```php
|
||||
$clients = [
|
||||
'Client #1 - Full Hourly Rate' => [
|
||||
'2020-0-06' => 2.5,
|
||||
'2020-0-07' => 2.25,
|
||||
'2020-0-08' => 6.0,
|
||||
'2020-0-09' => 3.0,
|
||||
'2020-0-10' => 2.25,
|
||||
],
|
||||
'Client #2 - Full Hourly Rate' => [
|
||||
'2020-0-06' => 1.5,
|
||||
'2020-0-07' => 2.75,
|
||||
'2020-0-08' => 0.0,
|
||||
'2020-0-09' => 4.5,
|
||||
'2020-0-10' => 3.5,
|
||||
],
|
||||
'Client #3 - Reduced Hourly Rate' => [
|
||||
'2020-0-06' => 3.5,
|
||||
'2020-0-07' => 2.5,
|
||||
'2020-0-08' => 1.5,
|
||||
'2020-0-09' => 0.0,
|
||||
'2020-0-10' => 1.25,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($clients as $clientName => $workHours) {
|
||||
$worksheet = $spreadsheet->addSheet(new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet($spreadsheet, $clientName));
|
||||
|
||||
// Set up some basic data for a timesheet
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Charge Rate/hour:')
|
||||
->setCellValue('B1', '7.50')
|
||||
->setCellValue('A3', 'Date')
|
||||
->setCellValue('B3', 'Hours')
|
||||
->setCellValue('C3', 'Charge');
|
||||
;
|
||||
|
||||
// Define named ranges
|
||||
// CHARGE_RATE is an absolute cell reference that always points to cell B1
|
||||
$spreadsheet->addNamedRange( new NamedRange('CHARGE_RATE', $worksheet, '=$B$1', true) );
|
||||
// HOURS_PER_DAY is a relative cell reference that always points to column B, but to a cell in the row where it is used
|
||||
$spreadsheet->addNamedRange( new NamedRange('HOURS_PER_DAY', $worksheet, '=$B1', true) );
|
||||
|
||||
// Populate the Timesheet
|
||||
$startRow = 4;
|
||||
$row = $startRow;
|
||||
foreach ($workHours as $date => $hours) {
|
||||
$worksheet
|
||||
->setCellValue("A{$row}", $date)
|
||||
->setCellValue("B{$row}", $hours)
|
||||
->setCellValue("C{$row}", "=HOURS_PER_DAY*CHARGE_RATE");
|
||||
$row++;
|
||||
}
|
||||
$endRow = $row - 1;
|
||||
|
||||
// COLUMN_TOTAL is another relative cell reference that always points to the same range of rows but to cell in the column where it is used
|
||||
$spreadsheet->addNamedRange( new NamedRange('COLUMN_TOTAL', $worksheet, "=A\${$startRow}:A\${$endRow}", true) );
|
||||
|
||||
++$row;
|
||||
$worksheet
|
||||
->setCellValue("B{$row}", "=SUM(COLUMN_TOTAL)")
|
||||
->setCellValue("C{$row}", "=SUM(COLUMN_TOTAL)");
|
||||
}
|
||||
$spreadsheet->removeSheetByIndex(0);
|
||||
|
||||
// Set the reduced charge rate for our special client
|
||||
$worksheet
|
||||
->setCellValue("B1", 4.5);
|
||||
|
||||
foreach ($spreadsheet->getAllSheets() as $worksheet) {
|
||||
echo sprintf(
|
||||
'Worked %.2f hours for "%s" at a rate of %.2f - Charge to the client is %.2f',
|
||||
$worksheet->getCell("B{$row}")->getCalculatedValue(),
|
||||
$worksheet->getTitle(),
|
||||
$worksheet->getCell('B1')->getValue(),
|
||||
$worksheet->getCell("C{$row}")->getCalculatedValue()
|
||||
), PHP_EOL;
|
||||
}
|
||||
```
|
||||
`/samples/DefinedNames/ScopedNamedRange2.php`
|
||||
|
||||
Now we are creating three worksheets for each of three different clients. Because each Named Range is linked to a worksheet, we need to create three sets of Named Ranges, so that we don't simply reference the cells on only one of the worksheets; but because we are locally scoping them (note the extra boolean argument used when we define the Named Ranges) we can use the same names on each worksheet, and they will reference the correct cells when we use them in our formulae on that worksheet.
|
||||
|
||||
When Named Ranges are being evaluated, the logic looks first to see if there is a locally scoped Named Range defined for the current worksheet. If there is, then that is the Named Range that will be used in the calculation. If no locally scoped Named Range with that name is found, the logic then looks to see if there is a globally scoped Named Range definition, and will use that if it is found. If no Named Range of the required name is found scoped to the current worksheet, or globally scoped, then a `#NAME` error will be returned.
|
||||
|
||||
## Named Formulae
|
||||
|
||||
A Named Formula is a stored formula, or part of a formula, that can be referenced in cells by name, and re-used in many different places within the spreadsheet.
|
||||
|
||||
As an example, I'll modify the simple Tax Calculator that I created as my example for Named Ranges.
|
||||
|
||||
```php
|
||||
// Add some Named Formulae
|
||||
// The first to store our tax rate
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('TAX_RATE', $worksheet, '=19%'));
|
||||
// The second to calculate the Tax on a Price value (Note that `PRICE` is defined later as a Named Range)
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('TAX', $worksheet, '=PRICE*TAX_RATE'));
|
||||
|
||||
// Set up some basic data
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Tax Rate:')
|
||||
->setCellValue('B1', '=TAX_RATE')
|
||||
->setCellValue('A3', 'Net Price:')
|
||||
->setCellValue('B3', 19.99)
|
||||
->setCellValue('A4', 'Tax:')
|
||||
->setCellValue('A5', 'Price including Tax:');
|
||||
|
||||
// Define a named range that we can use in our formulae
|
||||
$spreadsheet->addNamedRange(new NamedRange('PRICE', $worksheet, '=$B$3'));
|
||||
|
||||
// Reference the defined formulae in worksheet formulae
|
||||
$worksheet
|
||||
->setCellValue('B4', '=TAX')
|
||||
->setCellValue('B5', '=PRICE+TAX');
|
||||
|
||||
echo sprintf(
|
||||
'With a Tax Rate of %.2f and a net price of %.2f, Tax is %.2f and the gross price is %.2f',
|
||||
$worksheet->getCell('B1')->getCalculatedValue(),
|
||||
$worksheet->getCell('B3')->getValue(),
|
||||
$worksheet->getCell('B4')->getCalculatedValue(),
|
||||
$worksheet->getCell('B5')->getCalculatedValue()
|
||||
), PHP_EOL;
|
||||
```
|
||||
`/samples/DefinedNames/SimpleNamedFormula.php`
|
||||
|
||||
There are a few points to note here:
|
||||
|
||||
Firstly. we are actually storing the tax rate in a named formula (`TAX_RATE`) rather than as a cell value. When we display the tax rate in cell `B1`, we are really storing an instruction for MS Excel to evaluate the formula and display the result in that cell.
|
||||
|
||||
Then we are using a Named Formula `TAX` that references both another Named Formula (`TAX_RATE`) and a Named Range (`PRICE`) and executes a calculation using them both (`PRICE * TAX_RATE`).
|
||||
|
||||
Finally, we are using the formula `TAX` in two different contexts. Once to display the tax value (in cell `B4`); and a second time as part of another formula (`PRICE + TAX`) in cell `B5`.
|
||||
|
||||
---
|
||||
|
||||
Named Formulae aren't just restricted tosimple mathematics, but can include MS EXcel functions as well to provide a lot of flexibility; and they can reference values on other worksheets.
|
||||
|
||||
```php
|
||||
$worksheet = $spreadsheet->setActiveSheetIndex(0);
|
||||
setYearlyData($worksheet,'2019', $data2019);
|
||||
$worksheet = $spreadsheet->addSheet(new Worksheet($spreadsheet));
|
||||
setYearlyData($worksheet,'2020', $data2020);
|
||||
$worksheet = $spreadsheet->addSheet(new Worksheet($spreadsheet));
|
||||
setYearlyData($worksheet,'2020', [], 'GROWTH');
|
||||
|
||||
function setYearlyData(Worksheet $worksheet, string $year, $yearlyData, ?string $title = null) {
|
||||
// Set up some basic data
|
||||
$worksheetTitle = $title ?: $year;
|
||||
$worksheet
|
||||
->setTitle($worksheetTitle)
|
||||
->setCellValue('A1', 'Month')
|
||||
->setCellValue('B1', $worksheetTitle === 'GROWTH' ? 'Growth' : 'Sales')
|
||||
->setCellValue('C1', $worksheetTitle === 'GROWTH' ? 'Profit Growth' : 'Margin')
|
||||
->setCellValue('A2', Date::stringToExcel("{$year}-01-01"));
|
||||
for ($row = 3; $row <= 13; ++$row) {
|
||||
$worksheet->setCellValue("A{$row}", "=NEXT_MONTH");
|
||||
}
|
||||
|
||||
if (!empty($yearlyData)) {
|
||||
$worksheet->fromArray($yearlyData, null, 'B2');
|
||||
} else {
|
||||
for ($row = 2; $row <= 13; ++$row) {
|
||||
$worksheet->setCellValue("B{$row}", "=GROWTH");
|
||||
$worksheet->setCellValue("C{$row}", "=PROFIT_GROWTH");
|
||||
}
|
||||
}
|
||||
|
||||
$worksheet->getStyle('A1:C1')
|
||||
->getFont()->setBold(true);
|
||||
$worksheet->getStyle('A2:A13')
|
||||
->getNumberFormat()
|
||||
->setFormatCode('mmmm');
|
||||
$worksheet->getStyle('B2:C13')
|
||||
->getNumberFormat()
|
||||
->setFormatCode($worksheetTitle === 'GROWTH' ? '0.00%' : '_-€* #,##0_-');
|
||||
}
|
||||
|
||||
// Add some Named Formulae
|
||||
// The first to store our tax rate
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('NEXT_MONTH', $worksheet, "=EDATE(OFFSET(\$A1,-1,0),1)"));
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('GROWTH', $worksheet, "=IF('2020'!\$B1=\"\",\"-\",(('2020'!\$B1/'2019'!\$B1)-1))"));
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('PROFIT_GROWTH', $worksheet, "=IF('2020'!\$C1=\"\",\"-\",(('2020'!\$C1/'2019'!\$C1)-1))"));
|
||||
|
||||
for ($row = 2; $row<=7; ++$row) {
|
||||
$month = $worksheet->getCell("A{$row}")->getFormattedValue();
|
||||
$growth = $worksheet->getCell("B{$row}")->getFormattedValue();
|
||||
$profitGrowth = $worksheet->getCell("C{$row}")->getFormattedValue();
|
||||
|
||||
echo "Growth for {$month} is {$growth}, with a Profit Growth of {$profitGrowth}", PHP_EOL;
|
||||
}
|
||||
```
|
||||
`/samples/DefinedNames/CrossWorksheetNamedFormula.php`
|
||||
|
||||
Here we're creating two Named Formulae that both use the `IF()` function, and that compare values on two different worksheets, and calculate the percentage difference between the two. We're also creating a Named Formula that uses the `OFFSET()` function to reference the cell immediately above the current Relative cell reference.
|
||||
|
||||
## Combining Named Ranges and Formulae
|
||||
|
||||
For a slightly more complex example combining Named Ranges and Named Formulae, we can build on our client timesheet.
|
||||
|
||||
```php
|
||||
// Set up some basic data for a timesheet
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Charge Rate/hour:')
|
||||
->setCellValue('B1', '7.50')
|
||||
->setCellValue('A3', 'Date')
|
||||
->setCellValue('B3', 'Hours')
|
||||
->setCellValue('C3', 'Charge');
|
||||
|
||||
// Define named ranges
|
||||
// CHARGE_RATE is an absolute cell reference that always points to cell B1
|
||||
$spreadsheet->addNamedRange(new NamedRange('CHARGE_RATE', $worksheet, '=$B$1'));
|
||||
// HOURS_PER_DAY is a relative cell reference that always points to column B, but to a cell in the row where it is used
|
||||
$spreadsheet->addNamedRange(new NamedRange('HOURS_PER_DAY', $worksheet, '=$B1'));
|
||||
// Set up the formula for calculating the daily charge
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('DAILY_CHARGE', null, '=HOURS_PER_DAY*CHARGE_RATE'));
|
||||
// Set up the formula for calculating the column totals
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('COLUMN_TOTALS', null, '=SUM(COLUMN_DATA_VALUES)'));
|
||||
|
||||
|
||||
$workHours = [
|
||||
'2020-0-06' => 7.5,
|
||||
'2020-0-07' => 7.25,
|
||||
'2020-0-08' => 6.5,
|
||||
'2020-0-09' => 7.0,
|
||||
'2020-0-10' => 5.5,
|
||||
];
|
||||
|
||||
// Populate the Timesheet
|
||||
$startRow = 4;
|
||||
$row = $startRow;
|
||||
foreach ($workHours as $date => $hours) {
|
||||
$worksheet
|
||||
->setCellValue("A{$row}", $date)
|
||||
->setCellValue("B{$row}", $hours)
|
||||
->setCellValue("C{$row}", '=DAILY_CHARGE');
|
||||
++$row;
|
||||
}
|
||||
$endRow = $row - 1;
|
||||
|
||||
// COLUMN_TOTAL is another relative cell reference that always points to the same range of rows but to cell in the column where it is used
|
||||
$spreadsheet->addNamedRange(new NamedRange('COLUMN_DATA_VALUES', $worksheet, "=A\${$startRow}:A\${$endRow}"));
|
||||
|
||||
++$row;
|
||||
$worksheet
|
||||
->setCellValue("B{$row}", '=COLUMN_TOTALS')
|
||||
->setCellValue("C{$row}", '=COLUMN_TOTALS');
|
||||
|
||||
echo sprintf(
|
||||
'Worked %.2f hours at a rate of %.2f - Charge to the client is %.2f',
|
||||
$worksheet->getCell("B{$row}")->getCalculatedValue(),
|
||||
$worksheet->getCell('B1')->getValue(),
|
||||
$worksheet->getCell("C{$row}")->getCalculatedValue()
|
||||
), PHP_EOL;
|
||||
```
|
||||
`/samples/DefinedNames/NamedFormulaeAndRanges.php`
|
||||
|
||||
The main point to notice in this example is that you must specify a Worksheet for Named Ranges, but that it isn't required for Named Formulae; in fact, specifying a Worksheet for named Formulae can lead to MS Excel errors when a saved file is opened. Generally, it is far safer to specify a null Worksheet value when creating a Named Formula, unless it references cell values explicitly, or you wish to scope it to that Worksheet.
|
||||
|
||||
It also doesn't matter what order we define our Named Ranges and Formulae, even when some are dependent on others: this only matters when we try to use them in a cell calculation, or when we save the file; and as long as every Defined Name has been defined at that point, then it isn't important. In this case, we couldn't define `COLUMN_DATA_VALUES` until we new the range of rows that it needed to contain; but we could still define the `COLUMN_TOTALS` formula before that.
|
||||
|
||||
## Additional Comments
|
||||
|
||||
### Helper
|
||||
|
||||
In all the examples so far, we have explicitly used the `NamedRange` and `NamedFormula` classes, and the Spreadsheet's `addNamedRange()` and `addNamedFormula()` methods, e.g.
|
||||
```php
|
||||
$spreadsheet->addNamedRange(new NamedRange('HOURS_PER_DAY', $worksheet, '=$B1'));
|
||||
```
|
||||
However, this can lead to errors if we accidentally set a formula value for a Named Range, or a range value for a Named Formula.
|
||||
|
||||
As a helper, the DefinedName class provides a static method that can identify whether the value expression is a Range or a Formula, and instantiate the appropriate class.
|
||||
```php
|
||||
$this->spreadsheet->addDefinedName(
|
||||
DefinedName::createInstance('FOO', $this->spreadsheet->getSheetByName('Sheet #2'), '=16%', true)
|
||||
);
|
||||
```
|
||||
|
||||
### Naming Names
|
||||
|
||||
The names that you assign to Defined Name must follow the following set of rules:
|
||||
- The first character of a name must be one of the following characters:
|
||||
- letter (including UTF-8 letters)
|
||||
- underscore (`_`)
|
||||
- Remaining characters in the name can be
|
||||
- letters (including UTF-8 letters)
|
||||
- numbers (including UTF-8 numbers)
|
||||
- periods (`.`)
|
||||
- underscore characters (`_`)
|
||||
- The following are not allowed:
|
||||
- Space characters are not allowed as part of a name.
|
||||
- Names can't look like cell addresses, such as A35 or R2C2
|
||||
- Names are not case sensitive. For example, `North` and `NORTH` are treated as the same name.
|
||||
|
||||
### Limitations
|
||||
|
||||
PHPSpreadsheet doesn't yet fully validate the names that you use, so it is possible to create a spreadsheet in PHPSpreadsheet that will break when you save and try to open it in MS Excel; or that will break PHPSpreadsheet when they are referenced in a cell.
|
||||
So please be sensible when creating names, and follow the rules listed above.
|
||||
|
||||
---
|
||||
|
||||
There is nothing to stop you creating a Defined Name that matches an existing Function name
|
||||
```php
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('SUM', $worksheet, '=SUM(A1:E5)'));
|
||||
```
|
||||
And this will work without problems in MS Excel. However, it is not guaranteed to work correctly in PHPSpreadsheet; and will certainly cause confusion for anybody reading it; so it is not recommended. Names exist to give clarity to the person reading the spreadsheet, and a cell containing `=SUM` is even harder to understand (what is it the sum of?) than a cell containing `=SUM(B4:B8)`. Use names that provide meaning, like `SUM_OF_WORKED_HOURS`.
|
||||
|
||||
---
|
||||
|
||||
You cannot have a Named Range and a Named Formula with the same name, unless they are differently scoped.
|
||||
|
||||
---
|
||||
|
||||
MS Excel uses some "special tricks" to simulate Relative Named Ranges where the row or column comes before the current row or column, useful if you want to get column totals that don't include the current cell. These "tricks" aren't supported by PHPSpreadsheet, but can be simulated using the `OFFSET()` function in a Named Formula.
|
||||
In our `RelativeNamedRange2.php` example, we explicitly created the `COLUMN_DATA_VALUES` Named Range using only the rows that we knew should be included, so that we weren't including the current row (where we were displaying the total) and creating a cyclic reference:
|
||||
```php
|
||||
// COLUMN_TOTAL is another relative cell reference that always points to the same range of rows but to cell in the column where it is used
|
||||
$spreadsheet->addNamedRange(new NamedRange('COLUMN_DATA_VALUES', $worksheet, "=A\${$startRow}:A\${$endRow}"));
|
||||
```
|
||||
We could instead have created a Named Function using `OFFSET()` to specify just the start row, and offset the end row by -1 row:
|
||||
```php
|
||||
// COLUMN_TOTAL is another relative cell reference that always points to the same range of rows but to cell in the column where it is used
|
||||
// To avoid including the current row,or having to hard-code the range itself (as we did in the previous example)
|
||||
// we wrap it in a named formula using the OFFSET() function
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('COLUMN_DATA_VALUES', $worksheet, "=OFFSET(A\$4:A1, -1, 0)"));
|
||||
```
|
||||
as demonstrated in example `RelativeNamedRangeAsFunction.php`.
|
|
@ -478,7 +478,7 @@ imports onto the 6th sheet:
|
|||
```php
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv();
|
||||
$reader->setDelimiter(';');
|
||||
$reader->setEnclosure('');
|
||||
$reader->setEnclosure('"');
|
||||
$reader->setSheetIndex(5);
|
||||
|
||||
$reader->loadIntoExisting("05featuredemo.csv", $spreadsheet);
|
||||
|
@ -505,13 +505,26 @@ file:
|
|||
```php
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Csv($spreadsheet);
|
||||
$writer->setDelimiter(';');
|
||||
$writer->setEnclosure('');
|
||||
$writer->setEnclosure('"');
|
||||
$writer->setLineEnding("\r\n");
|
||||
$writer->setSheetIndex(0);
|
||||
|
||||
$writer->save("05featuredemo.csv");
|
||||
```
|
||||
|
||||
#### CSV enclosures
|
||||
|
||||
By default, all CSV fields are wrapped in the enclosure character,
|
||||
which defaults to double-quote.
|
||||
You can change to use the enclosure character only when required:
|
||||
|
||||
``` php
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Csv($spreadsheet);
|
||||
$writer->setEnclosureRequired(false);
|
||||
|
||||
$writer->save("05featuredemo.csv");
|
||||
```
|
||||
|
||||
#### Write a specific worksheet
|
||||
|
||||
CSV files can only contain one worksheet. Therefore, you can specify
|
||||
|
@ -538,6 +551,7 @@ $writer->save("05featuredemo.csv");
|
|||
CSV files are written in UTF-8. If they do not contain characters
|
||||
outside the ASCII range, nothing else need be done.
|
||||
However, if such characters are in the file,
|
||||
or if the file starts with the 2 characters 'ID',
|
||||
it should explicitly include a BOM file header;
|
||||
if it doesn't, Excel will not interpret those characters correctly.
|
||||
This can be enabled by using the following code:
|
||||
|
@ -693,7 +707,7 @@ $sty = $writer->generateStyles(false); // do not write <style> and </style>
|
|||
$newstyle = <<<EOF
|
||||
<style type='text/css'>
|
||||
$sty
|
||||
html {
|
||||
body {
|
||||
background-color: yellow;
|
||||
}
|
||||
</style>
|
||||
|
@ -703,16 +717,22 @@ echo $writer->generateSheetData();
|
|||
echo $writer->generateHTMLFooter();
|
||||
```
|
||||
|
||||
#### Writing UTF-8 HTML files
|
||||
#### Editing HTML during save via a callback
|
||||
|
||||
A HTML file can be marked as UTF-8 by writing a BOM file header. This
|
||||
can be enabled by using the following code:
|
||||
You can also add a callback function to edit the generated html
|
||||
before saving. For example, you could change the gridlines
|
||||
from a thin solid black line:
|
||||
|
||||
``` php
|
||||
function changeGridlines(string $html): string
|
||||
{
|
||||
return str_replace('{border: 1px solid black;}',
|
||||
'{border: 2px dashed red;}',
|
||||
$html);
|
||||
}
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Html($spreadsheet);
|
||||
$writer->setUseBOM(true);
|
||||
|
||||
$writer->save("05featuredemo.htm");
|
||||
$writer->setEditHtmlCallback('changeGridlines');
|
||||
$writer->save($filename);
|
||||
```
|
||||
|
||||
#### Decimal and thousands separators
|
||||
|
@ -841,6 +861,12 @@ $writer->setPreCalculateFormulas(false);
|
|||
$writer->save("05featuredemo.pdf");
|
||||
```
|
||||
|
||||
#### Editing Pdf during save via a callback
|
||||
|
||||
You can also add a callback function to edit the html used to
|
||||
generate the Pdf before saving.
|
||||
[See under Html](#editing-html-during-save-via-a-callback).
|
||||
|
||||
#### Decimal and thousands separators
|
||||
|
||||
See section `\PhpOffice\PhpSpreadsheet\Writer\Csv` how to control the
|
||||
|
|
|
@ -587,6 +587,13 @@ execution whenever you are setting more than one style property. But the
|
|||
difference may barely be measurable unless you have many different
|
||||
styles in your workbook.
|
||||
|
||||
You can perform the opposite function, exporting a Style as an array,
|
||||
as follows:
|
||||
|
||||
``` php
|
||||
$styleArray = $spreadsheet->getActiveSheet()->getStyle('A3')->exportArray();
|
||||
```
|
||||
|
||||
### Number formats
|
||||
|
||||
You often want to format numbers in Excel. For example you may want a
|
||||
|
@ -753,69 +760,74 @@ another style array.
|
|||
|
||||
Array key | Maps to property
|
||||
-------------|-------------------
|
||||
fill | getFill()
|
||||
font | getFont()
|
||||
borders | getBorders()
|
||||
alignment | getAlignment()
|
||||
numberFormat | getNumberFormat()
|
||||
protection | getProtection()
|
||||
|
||||
**\PhpOffice\PhpSpreadsheet\Style\Fill**
|
||||
|
||||
Array key | Maps to property
|
||||
-----------|-------------------
|
||||
fillType | setFillType()
|
||||
rotation | setRotation()
|
||||
startColor | getStartColor()
|
||||
endColor | getEndColor()
|
||||
color | getStartColor()
|
||||
|
||||
**\PhpOffice\PhpSpreadsheet\Style\Font**
|
||||
|
||||
Array key | Maps to property
|
||||
------------|-------------------
|
||||
name | setName()
|
||||
bold | setBold()
|
||||
italic | setItalic()
|
||||
underline | setUnderline()
|
||||
strikethrough | setStrikethrough()
|
||||
color | getColor()
|
||||
size | setSize()
|
||||
superscript | setSuperscript()
|
||||
subscript | setSubscript()
|
||||
|
||||
**\PhpOffice\PhpSpreadsheet\Style\Borders**
|
||||
|
||||
Array key | Maps to property
|
||||
------------------|-------------------
|
||||
allBorders | getLeft(); getRight(); getTop(); getBottom()
|
||||
left | getLeft()
|
||||
right | getRight()
|
||||
top | getTop()
|
||||
bottom | getBottom()
|
||||
diagonal | getDiagonal()
|
||||
vertical | getVertical()
|
||||
horizontal | getHorizontal()
|
||||
diagonalDirection | setDiagonalDirection()
|
||||
outline | setOutline()
|
||||
|
||||
**\PhpOffice\PhpSpreadsheet\Style\Border**
|
||||
|
||||
Array key | Maps to property
|
||||
------------|-------------------
|
||||
borderStyle | setBorderStyle()
|
||||
color | getColor()
|
||||
alignment | setAlignment()
|
||||
borders | setBorders()
|
||||
fill | setFill()
|
||||
font | setFont()
|
||||
numberFormat | setNumberFormat()
|
||||
protection | setProtection()
|
||||
quotePrefix | setQuotePrefix()
|
||||
|
||||
**\PhpOffice\PhpSpreadsheet\Style\Alignment**
|
||||
|
||||
Array key | Maps to property
|
||||
------------|-------------------
|
||||
horizontal | setHorizontal()
|
||||
vertical | setVertical()
|
||||
textRotation| setTextRotation()
|
||||
wrapText | setWrapText()
|
||||
shrinkToFit | setShrinkToFit()
|
||||
indent | setIndent()
|
||||
readOrder | setReadOrder()
|
||||
shrinkToFit | setShrinkToFit()
|
||||
textRotation| setTextRotation()
|
||||
vertical | setVertical()
|
||||
wrapText | setWrapText()
|
||||
|
||||
**\PhpOffice\PhpSpreadsheet\Style\Border**
|
||||
|
||||
Array key | Maps to property
|
||||
------------|-------------------
|
||||
borderStyle | setBorderStyle()
|
||||
color | setColor()
|
||||
|
||||
**\PhpOffice\PhpSpreadsheet\Style\Borders**
|
||||
|
||||
Array key | Maps to property
|
||||
------------------|-------------------
|
||||
allBorders | setLeft(); setRight(); setTop(); setBottom()
|
||||
bottom | setBottom()
|
||||
diagonal | setDiagonal()
|
||||
diagonalDirection | setDiagonalDirection()
|
||||
left | setLeft()
|
||||
right | setRight()
|
||||
top | setTop()
|
||||
|
||||
**\PhpOffice\PhpSpreadsheet\Style\Color**
|
||||
|
||||
Array key | Maps to property
|
||||
------------|-------------------
|
||||
argb | setARGB()
|
||||
|
||||
**\PhpOffice\PhpSpreadsheet\Style\Fill**
|
||||
|
||||
Array key | Maps to property
|
||||
-----------|-------------------
|
||||
color | getStartColor()
|
||||
endColor | getEndColor()
|
||||
fillType | setFillType()
|
||||
rotation | setRotation()
|
||||
startColor | getStartColor()
|
||||
|
||||
**\PhpOffice\PhpSpreadsheet\Style\Font**
|
||||
|
||||
Array key | Maps to property
|
||||
------------|-------------------
|
||||
bold | setBold()
|
||||
color | getColor()
|
||||
italic | setItalic()
|
||||
name | setName()
|
||||
size | setSize()
|
||||
strikethrough | setStrikethrough()
|
||||
subscript | setSubscript()
|
||||
superscript | setSuperscript()
|
||||
underline | setUnderline()
|
||||
|
||||
**\PhpOffice\PhpSpreadsheet\Style\NumberFormat**
|
||||
|
||||
|
@ -919,29 +931,53 @@ disallow inserting rows on a specific sheet, disallow sorting, ...
|
|||
- Cell: offers the option to lock/unlock a cell as well as show/hide
|
||||
the internal formula.
|
||||
|
||||
**Make sure you enable worksheet protection if you need any of the
|
||||
worksheet or cell protection features!** This can be done using the following
|
||||
code:
|
||||
|
||||
```php
|
||||
$spreadsheet->getActiveSheet()->getProtection()->setSheet(true);
|
||||
```
|
||||
|
||||
### Document
|
||||
|
||||
An example on setting document security:
|
||||
|
||||
```php
|
||||
$spreadsheet->getSecurity()->setLockWindows(true);
|
||||
$spreadsheet->getSecurity()->setLockStructure(true);
|
||||
$spreadsheet->getSecurity()->setWorkbookPassword("PhpSpreadsheet");
|
||||
$security = $spreadsheet->getSecurity();
|
||||
$security->setLockWindows(true);
|
||||
$security->setLockStructure(true);
|
||||
$security->setWorkbookPassword("PhpSpreadsheet");
|
||||
```
|
||||
|
||||
### Worksheet
|
||||
|
||||
An example on setting worksheet security:
|
||||
|
||||
```php
|
||||
$spreadsheet->getActiveSheet()
|
||||
->getProtection()->setPassword('PhpSpreadsheet');
|
||||
$spreadsheet->getActiveSheet()
|
||||
->getProtection()->setSheet(true);
|
||||
$spreadsheet->getActiveSheet()
|
||||
->getProtection()->setSort(true);
|
||||
$spreadsheet->getActiveSheet()
|
||||
->getProtection()->setInsertRows(true);
|
||||
$spreadsheet->getActiveSheet()
|
||||
->getProtection()->setFormatCells(true);
|
||||
$protection = $spreadsheet->getActiveSheet()->getProtection();
|
||||
$protection->setPassword('PhpSpreadsheet');
|
||||
$protection->setSheet(true);
|
||||
$protection->setSort(true);
|
||||
$protection->setInsertRows(true);
|
||||
$protection->setFormatCells(true);
|
||||
```
|
||||
|
||||
If writing Xlsx files you can specify the algorithm used to hash the password
|
||||
before calling `setPassword()` like so:
|
||||
|
||||
```php
|
||||
$protection = $spreadsheet->getActiveSheet()->getProtection();
|
||||
$protection->setAlgorithm(Protection::ALGORITHM_SHA_512);
|
||||
$protection->setSpinCount(20000);
|
||||
$protection->setPassword('PhpSpreadsheet');
|
||||
```
|
||||
|
||||
The salt should **not** be set manually and will be automatically generated
|
||||
when setting a new password.
|
||||
|
||||
### Cell
|
||||
|
||||
An example on setting cell security:
|
||||
|
||||
```php
|
||||
|
@ -950,14 +986,30 @@ $spreadsheet->getActiveSheet()->getStyle('B1')
|
|||
->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED);
|
||||
```
|
||||
|
||||
**Make sure you enable worksheet protection if you need any of the
|
||||
worksheet protection features!** This can be done using the following
|
||||
code:
|
||||
## Reading protected spreadsheet
|
||||
|
||||
Spreadsheets that are protected as described above can always be read by
|
||||
PhpSpreadsheet. There is no need to know the password or do anything special in
|
||||
order to read a protected file.
|
||||
|
||||
However if you need to implement a password verification mechanism, you can use the
|
||||
following helper method:
|
||||
|
||||
|
||||
```php
|
||||
$spreadsheet->getActiveSheet()->getProtection()->setSheet(true);
|
||||
$protection = $spreadsheet->getActiveSheet()->getProtection();
|
||||
$allowed = $protection->verify('my password');
|
||||
|
||||
if ($allowed) {
|
||||
doSomething();
|
||||
} else {
|
||||
throw new Exception('Incorrect password');
|
||||
}
|
||||
```
|
||||
|
||||
If you need to completely prevent reading a file by any tool, including PhpSpreadsheet,
|
||||
then you are looking for "encryption", not "protection".
|
||||
|
||||
## Setting data validation on a cell
|
||||
|
||||
Data validation is a powerful feature of Xlsx. It allows to specify an
|
||||
|
@ -1328,14 +1380,73 @@ $spreadsheet->getActiveSheet()->setCellValue('B1', 'Maarten');
|
|||
$spreadsheet->getActiveSheet()->setCellValue('B2', 'Balliauw');
|
||||
|
||||
// Define named ranges
|
||||
$spreadsheet->addNamedRange( new \PhpOffice\PhpSpreadsheet\NamedRange('PersonFN', $spreadsheet->getActiveSheet(), 'B1') );
|
||||
$spreadsheet->addNamedRange( new \PhpOffice\PhpSpreadsheet\NamedRange('PersonLN', $spreadsheet->getActiveSheet(), 'B2') );
|
||||
$spreadsheet->addNamedRange( new \PhpOffice\PhpSpreadsheet\NamedRange('PersonFN', $spreadsheet->getActiveSheet(), '$B$1'));
|
||||
$spreadsheet->addNamedRange( new \PhpOffice\PhpSpreadsheet\NamedRange('PersonLN', $spreadsheet->getActiveSheet(), '$B$2'));
|
||||
```
|
||||
|
||||
Optionally, a fourth parameter can be passed defining the named range
|
||||
local (i.e. only usable on the current worksheet). Named ranges are
|
||||
global by default.
|
||||
|
||||
## Define a named formula
|
||||
|
||||
In addition to named ranges, PhpSpreadsheet also supports the definition of named formulae. These can be
|
||||
defined using the following code:
|
||||
|
||||
```php
|
||||
// Add some data
|
||||
$spreadsheet->setActiveSheetIndex(0);
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Product')
|
||||
->setCellValue('B1', 'Quantity')
|
||||
->setCellValue('C1', 'Unit Price')
|
||||
->setCellValue('D1', 'Price')
|
||||
->setCellValue('E1', 'VAT')
|
||||
->setCellValue('F1', 'Total');
|
||||
|
||||
// Define named formula
|
||||
$spreadsheet->addNamedFormula( new \PhpOffice\PhpSpreadsheet\NamedFormula('GERMAN_VAT_RATE', $worksheet, '=16.0%'));
|
||||
$spreadsheet->addNamedFormula( new \PhpOffice\PhpSpreadsheet\NamedFormula('CALCULATED_PRICE', $worksheet, '=$B1*$C1'));
|
||||
$spreadsheet->addNamedFormula( new \PhpOffice\PhpSpreadsheet\NamedFormula('GERMAN_VAT', $worksheet, '=$D1*GERMAN_VAT_RATE'));
|
||||
$spreadsheet->addNamedFormula( new \PhpOffice\PhpSpreadsheet\NamedFormula('TOTAL_INCLUDING_VAT', $worksheet, '=$D1+$E1'));
|
||||
|
||||
$worksheet
|
||||
->setCellValue('A2', 'Advanced Web Application Architecture')
|
||||
->setCellValue('B2', 2)
|
||||
->setCellValue('C2', 23.0)
|
||||
->setCellValue('D2', '=CALCULATED_PRICE')
|
||||
->setCellValue('E2', '=GERMAN_VAT')
|
||||
->setCellValue('F2', '=TOTAL_INCLUDING_VAT');
|
||||
$spreadsheet->getActiveSheet()
|
||||
->setCellValue('A3', 'Object Design Style Guide')
|
||||
->setCellValue('B3', 5)
|
||||
->setCellValue('C3', 12.0)
|
||||
->setCellValue('D3', '=CALCULATED_PRICE')
|
||||
->setCellValue('E3', '=GERMAN_VAT')
|
||||
->setCellValue('F3', '=TOTAL_INCLUDING_VAT');
|
||||
$spreadsheet->getActiveSheet()
|
||||
->setCellValue('A4', 'PHP For the Web')
|
||||
->setCellValue('B4', 3)
|
||||
->setCellValue('C4', 10.0)
|
||||
->setCellValue('D4', '=CALCULATED_PRICE')
|
||||
->setCellValue('E4', '=GERMAN_VAT')
|
||||
->setCellValue('F4', '=TOTAL_INCLUDING_VAT');
|
||||
|
||||
// Use a relative named range to provide the totals for rows 2-4
|
||||
$spreadsheet->addNamedRange( new \PhpOffice\PhpSpreadsheet\NamedRange('COLUMN_TOTAL', $worksheet, '=A$2:A$4') );
|
||||
|
||||
$spreadsheet->getActiveSheet()
|
||||
->setCellValue('B6', '=SUBTOTAL(109,COLUMN_TOTAL)')
|
||||
->setCellValue('D6', '=SUBTOTAL(109,COLUMN_TOTAL)')
|
||||
->setCellValue('E6', '=SUBTOTAL(109,COLUMN_TOTAL)')
|
||||
->setCellValue('F6', '=SUBTOTAL(109,COLUMN_TOTAL)');
|
||||
```
|
||||
|
||||
As with named ranges, an optional fourth parameter can be passed defining the named formula
|
||||
scope as local (i.e. only usable on the specified worksheet). Otherwise, named formulae are
|
||||
global by default.
|
||||
|
||||
## Redirect output to a client's web browser
|
||||
|
||||
Sometimes, one really wants to output a file to a client''s browser,
|
||||
|
|
|
@ -43,3 +43,20 @@ More details of the features available once a locale has been set,
|
|||
including a list of the languages and locales currently supported, can
|
||||
be found in [Locale Settings for
|
||||
Formulae](./recipes.md#locale-settings-for-formulae).
|
||||
|
||||
## HTTP client
|
||||
|
||||
In order to use the `WEBSERVICE` function in formulae, you must configure an
|
||||
HTTP client. Assuming you chose Guzzle 7, this can be done like:
|
||||
|
||||
|
||||
```php
|
||||
use GuzzleHttp\Client;
|
||||
use Http\Factory\Guzzle\RequestFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
|
||||
$client = new Client();
|
||||
$requestFactory = new RequestFactory();
|
||||
|
||||
Settings::setHttpClient($client, $requestFactory);
|
||||
```
|
||||
|
|
|
@ -157,8 +157,10 @@ $spreadsheet->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:')
|
|||
$helper->log('Calculated data');
|
||||
for ($col = 'B'; $col != 'G'; ++$col) {
|
||||
for ($row = 14; $row <= 41; ++$row) {
|
||||
if ((($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue()) !== null) &&
|
||||
($formula[0] == '=')) {
|
||||
if (
|
||||
(($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue()) !== null) &&
|
||||
($formula[0] == '=')
|
||||
) {
|
||||
$helper->log('Value of ' . $col . $row . ' [' . $formula . ']: ' . $spreadsheet->getActiveSheet()->getCell($col . $row)->getCalculatedValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,10 @@ Calculation::getInstance($spreadsheet)->cyclicFormulaCount = 15;
|
|||
$helper->log('Calculated data');
|
||||
for ($row = 1; $row <= 2; ++$row) {
|
||||
for ($col = 'A'; $col != 'C'; ++$col) {
|
||||
if ((($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue()) !== null) &&
|
||||
($formula[0] == '=')) {
|
||||
if (
|
||||
(($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue()) !== null) &&
|
||||
($formula[0] == '=')
|
||||
) {
|
||||
$helper->log('Value of ' . $col . $row . ' [' . $formula . ']: ' . $spreadsheet->getActiveSheet()->getCell($col . $row)->getCalculatedValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Html;
|
||||
|
||||
require __DIR__ . '/../Header.php';
|
||||
$spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
|
||||
|
||||
$filename = $helper->getFilename(__FILE__, 'html');
|
||||
$writer = new Html($spreadsheet);
|
||||
|
||||
function changeGridlines(string $html): string
|
||||
{
|
||||
return str_replace('{border: 1px solid black;}', '{border: 2px dashed red;}', $html);
|
||||
}
|
||||
|
||||
$callStartTime = microtime(true);
|
||||
$writer->setEmbedImages(true);
|
||||
$writer->setEditHtmlCallback('changeGridlines');
|
||||
$writer->save($filename);
|
||||
$helper->logWrite($writer, $filename, $callStartTime);
|
|
@ -4,7 +4,7 @@ use PhpOffice\PhpSpreadsheet\IOFactory;
|
|||
|
||||
require __DIR__ . '/../Header.php';
|
||||
|
||||
$filename = __DIR__ . '/../templates/Excel2003XMLTest.xml';
|
||||
$filename = __DIR__ . '/../templates/excel2003.xml';
|
||||
$callStartTime = microtime(true);
|
||||
$spreadsheet = IOFactory::load($filename);
|
||||
$helper->logRead('Xml', $filename, $callStartTime);
|
||||
|
|
|
@ -12,10 +12,12 @@ $spreadsheet = $reader->load(__DIR__ . '/../templates/26template.xlsx');
|
|||
// at this point, we could do some manipulations with the template, but we skip this step
|
||||
$helper->write($spreadsheet, __FILE__, ['Xlsx', 'Xls', 'Html']);
|
||||
|
||||
if (\PHP_VERSION_ID < 80000) {
|
||||
// Export to PDF (.pdf)
|
||||
$helper->log('Write to PDF format');
|
||||
IOFactory::registerWriter('Pdf', \PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf::class);
|
||||
$helper->write($spreadsheet, __FILE__, ['Pdf']);
|
||||
}
|
||||
|
||||
// Remove first two rows with field headers before exporting to CSV
|
||||
$helper->log('Removing first two heading rows for CSV export');
|
||||
|
|
|
@ -30,7 +30,7 @@ $html1 = '<font color="#0000ff">
|
|||
while this block uses an <u>underline</u>.
|
||||
</font>
|
||||
</p>
|
||||
<p align="right"><font size="9" color="red">
|
||||
<p align="right"><font size="9" color="red" face="Times New Roman, serif">
|
||||
I want to eat <ins><del>healthy food</del> <strong>pizza</strong></ins>.
|
||||
</font>
|
||||
';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
|
||||
require __DIR__ . '/../Header.php';
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\NamedRange;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Adjust the path as required to reference the PHPSpreadsheet Bootstrap file
|
||||
require_once __DIR__ . '/../Bootstrap.php';
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
// Set up some basic data for a timesheet
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Charge Rate/hour:')
|
||||
->setCellValue('B1', '7.50')
|
||||
->setCellValue('A3', 'Date')
|
||||
->setCellValue('B3', 'Hours')
|
||||
->setCellValue('C3', 'Charge');
|
||||
|
||||
// Define named range using an absolute cell reference
|
||||
$spreadsheet->addNamedRange(new NamedRange('CHARGE_RATE', $worksheet, '=$B$1'));
|
||||
|
||||
$workHours = [
|
||||
'2020-0-06' => 7.5,
|
||||
'2020-0-07' => 7.25,
|
||||
'2020-0-08' => 6.5,
|
||||
'2020-0-09' => 7.0,
|
||||
'2020-0-10' => 5.5,
|
||||
];
|
||||
|
||||
// Populate the Timesheet
|
||||
$startRow = 4;
|
||||
$row = $startRow;
|
||||
foreach ($workHours as $date => $hours) {
|
||||
$worksheet
|
||||
->setCellValue("A{$row}", $date)
|
||||
->setCellValue("B{$row}", $hours)
|
||||
->setCellValue("C{$row}", "=B{$row}*CHARGE_RATE");
|
||||
++$row;
|
||||
}
|
||||
$endRow = $row - 1;
|
||||
|
||||
++$row;
|
||||
$worksheet
|
||||
->setCellValue("B{$row}", "=SUM(B{$startRow}:B{$endRow})")
|
||||
->setCellValue("C{$row}", "=SUM(C{$startRow}:C{$endRow})");
|
||||
|
||||
echo sprintf(
|
||||
'Worked %.2f hours at a rate of %.2f - Charge to the client is %.2f',
|
||||
$worksheet->getCell("B{$row}")->getCalculatedValue(),
|
||||
$worksheet->getCell('B1')->getValue(),
|
||||
$worksheet->getCell("C{$row}")->getCalculatedValue()
|
||||
), PHP_EOL;
|
||||
|
||||
$outputFileName = 'AbsoluteNamedRange.xlsx';
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save($outputFileName);
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\NamedFormula;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Adjust the path as required to reference the PHPSpreadsheet Bootstrap file
|
||||
require_once __DIR__ . '/../Bootstrap.php';
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
$data2019 = [
|
||||
[151600, 21600],
|
||||
[160320, 30320],
|
||||
[243500, 73500],
|
||||
[113450, 13450],
|
||||
[143200, 23200],
|
||||
[134000, 14000],
|
||||
[89400, -10600],
|
||||
[184500, 24500],
|
||||
[100800, 800],
|
||||
[241850, 5150],
|
||||
[142425, 12425],
|
||||
[243400, 43400],
|
||||
];
|
||||
|
||||
$data2020 = [
|
||||
[183250, 33250],
|
||||
[210350, 40350],
|
||||
[298650, 48650],
|
||||
[140550, 20550],
|
||||
[183145, 33145],
|
||||
[172355, 22355],
|
||||
];
|
||||
|
||||
$worksheet = $spreadsheet->setActiveSheetIndex(0);
|
||||
setYearlyData($worksheet, '2019', $data2019);
|
||||
$worksheet = $spreadsheet->addSheet(new Worksheet($spreadsheet));
|
||||
setYearlyData($worksheet, '2020', $data2020);
|
||||
$worksheet = $spreadsheet->addSheet(new Worksheet($spreadsheet));
|
||||
setYearlyData($worksheet, '2020', [], 'GROWTH');
|
||||
|
||||
function setYearlyData(Worksheet $worksheet, string $year, $yearlyData, ?string $title = null): void
|
||||
{
|
||||
// Set up some basic data
|
||||
$worksheetTitle = $title ?: $year;
|
||||
$worksheet
|
||||
->setTitle($worksheetTitle)
|
||||
->setCellValue('A1', 'Month')
|
||||
->setCellValue('B1', $worksheetTitle === 'GROWTH' ? 'Growth' : 'Sales')
|
||||
->setCellValue('C1', $worksheetTitle === 'GROWTH' ? 'Profit Growth' : 'Margin')
|
||||
->setCellValue('A2', Date::stringToExcel("{$year}-01-01"));
|
||||
for ($row = 3; $row <= 13; ++$row) {
|
||||
$worksheet->setCellValue("A{$row}", '=NEXT_MONTH');
|
||||
}
|
||||
|
||||
if (!empty($yearlyData)) {
|
||||
$worksheet->fromArray($yearlyData, null, 'B2');
|
||||
} else {
|
||||
for ($row = 2; $row <= 13; ++$row) {
|
||||
$worksheet->setCellValue("B{$row}", '=GROWTH');
|
||||
$worksheet->setCellValue("C{$row}", '=PROFIT_GROWTH');
|
||||
}
|
||||
}
|
||||
|
||||
$worksheet->getStyle('A1:C1')
|
||||
->getFont()->setBold(true);
|
||||
$worksheet->getStyle('A2:A13')
|
||||
->getNumberFormat()
|
||||
->setFormatCode('mmmm');
|
||||
$worksheet->getStyle('B2:C13')
|
||||
->getNumberFormat()
|
||||
->setFormatCode($worksheetTitle === 'GROWTH' ? '0.00%' : '_-€* #,##0_-');
|
||||
}
|
||||
|
||||
// Add some Named Formulae
|
||||
// The first to store our tax rate
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('NEXT_MONTH', $worksheet, '=EDATE(OFFSET($A1,-1,0),1)'));
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('GROWTH', $worksheet, "=IF('2020'!\$B1=\"\",\"-\",(('2020'!\$B1/'2019'!\$B1)-1))"));
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('PROFIT_GROWTH', $worksheet, "=IF('2020'!\$C1=\"\",\"-\",(('2020'!\$C1/'2019'!\$C1)-1))"));
|
||||
|
||||
for ($row = 2; $row <= 7; ++$row) {
|
||||
$month = $worksheet->getCell("A{$row}")->getFormattedValue();
|
||||
$growth = $worksheet->getCell("B{$row}")->getFormattedValue();
|
||||
$profitGrowth = $worksheet->getCell("C{$row}")->getFormattedValue();
|
||||
|
||||
echo "Growth for {$month} is {$growth}, with a Profit Growth of {$profitGrowth}", PHP_EOL;
|
||||
}
|
||||
|
||||
$outputFileName = 'CrossWorksheetNamedFormula.xlsx';
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save($outputFileName);
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\NamedFormula;
|
||||
use PhpOffice\PhpSpreadsheet\NamedRange;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Adjust the path as required to reference the PHPSpreadsheet Bootstrap file
|
||||
require_once __DIR__ . '/../Bootstrap.php';
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
// Set up some basic data for a timesheet
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Charge Rate/hour:')
|
||||
->setCellValue('B1', '7.50')
|
||||
->setCellValue('A3', 'Date')
|
||||
->setCellValue('B3', 'Hours')
|
||||
->setCellValue('C3', 'Charge');
|
||||
|
||||
// Define named ranges
|
||||
// CHARGE_RATE is an absolute cell reference that always points to cell B1
|
||||
$spreadsheet->addNamedRange(new NamedRange('CHARGE_RATE', $worksheet, '=$B$1'));
|
||||
// HOURS_PER_DAY is a relative cell reference that always points to column B, but to a cell in the row where it is used
|
||||
$spreadsheet->addNamedRange(new NamedRange('HOURS_PER_DAY', $worksheet, '=$B1'));
|
||||
// Set up the formula for calculating the daily charge
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('DAILY_CHARGE', null, '=HOURS_PER_DAY*CHARGE_RATE'));
|
||||
// Set up the formula for calculating the column totals
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('COLUMN_TOTALS', null, '=SUM(COLUMN_DATA_VALUES)'));
|
||||
|
||||
$workHours = [
|
||||
'2020-0-06' => 7.5,
|
||||
'2020-0-07' => 7.25,
|
||||
'2020-0-08' => 6.5,
|
||||
'2020-0-09' => 7.0,
|
||||
'2020-0-10' => 5.5,
|
||||
];
|
||||
|
||||
// Populate the Timesheet
|
||||
$startRow = 4;
|
||||
$row = $startRow;
|
||||
foreach ($workHours as $date => $hours) {
|
||||
$worksheet
|
||||
->setCellValue("A{$row}", $date)
|
||||
->setCellValue("B{$row}", $hours)
|
||||
->setCellValue("C{$row}", '=DAILY_CHARGE');
|
||||
++$row;
|
||||
}
|
||||
$endRow = $row - 1;
|
||||
|
||||
// COLUMN_TOTAL is another relative cell reference that always points to the same range of rows but to cell in the column where it is used
|
||||
$spreadsheet->addNamedRange(new NamedRange('COLUMN_DATA_VALUES', $worksheet, "=A\${$startRow}:A\${$endRow}"));
|
||||
|
||||
++$row;
|
||||
$worksheet
|
||||
->setCellValue("B{$row}", '=COLUMN_TOTALS')
|
||||
->setCellValue("C{$row}", '=COLUMN_TOTALS');
|
||||
|
||||
echo sprintf(
|
||||
'Worked %.2f hours at a rate of %.2f - Charge to the client is %.2f',
|
||||
$worksheet->getCell("B{$row}")->getCalculatedValue(),
|
||||
$worksheet->getCell('B1')->getValue(),
|
||||
$worksheet->getCell("C{$row}")->getCalculatedValue()
|
||||
), PHP_EOL;
|
||||
|
||||
$outputFileName = 'NamedFormulaeAndRanges.xlsx';
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save($outputFileName);
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\NamedRange;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Adjust the path as required to reference the PHPSpreadsheet Bootstrap file
|
||||
require_once __DIR__ . '/../Bootstrap.php';
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
// Set up some basic data for a timesheet
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Charge Rate/hour:')
|
||||
->setCellValue('B1', '7.50')
|
||||
->setCellValue('A3', 'Date')
|
||||
->setCellValue('B3', 'Hours')
|
||||
->setCellValue('C3', 'Charge');
|
||||
|
||||
// Define named ranges
|
||||
// CHARGE_RATE is an absolute cell reference that always points to cell B1
|
||||
$spreadsheet->addNamedRange(new NamedRange('CHARGE_RATE', $worksheet, '=$B$1'));
|
||||
// HOURS_PER_DAY is a relative cell reference that always points to column B, but to a cell in the row where it is used
|
||||
$spreadsheet->addNamedRange(new NamedRange('HOURS_PER_DAY', $worksheet, '=$B1'));
|
||||
|
||||
$workHours = [
|
||||
'2020-0-06' => 7.5,
|
||||
'2020-0-07' => 7.25,
|
||||
'2020-0-08' => 6.5,
|
||||
'2020-0-09' => 7.0,
|
||||
'2020-0-10' => 5.5,
|
||||
];
|
||||
|
||||
// Populate the Timesheet
|
||||
$startRow = 4;
|
||||
$row = $startRow;
|
||||
foreach ($workHours as $date => $hours) {
|
||||
$worksheet
|
||||
->setCellValue("A{$row}", $date)
|
||||
->setCellValue("B{$row}", $hours)
|
||||
->setCellValue("C{$row}", '=HOURS_PER_DAY*CHARGE_RATE');
|
||||
++$row;
|
||||
}
|
||||
$endRow = $row - 1;
|
||||
|
||||
++$row;
|
||||
$worksheet
|
||||
->setCellValue("B{$row}", "=SUM(B{$startRow}:B{$endRow})")
|
||||
->setCellValue("C{$row}", "=SUM(C{$startRow}:C{$endRow})");
|
||||
|
||||
echo sprintf(
|
||||
'Worked %.2f hours at a rate of %.2f - Charge to the client is %.2f',
|
||||
$worksheet->getCell("B{$row}")->getCalculatedValue(),
|
||||
$worksheet->getCell('B1')->getValue(),
|
||||
$worksheet->getCell("C{$row}")->getCalculatedValue()
|
||||
), PHP_EOL;
|
||||
|
||||
$outputFileName = 'RelativeNamedRange.xlsx';
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save($outputFileName);
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\NamedRange;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Adjust the path as required to reference the PHPSpreadsheet Bootstrap file
|
||||
require_once __DIR__ . '/../Bootstrap.php';
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
// Set up some basic data for a timesheet
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Charge Rate/hour:')
|
||||
->setCellValue('B1', '7.50')
|
||||
->setCellValue('A3', 'Date')
|
||||
->setCellValue('B3', 'Hours')
|
||||
->setCellValue('C3', 'Charge');
|
||||
|
||||
// Define named ranges
|
||||
// CHARGE_RATE is an absolute cell reference that always points to cell B1
|
||||
$spreadsheet->addNamedRange(new NamedRange('CHARGE_RATE', $worksheet, '=$B$1'));
|
||||
// HOURS_PER_DAY is a relative cell reference that always points to column B, but to a cell in the row where it is used
|
||||
$spreadsheet->addNamedRange(new NamedRange('HOURS_PER_DAY', $worksheet, '=$B1'));
|
||||
|
||||
$workHours = [
|
||||
'2020-0-06' => 7.5,
|
||||
'2020-0-07' => 7.25,
|
||||
'2020-0-08' => 6.5,
|
||||
'2020-0-09' => 7.0,
|
||||
'2020-0-10' => 5.5,
|
||||
];
|
||||
|
||||
// Populate the Timesheet
|
||||
$startRow = 4;
|
||||
$row = $startRow;
|
||||
foreach ($workHours as $date => $hours) {
|
||||
$worksheet
|
||||
->setCellValue("A{$row}", $date)
|
||||
->setCellValue("B{$row}", $hours)
|
||||
->setCellValue("C{$row}", '=HOURS_PER_DAY*CHARGE_RATE');
|
||||
++$row;
|
||||
}
|
||||
$endRow = $row - 1;
|
||||
|
||||
// COLUMN_TOTAL is another relative cell reference that always points to the same range of rows but to cell in the column where it is used
|
||||
$spreadsheet->addNamedRange(new NamedRange('COLUMN_DATA_VALUES', $worksheet, "=A\${$startRow}:A\${$endRow}"));
|
||||
|
||||
++$row;
|
||||
$worksheet
|
||||
->setCellValue("B{$row}", '=SUM(COLUMN_DATA_VALUES)')
|
||||
->setCellValue("C{$row}", '=SUM(COLUMN_DATA_VALUES)');
|
||||
|
||||
echo sprintf(
|
||||
'Worked %.2f hours at a rate of %.2f - Charge to the client is %.2f',
|
||||
$worksheet->getCell("B{$row}")->getCalculatedValue(),
|
||||
$worksheet->getCell('B1')->getValue(),
|
||||
$worksheet->getCell("C{$row}")->getCalculatedValue()
|
||||
), PHP_EOL;
|
||||
|
||||
$outputFileName = 'RelativeNamedRange2.xlsx';
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save($outputFileName);
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\NamedFormula;
|
||||
use PhpOffice\PhpSpreadsheet\NamedRange;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Adjust the path as required to reference the PHPSpreadsheet Bootstrap file
|
||||
require_once __DIR__ . '/../Bootstrap.php';
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
// Set up some basic data for a timesheet
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Charge Rate/hour:')
|
||||
->setCellValue('B1', '7.50')
|
||||
->setCellValue('A3', 'Date')
|
||||
->setCellValue('B3', 'Hours')
|
||||
->setCellValue('C3', 'Charge');
|
||||
|
||||
// Define named ranges
|
||||
// CHARGE_RATE is an absolute cell reference that always points to cell B1
|
||||
$spreadsheet->addNamedRange(new NamedRange('CHARGE_RATE', $worksheet, '=$B$1'));
|
||||
// HOURS_PER_DAY is a relative cell reference that always points to column B, but to a cell in the row where it is used
|
||||
$spreadsheet->addNamedRange(new NamedRange('HOURS_PER_DAY', $worksheet, '=$B1'));
|
||||
|
||||
$workHours = [
|
||||
'2020-0-06' => 7.5,
|
||||
'2020-0-07' => 7.25,
|
||||
'2020-0-08' => 6.5,
|
||||
'2020-0-09' => 7.0,
|
||||
'2020-0-10' => 5.5,
|
||||
];
|
||||
|
||||
// Populate the Timesheet
|
||||
$startRow = 4;
|
||||
$row = $startRow;
|
||||
foreach ($workHours as $date => $hours) {
|
||||
$worksheet
|
||||
->setCellValue("A{$row}", $date)
|
||||
->setCellValue("B{$row}", $hours)
|
||||
->setCellValue("C{$row}", '=HOURS_PER_DAY*CHARGE_RATE');
|
||||
++$row;
|
||||
}
|
||||
$endRow = $row - 1;
|
||||
|
||||
// COLUMN_TOTAL is another relative cell reference that always points to the same range of rows but to cell in the column where it is used
|
||||
// To avoid including the current row,or having to hard-code the range itself (as we did in the previous example)
|
||||
// we wrap it in a named formula using the OFFSET() function
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('COLUMN_DATA_VALUES', $worksheet, '=OFFSET(A$4:A1, -1, 0)'));
|
||||
|
||||
++$row;
|
||||
$worksheet
|
||||
->setCellValue("B{$row}", '=SUM(COLUMN_DATA_VALUES)')
|
||||
->setCellValue("C{$row}", '=SUM(COLUMN_DATA_VALUES)');
|
||||
|
||||
echo sprintf(
|
||||
'Worked %.2f hours at a rate of %.2f - Charge to the client is %.2f',
|
||||
$worksheet->getCell("B{$row}")->getCalculatedValue(),
|
||||
$worksheet->getCell('B1')->getValue(),
|
||||
$worksheet->getCell("C{$row}")->getCalculatedValue()
|
||||
), PHP_EOL;
|
||||
|
||||
$outputFileName = 'RelativeNamedRangeAsFunction.xlsx';
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save($outputFileName);
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\NamedRange;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Adjust the path as required to reference the PHPSpreadsheet Bootstrap file
|
||||
require_once __DIR__ . '/../Bootstrap.php';
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->setActiveSheetIndex(0);
|
||||
$worksheet->setTitle('Base Data');
|
||||
|
||||
// Set up some basic data for a timesheet
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Charge Rate/hour:')
|
||||
->setCellValue('B1', '7.50');
|
||||
|
||||
// Define a global named range on the first worksheet for our Charge Rate
|
||||
// CHARGE_RATE is an absolute cell reference that always points to cell B1
|
||||
// Because it is defined globally, it will still be usable from any worksheet in the spreadsheet
|
||||
$spreadsheet->addNamedRange(new NamedRange('CHARGE_RATE', $worksheet, '=$B$1'));
|
||||
|
||||
// Create a second worksheet as our client timesheet
|
||||
$worksheet = $spreadsheet->addSheet(new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet($spreadsheet, 'Client Timesheet'));
|
||||
|
||||
// Define named ranges
|
||||
// HOURS_PER_DAY is a relative cell reference that always points to column B, but to a cell in the row where it is used
|
||||
$spreadsheet->addNamedRange(new NamedRange('HOURS_PER_DAY', $worksheet, '=$B1'));
|
||||
|
||||
// Set up some basic data for a timesheet
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Date')
|
||||
->setCellValue('B1', 'Hours')
|
||||
->setCellValue('C1', 'Charge');
|
||||
|
||||
$workHours = [
|
||||
'2020-0-06' => 7.5,
|
||||
'2020-0-07' => 7.25,
|
||||
'2020-0-08' => 6.5,
|
||||
'2020-0-09' => 7.0,
|
||||
'2020-0-10' => 5.5,
|
||||
];
|
||||
|
||||
// Populate the Timesheet
|
||||
$startRow = 2;
|
||||
$row = $startRow;
|
||||
foreach ($workHours as $date => $hours) {
|
||||
$worksheet
|
||||
->setCellValue("A{$row}", $date)
|
||||
->setCellValue("B{$row}", $hours)
|
||||
->setCellValue("C{$row}", '=HOURS_PER_DAY*CHARGE_RATE');
|
||||
++$row;
|
||||
}
|
||||
$endRow = $row - 1;
|
||||
|
||||
// COLUMN_TOTAL is another relative cell reference that always points to the same range of rows but to cell in the column where it is used
|
||||
$spreadsheet->addNamedRange(new NamedRange('COLUMN_DATA_VALUES', $worksheet, "=A\${$startRow}:A\${$endRow}"));
|
||||
|
||||
++$row;
|
||||
$worksheet
|
||||
->setCellValue("B{$row}", '=SUM(COLUMN_DATA_VALUES)')
|
||||
->setCellValue("C{$row}", '=SUM(COLUMN_DATA_VALUES)');
|
||||
|
||||
echo sprintf(
|
||||
'Worked %.2f hours at a rate of %s - Charge to the client is %.2f',
|
||||
$worksheet->getCell("B{$row}")->getCalculatedValue(),
|
||||
$chargeRateCellValue = $spreadsheet
|
||||
->getSheetByName($spreadsheet->getNamedRange('CHARGE_RATE')->getWorksheet()->getTitle())
|
||||
->getCell($spreadsheet->getNamedRange('CHARGE_RATE')->getCellsInRange()[0])->getValue(),
|
||||
$worksheet->getCell("C{$row}")->getCalculatedValue()
|
||||
), PHP_EOL;
|
||||
|
||||
$outputFileName = 'ScopedNamedRange.xlsx';
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save($outputFileName);
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\NamedRange;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Adjust the path as required to reference the PHPSpreadsheet Bootstrap file
|
||||
require_once __DIR__ . '/../Bootstrap.php';
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
$clients = [
|
||||
'Client #1 - Full Hourly Rate' => [
|
||||
'2020-0-06' => 2.5,
|
||||
'2020-0-07' => 2.25,
|
||||
'2020-0-08' => 6.0,
|
||||
'2020-0-09' => 3.0,
|
||||
'2020-0-10' => 2.25,
|
||||
],
|
||||
'Client #2 - Full Hourly Rate' => [
|
||||
'2020-0-06' => 1.5,
|
||||
'2020-0-07' => 2.75,
|
||||
'2020-0-08' => 0.0,
|
||||
'2020-0-09' => 4.5,
|
||||
'2020-0-10' => 3.5,
|
||||
],
|
||||
'Client #3 - Reduced Hourly Rate' => [
|
||||
'2020-0-06' => 3.5,
|
||||
'2020-0-07' => 2.5,
|
||||
'2020-0-08' => 1.5,
|
||||
'2020-0-09' => 0.0,
|
||||
'2020-0-10' => 1.25,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($clients as $clientName => $workHours) {
|
||||
$worksheet = $spreadsheet->addSheet(new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet($spreadsheet, $clientName));
|
||||
|
||||
// Set up some basic data for a timesheet
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Charge Rate/hour:')
|
||||
->setCellValue('B1', '7.50')
|
||||
->setCellValue('A3', 'Date')
|
||||
->setCellValue('B3', 'Hours')
|
||||
->setCellValue('C3', 'Charge');
|
||||
|
||||
// Define named ranges
|
||||
// CHARGE_RATE is an absolute cell reference that always points to cell B1
|
||||
$spreadsheet->addNamedRange(new NamedRange('CHARGE_RATE', $worksheet, '=$B$1', true));
|
||||
// HOURS_PER_DAY is a relative cell reference that always points to column B, but to a cell in the row where it is used
|
||||
$spreadsheet->addNamedRange(new NamedRange('HOURS_PER_DAY', $worksheet, '=$B1', true));
|
||||
|
||||
// Populate the Timesheet
|
||||
$startRow = 4;
|
||||
$row = $startRow;
|
||||
foreach ($workHours as $date => $hours) {
|
||||
$worksheet
|
||||
->setCellValue("A{$row}", $date)
|
||||
->setCellValue("B{$row}", $hours)
|
||||
->setCellValue("C{$row}", '=HOURS_PER_DAY*CHARGE_RATE');
|
||||
++$row;
|
||||
}
|
||||
$endRow = $row - 1;
|
||||
|
||||
// COLUMN_TOTAL is another relative cell reference that always points to the same range of rows but to cell in the column where it is used
|
||||
$spreadsheet->addNamedRange(new NamedRange('COLUMN_TOTAL', $worksheet, "=A\${$startRow}:A\${$endRow}", true));
|
||||
|
||||
++$row;
|
||||
$worksheet
|
||||
->setCellValue("B{$row}", '=SUM(COLUMN_TOTAL)')
|
||||
->setCellValue("C{$row}", '=SUM(COLUMN_TOTAL)');
|
||||
}
|
||||
$spreadsheet->removeSheetByIndex(0);
|
||||
|
||||
// Set the reduced charge rate for our special client
|
||||
$worksheet
|
||||
->setCellValue('B1', 4.5);
|
||||
|
||||
foreach ($spreadsheet->getAllSheets() as $worksheet) {
|
||||
echo sprintf(
|
||||
'Worked %.2f hours for "%s" at a rate of %.2f - Charge to the client is %.2f',
|
||||
$worksheet->getCell("B{$row}")->getCalculatedValue(),
|
||||
$worksheet->getTitle(),
|
||||
$worksheet->getCell('B1')->getValue(),
|
||||
$worksheet->getCell("C{$row}")->getCalculatedValue()
|
||||
), PHP_EOL;
|
||||
}
|
||||
$worksheet = $spreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
$outputFileName = 'ScopedNamedRange2.xlsx';
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save($outputFileName);
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\NamedFormula;
|
||||
use PhpOffice\PhpSpreadsheet\NamedRange;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Adjust the path as required to reference the PHPSpreadsheet Bootstrap file
|
||||
require_once __DIR__ . '/../Bootstrap.php';
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
// Add some Named Formulae
|
||||
// The first to store our tax rate
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('TAX_RATE', $worksheet, '=19%'));
|
||||
// The second to calculate the Tax on a Price value (Note that `PRICE` is defined later as a Named Range)
|
||||
$spreadsheet->addNamedFormula(new NamedFormula('TAX', $worksheet, '=PRICE*TAX_RATE'));
|
||||
|
||||
// Set up some basic data
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Tax Rate:')
|
||||
->setCellValue('B1', '=TAX_RATE')
|
||||
->setCellValue('A3', 'Net Price:')
|
||||
->setCellValue('B3', 19.99)
|
||||
->setCellValue('A4', 'Tax:')
|
||||
->setCellValue('A5', 'Price including Tax:');
|
||||
|
||||
// Define a named range that we can use in our formulae
|
||||
$spreadsheet->addNamedRange(new NamedRange('PRICE', $worksheet, '=$B$3'));
|
||||
|
||||
// Reference the defined formulae in worksheet formulae
|
||||
$worksheet
|
||||
->setCellValue('B4', '=TAX')
|
||||
->setCellValue('B5', '=PRICE+TAX');
|
||||
|
||||
echo sprintf(
|
||||
'With a Tax Rate of %.2f and a net price of %.2f, Tax is %.2f and the gross price is %.2f',
|
||||
$worksheet->getCell('B1')->getCalculatedValue(),
|
||||
$worksheet->getCell('B3')->getValue(),
|
||||
$worksheet->getCell('B4')->getCalculatedValue(),
|
||||
$worksheet->getCell('B5')->getCalculatedValue()
|
||||
), PHP_EOL;
|
||||
|
||||
$outputFileName = 'SimpleNamedFormula.xlsx';
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save($outputFileName);
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\NamedRange;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Adjust the path as required to reference the PHPSpreadsheet Bootstrap file
|
||||
require_once __DIR__ . '/../Bootstrap.php';
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
// Set up some basic data
|
||||
$worksheet
|
||||
->setCellValue('A1', 'Tax Rate:')
|
||||
->setCellValue('B1', '=19%')
|
||||
->setCellValue('A3', 'Net Price:')
|
||||
->setCellValue('B3', 12.99)
|
||||
->setCellValue('A4', 'Tax:')
|
||||
->setCellValue('A5', 'Price including Tax:');
|
||||
|
||||
// Define named ranges
|
||||
$spreadsheet->addNamedRange(new NamedRange('TAX_RATE', $worksheet, '=$B$1'));
|
||||
$spreadsheet->addNamedRange(new NamedRange('PRICE', $worksheet, '=$B$3'));
|
||||
|
||||
// Reference that defined name in a formula
|
||||
$worksheet
|
||||
->setCellValue('B4', '=PRICE*TAX_RATE')
|
||||
->setCellValue('B5', '=PRICE*(1+TAX_RATE)');
|
||||
|
||||
echo sprintf(
|
||||
'With a Tax Rate of %.2f and a net price of %.2f, Tax is %.2f and the gross price is %.2f',
|
||||
$worksheet->getCell('B1')->getCalculatedValue(),
|
||||
$worksheet->getCell('B3')->getValue(),
|
||||
$worksheet->getCell('B4')->getCalculatedValue(),
|
||||
$worksheet->getCell('B5')->getCalculatedValue()
|
||||
), PHP_EOL;
|
||||
|
||||
$outputFileName = 'SimpleNamedRange.xlsx';
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save($outputFileName);
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf;
|
||||
|
||||
require __DIR__ . '/../Header.php';
|
||||
$spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
|
||||
|
||||
$helper->log('Hide grid lines');
|
||||
$spreadsheet->getActiveSheet()->setShowGridLines(false);
|
||||
|
||||
$helper->log('Set orientation to landscape');
|
||||
$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE);
|
||||
$spreadsheet->setActiveSheetIndex(0)->setPrintGridlines(true);
|
||||
|
||||
function changeGridlines(string $html): string
|
||||
{
|
||||
return str_replace('{border: 1px solid black;}', '{border: 2px dashed red;}', $html);
|
||||
}
|
||||
|
||||
$helper->log('Write to Mpdf');
|
||||
$writer = new Mpdf($spreadsheet);
|
||||
$filename = $helper->getFileName('21a_Pdf_mpdf.xlsx', 'pdf');
|
||||
$writer->setEditHtmlCallback('changeGridlines');
|
||||
$writer->save($filename);
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Tcpdf;
|
||||
|
||||
function replaceBody(string $html): string
|
||||
{
|
||||
$lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
|
||||
$bodystring = '~<body>.*</body>~ms';
|
||||
$bodyrepl = <<<EOF
|
||||
<body>
|
||||
<h1>Serif</h1>
|
||||
<p style='font-family: serif; font-size: 12pt;'>$lorem</p>
|
||||
<h1>Sans-Serif</h1>
|
||||
<p style='font-family: sans-serif; font-size: 12pt;'>$lorem</p>
|
||||
<h1>Monospace</h1>
|
||||
<p style='font-family: monospace; font-size: 12pt;'>$lorem</p>
|
||||
</body>
|
||||
EOF;
|
||||
|
||||
return preg_replace($bodystring, $bodyrepl, $html);
|
||||
}
|
||||
|
||||
require __DIR__ . '/../Header.php';
|
||||
$spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
|
||||
|
||||
$helper->log('Hide grid lines');
|
||||
$spreadsheet->getActiveSheet()->setShowGridLines(false);
|
||||
|
||||
$helper->log('Set orientation to landscape');
|
||||
$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE);
|
||||
|
||||
if (\PHP_VERSION_ID < 80000) {
|
||||
$helper->log('Write to Dompdf');
|
||||
$writer = new Dompdf($spreadsheet);
|
||||
$filename = $helper->getFileName('21b_Pdf_dompdf.xlsx', 'pdf');
|
||||
$writer->setEditHtmlCallback('replaceBody');
|
||||
$writer->save($filename);
|
||||
}
|
||||
|
||||
$helper->log('Write to Mpdf');
|
||||
$writer = new Mpdf($spreadsheet);
|
||||
$filename = $helper->getFileName('21b_Pdf_mpdf.xlsx', 'pdf');
|
||||
$writer->setEditHtmlCallback('replaceBody');
|
||||
$writer->save($filename);
|
||||
|
||||
if (\PHP_VERSION_ID < 80000) {
|
||||
$helper->log('Write to Tcpdf');
|
||||
$writer = new Tcpdf($spreadsheet);
|
||||
$filename = $helper->getFileName('21b_Pdf_tcpdf.xlsx', 'pdf');
|
||||
$writer->setEditHtmlCallback('replaceBody');
|
||||
$writer->save($filename);
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
@ -52,7 +52,7 @@ P;EArial;M200
|
|||
P;EArial;M200;SI
|
||||
P;EArial;M200;SBI
|
||||
P;EArial;M200;SBU
|
||||
P;EArial;M200;SBIU
|
||||
P;EArial;M220;SBIU
|
||||
P;EArial;M200
|
||||
P;EArial;M200;SI
|
||||
F;P0;DG0G8;M255
|
||||
|
@ -115,6 +115,7 @@ F;P19;FG0G;X4
|
|||
C;Y7;X2;K2.34
|
||||
C;X3;KFALSE
|
||||
C;Y8;X2;K3.45
|
||||
C;Y9;X2;K2.34;EMEDIAN(R[-3]C:R[-1]C)
|
||||
F;Y9;X1
|
||||
F;X2
|
||||
F;X3
|
||||
|
|
|
@ -20,6 +20,19 @@
|
|||
<ProtectStructure>False</ProtectStructure>
|
||||
<ProtectWindows>False</ProtectWindows>
|
||||
</ExcelWorkbook>
|
||||
<Styles>
|
||||
<Style ss:ID="ce9">
|
||||
<Alignment ss:Vertical="Bottom" ss:Rotate="0"/>
|
||||
<Borders/>
|
||||
<Font ss:Color="#000000" ss:FontName="Arial1" ss:Size="11"/>
|
||||
<NumberFormat ss:Format="Short Date"/>
|
||||
</Style>
|
||||
<Style ss:ID="ce32">
|
||||
<Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1" ss:Rotate="0"/>
|
||||
<Borders/>
|
||||
<Font ss:Color="#000000" ss:FontName="Calibri" ss:Size="11"/>
|
||||
</Style>
|
||||
</Styles>
|
||||
<ss:Worksheet ss:Name="Sample Data">
|
||||
<Table>
|
||||
<Column ss:Width="96.4913"/>
|
||||
|
@ -28,7 +41,7 @@
|
|||
<Column ss:Span="6" ss:Width="48.3874"/>
|
||||
<Column ss:Index="12" ss:Width="50.2583"/>
|
||||
<Column ss:Span="1011" ss:Width="48.3874"/>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="14.9953">
|
||||
<Row ss:Index="8" ss:AutoFitHeight="0" ss:Height="14.9953">
|
||||
<Cell>
|
||||
<ss:Data xmlns="http://www.w3.org/TR/REC-html40" ss:Type="String">Test String 1</ss:Data>
|
||||
<Comment>
|
||||
|
@ -38,7 +51,16 @@
|
|||
</Comment>
|
||||
</Cell>
|
||||
<Cell>
|
||||
<Data ss:Type="Number">1</Data>
|
||||
<Data ss:StyleID="ce32" ss:Type="Number">1</Data>
|
||||
</Cell>
|
||||
<Cell ss:Formula="of:=12/1">
|
||||
<Data ss:Type="Number">12</Data>
|
||||
</Cell>
|
||||
<Cell ss:Formula="of:=[.C8]-[.B8]">
|
||||
<Data ss:Type="Number">11</Data>
|
||||
</Cell>
|
||||
<Cell ss:StyleID="ce9">
|
||||
<Data ss:Type="DateTime">1960-12-19T00:00:00.000</Data>
|
||||
</Cell>
|
||||
</Row>
|
||||
</Table>
|
|
@ -0,0 +1,944 @@
|
|||
<?xml version="1.0"?>
|
||||
<?mso-application progid="Excel.Sheet"?>
|
||||
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
|
||||
xmlns:o="urn:schemas-microsoft-com:office:office"
|
||||
xmlns:x="urn:schemas-microsoft-com:office:excel"
|
||||
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
|
||||
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40">
|
||||
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
|
||||
<Title>Xml2003 Workbook</Title>
|
||||
<Subject>Test Gnumeric Workbook Subject</Subject>
|
||||
<Author>Mark Baker</Author>
|
||||
<Keywords>PHPExcel Xml Reader Test Keywords</Keywords>
|
||||
<Description>Some comments about the PHPExcel Gnumeric Reader</Description>
|
||||
<LastAuthor>Owen Leibman</LastAuthor>
|
||||
<Created>2010-09-02T20:48:39Z</Created>
|
||||
<LastSaved>2010-09-02T20:48:39Z</LastSaved>
|
||||
<Category>PHPExcel Xml Reader Test Category</Category>
|
||||
<Manager>Maarten Balliauw</Manager>
|
||||
<Company>PHPExcel</Company>
|
||||
<HyperlinkBase>https://github.com/PHPOffice/PhpSpreadsheet</HyperlinkBase>
|
||||
<Version>16.00</Version>
|
||||
</DocumentProperties>
|
||||
<CustomDocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
|
||||
<my_API_Token dt:dt="string">AbCd1234</my_API_Token>
|
||||
<my_API_Token_Expiry dt:dt="dateTime.tz">2019-01-31T07:00:00Z</my_API_Token_Expiry>
|
||||
<my_API_Boolean dt:dt="boolean">1</my_API_Boolean>
|
||||
<my_API_Int dt:dt="string">3</my_API_Int>
|
||||
<myאInt dt:dt="string">2</myאInt>
|
||||
<my_API_Float dt:dt="float">3.14159</my_API_Float>
|
||||
</CustomDocumentProperties>
|
||||
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
|
||||
<AllowPNG/>
|
||||
</OfficeDocumentSettings>
|
||||
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
|
||||
<WindowHeight>8964</WindowHeight>
|
||||
<WindowWidth>23040</WindowWidth>
|
||||
<WindowTopX>32767</WindowTopX>
|
||||
<WindowTopY>32767</WindowTopY>
|
||||
<ProtectStructure>False</ProtectStructure>
|
||||
<ProtectWindows>False</ProtectWindows>
|
||||
</ExcelWorkbook>
|
||||
<Styles>
|
||||
<Style ss:ID="Default" ss:Name="Normal">
|
||||
<Alignment ss:Vertical="Bottom"/>
|
||||
<Borders/>
|
||||
<Font ss:FontName="Calibri" ss:Size="11" ss:Color="#000000"/>
|
||||
<Interior/>
|
||||
<NumberFormat/>
|
||||
<Protection/>
|
||||
</Style>
|
||||
<Style ss:ID="s62" ss:Name="Hyperlink">
|
||||
<Font ss:FontName="Calibri" ss:Size="11" ss:Color="#0066CC"
|
||||
ss:Underline="Single"/>
|
||||
</Style>
|
||||
<Style ss:ID="m1867777004784">
|
||||
<Borders>
|
||||
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="3"
|
||||
ss:Color="#00B050"/>
|
||||
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="3"
|
||||
ss:Color="#0070C0"/>
|
||||
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="3"
|
||||
ss:Color="#FFFF00"/>
|
||||
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="3"
|
||||
ss:Color="#FF0000"/>
|
||||
</Borders>
|
||||
<Font ss:FontName="Arial1" ss:Size="11" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s63">
|
||||
<Font ss:FontName="Arial1" ss:Size="11" ss:Color="#FF0000" ss:Bold="1"/>
|
||||
</Style>
|
||||
<Style ss:ID="s64">
|
||||
<Font ss:FontName="Arial1" ss:Size="11" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s65">
|
||||
<Font ss:FontName="Arial1" ss:Size="11" ss:Color="#000000" ss:Bold="1"
|
||||
ss:Italic="1"/>
|
||||
</Style>
|
||||
<Style ss:ID="s66">
|
||||
<Font ss:FontName="Arial1" ss:Size="11" ss:Color="#000000" ss:Bold="1"/>
|
||||
</Style>
|
||||
<Style ss:ID="s68">
|
||||
<Font ss:FontName="Arial1" ss:Size="11" ss:Color="#000000" ss:Underline="Single"/>
|
||||
</Style>
|
||||
<Style ss:ID="s69">
|
||||
<Interior ss:Color="#FF0000" ss:Pattern="Solid"/>
|
||||
</Style>
|
||||
<Style ss:ID="s70">
|
||||
<Font ss:FontName="Calibri" ss:Size="11" ss:Color="#FF0000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s72">
|
||||
<Font ss:FontName="Arial1" ss:Size="11" ss:Color="#000000" ss:Italic="1"/>
|
||||
</Style>
|
||||
<Style ss:ID="s73">
|
||||
<Interior ss:Color="#FF9900" ss:Pattern="Solid"/>
|
||||
</Style>
|
||||
<Style ss:ID="s74">
|
||||
<Font ss:FontName="Calibri" ss:Size="11" ss:Color="#FF6600"/>
|
||||
</Style>
|
||||
<Style ss:ID="s75">
|
||||
<Borders>
|
||||
<Border ss:Position="Bottom" ss:LineStyle="DashDotDot" ss:Weight="1"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
</Style>
|
||||
<Style ss:ID="s76">
|
||||
<Interior ss:Color="#FFFF00" ss:Pattern="Solid"/>
|
||||
</Style>
|
||||
<Style ss:ID="s77">
|
||||
<Font ss:FontName="Calibri" ss:Size="11" ss:Color="#FFFF00"/>
|
||||
</Style>
|
||||
<Style ss:ID="s78">
|
||||
<Borders>
|
||||
<Border ss:Position="Bottom" ss:LineStyle="DashDot" ss:Weight="1"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
</Style>
|
||||
<Style ss:ID="s79">
|
||||
<Font ss:FontName="Calibri" ss:Size="11" ss:Color="#000000"
|
||||
ss:Underline="Single"/>
|
||||
</Style>
|
||||
<Style ss:ID="s80">
|
||||
<Font ss:FontName="Arial1" ss:Size="11" ss:Color="#000000"/>
|
||||
<NumberFormat ss:Format="dd/mm/yyyy"/>
|
||||
</Style>
|
||||
<Style ss:ID="s81">
|
||||
<Interior ss:Color="#008000" ss:Pattern="Solid"/>
|
||||
</Style>
|
||||
<Style ss:ID="s82">
|
||||
<Font ss:FontName="Calibri" ss:Size="11" ss:Color="#008000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s83">
|
||||
<Borders>
|
||||
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
</Style>
|
||||
<Style ss:ID="s84">
|
||||
<Font ss:FontName="Calibri" ss:Size="11" ss:Color="#000000"
|
||||
ss:Underline="Double"/>
|
||||
</Style>
|
||||
<Style ss:ID="s85">
|
||||
<Interior ss:Color="#0000FF" ss:Pattern="Solid"/>
|
||||
</Style>
|
||||
<Style ss:ID="s86">
|
||||
<Font ss:FontName="Calibri" ss:Size="11" ss:Color="#0000FF"/>
|
||||
</Style>
|
||||
<Style ss:ID="s87">
|
||||
<Borders>
|
||||
<Border ss:Position="Bottom" ss:LineStyle="DashDotDot" ss:Weight="2"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
</Style>
|
||||
<Style ss:ID="s88">
|
||||
<Font ss:FontName="Calibri" ss:Size="11" ss:Color="#000000" ss:StrikeThrough="1"/>
|
||||
</Style>
|
||||
<Style ss:ID="s89">
|
||||
<Interior ss:Color="#993366" ss:Pattern="Solid"/>
|
||||
</Style>
|
||||
<Style ss:ID="s90">
|
||||
<Font ss:FontName="Calibri" ss:Size="11" ss:Color="#800080"/>
|
||||
</Style>
|
||||
<Style ss:ID="s91">
|
||||
<Interior ss:Color="#FF99CC" ss:Pattern="Solid"/>
|
||||
</Style>
|
||||
<Style ss:ID="s92">
|
||||
<Font ss:FontName="Calibri" ss:Size="11" ss:Color="#FF00FF"/>
|
||||
</Style>
|
||||
<Style ss:ID="s93">
|
||||
<Borders>
|
||||
<Border ss:Position="Bottom" ss:LineStyle="DashDot" ss:Weight="2"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
</Style>
|
||||
<Style ss:ID="s94">
|
||||
<Borders>
|
||||
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="2"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
<Font ss:FontName="Arial1" ss:Size="11" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s95">
|
||||
<Interior ss:Color="#DDBC7D" ss:Pattern="Solid"/>
|
||||
</Style>
|
||||
<Style ss:ID="s96">
|
||||
<Borders>
|
||||
<Border ss:Position="Bottom" ss:LineStyle="Dash" ss:Weight="2"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
</Style>
|
||||
<Style ss:ID="s97">
|
||||
<Font ss:FontName="Arial1" ss:Size="11" ss:Color="#000000"/>
|
||||
<NumberFormat ss:Format="#\ ?0/??0"/>
|
||||
</Style>
|
||||
<Style ss:ID="s98">
|
||||
<Borders>
|
||||
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
</Style>
|
||||
<Style ss:ID="s99">
|
||||
<Borders>
|
||||
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="2"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
<Font ss:FontName="Arial1" ss:Size="11" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s100">
|
||||
<Borders>
|
||||
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="3"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
</Style>
|
||||
<Style ss:ID="s101">
|
||||
<NumberFormat ss:Format="hh":"mm":"ss"/>
|
||||
</Style>
|
||||
<Style ss:ID="s102">
|
||||
<Borders>
|
||||
<Border ss:Position="Bottom" ss:LineStyle="Double" ss:Weight="3"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
</Style>
|
||||
<Style ss:ID="s103">
|
||||
<Borders>
|
||||
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="2"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
<Font ss:FontName="Arial1" ss:Size="11" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s104">
|
||||
<NumberFormat ss:Format="d/m/yy\ hh":"mm"/>
|
||||
</Style>
|
||||
<Style ss:ID="s105">
|
||||
<Borders>
|
||||
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="2"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
<Font ss:FontName="Arial1" ss:Size="11" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s113">
|
||||
<Borders>
|
||||
<Border ss:Position="DiagonalLeft" ss:LineStyle="Double" ss:Weight="3"
|
||||
ss:Color="#FF0000"/>
|
||||
<Border ss:Position="DiagonalRight" ss:LineStyle="Double" ss:Weight="3"
|
||||
ss:Color="#FF0000"/>
|
||||
</Borders>
|
||||
</Style>
|
||||
<Style ss:ID="s114">
|
||||
<Alignment ss:Vertical="Bottom" ss:WrapText="1"/>
|
||||
</Style>
|
||||
<Style ss:ID="s115">
|
||||
<Alignment ss:Vertical="Bottom" ss:WrapText="1"/>
|
||||
<Borders>
|
||||
<Border ss:Position="DiagonalLeft" ss:LineStyle="Continuous" ss:Weight="1"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
</Style>
|
||||
<Style ss:ID="s116">
|
||||
<Borders>
|
||||
<Border ss:Position="DiagonalRight" ss:LineStyle="Continuous" ss:Weight="1"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
</Style>
|
||||
<Style ss:ID="s118">
|
||||
<Alignment ss:Vertical="Bottom" ss:WrapText="1"/>
|
||||
<Font ss:FontName="Calibri" ss:Size="11" ss:Color="#CCFFCC"/>
|
||||
<Interior ss:Color="#FF0000" ss:Pattern="Gray0625" ss:PatternColor="#FFFF00"/>
|
||||
</Style>
|
||||
<Style ss:ID="s121">
|
||||
<Font ss:FontName="Sans" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s123">
|
||||
<Alignment ss:Vertical="Bottom" ss:Rotate="90"/>
|
||||
<Font ss:FontName="Sans" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s125">
|
||||
<Alignment ss:Vertical="Bottom" ss:Rotate="45"/>
|
||||
<Font ss:FontName="Sans" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s127">
|
||||
<Alignment ss:Vertical="Bottom" ss:Rotate="-90"/>
|
||||
<Font ss:FontName="Sans" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s129">
|
||||
<Alignment ss:Vertical="Bottom" ss:Rotate="-45"/>
|
||||
<Font ss:FontName="Sans" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s130">
|
||||
<Font ss:FontName="Sans" ss:Color="#000000" ss:Underline="Single"/>
|
||||
</Style>
|
||||
<Style ss:ID="s131">
|
||||
<Font ss:FontName="Sans" ss:Color="#000000" ss:VerticalAlign="Subscript"/>
|
||||
</Style>
|
||||
<Style ss:ID="s132">
|
||||
<Font ss:FontName="Sans" ss:Color="#000000" ss:Underline="Double"/>
|
||||
</Style>
|
||||
<Style ss:ID="s133">
|
||||
<Font ss:FontName="Sans" ss:Color="#000000" ss:VerticalAlign="Superscript"/>
|
||||
</Style>
|
||||
<Style ss:ID="s134">
|
||||
<Font ss:FontName="Sans" ss:Color="#000000" ss:Underline="SingleAccounting"/>
|
||||
</Style>
|
||||
<Style ss:ID="s135">
|
||||
<Font ss:FontName="Sans" ss:Color="#000000" ss:Underline="DoubleAccounting"/>
|
||||
</Style>
|
||||
<Style ss:ID="s136">
|
||||
<Alignment ss:Vertical="Bottom" ss:WrapText="1"/>
|
||||
<Font ss:FontName="Sans" ss:Color="#000000"/>
|
||||
</Style>
|
||||
<Style ss:ID="s139">
|
||||
<Font ss:FontName="Sans" ss:Color="#0000FF" ss:Underline="Single"/>
|
||||
</Style>
|
||||
<Style ss:ID="s140">
|
||||
<Font ss:FontName="Sans" ss:Color="#000000"/>
|
||||
<NumberFormat ss:Format="0"/>
|
||||
</Style>
|
||||
<Style ss:ID="s141">
|
||||
<Alignment ss:Vertical="Bottom" ss:WrapText="1"/>
|
||||
<Font ss:FontName="Arial1" ss:Size="12" ss:Color="#000000" ss:Bold="1"/>
|
||||
</Style>
|
||||
<Style ss:ID="s142">
|
||||
<Font ss:FontName="Arial1" ss:Size="11" ss:Color="#000000"/>
|
||||
<NumberFormat ss:Format="0.00;[Red]0.00"/>
|
||||
</Style>
|
||||
<Style ss:ID="s143">
|
||||
<Font ss:FontName="Arial1" ss:Size="11" ss:Color="#000000"/>
|
||||
<NumberFormat ss:Format="dd\-mmm\-yyyy"/>
|
||||
</Style>
|
||||
<Style ss:ID="s144">
|
||||
<Font ss:FontName="Arial1" ss:Size="11" ss:Color="#000000"/>
|
||||
<NumberFormat ss:Format="hh":"mm\ AM/PM"/>
|
||||
</Style>
|
||||
<Style ss:ID="s145">
|
||||
<Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/>
|
||||
<Borders>
|
||||
<Border ss:Position="Bottom" ss:LineStyle="Dot" ss:Weight="1"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
</Style>
|
||||
<Style ss:ID="s146">
|
||||
<Alignment ss:Horizontal="Right" ss:Vertical="Bottom"/>
|
||||
<Borders>
|
||||
<Border ss:Position="Bottom" ss:LineStyle="Dash" ss:Weight="1"
|
||||
ss:Color="#000000"/>
|
||||
</Borders>
|
||||
</Style>
|
||||
<Style ss:ID="s147">
|
||||
<Alignment ss:Vertical="Top"/>
|
||||
<Interior ss:Color="#00CCFF" ss:Pattern="HorzStripe" ss:PatternColor="#0000FF"/>
|
||||
</Style>
|
||||
</Styles>
|
||||
<Names>
|
||||
<NamedRange ss:Name="goodname" ss:RefersTo="='Sample Data'!R30C1"/>
|
||||
<NamedRange ss:Name="MarksRange" ss:RefersTo="='Sample Data'!R1C2:R4C3"/>
|
||||
</Names>
|
||||
<Worksheet ss:Name="Sample Data">
|
||||
<Table ss:ExpandedColumnCount="14" ss:ExpandedRowCount="32" x:FullColumns="1"
|
||||
x:FullRows="1" ss:DefaultRowHeight="14.55">
|
||||
<Column ss:AutoFitWidth="0" ss:Width="96.6"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="48.6" ss:Span="1"/>
|
||||
<Column ss:Index="4" ss:AutoFitWidth="0" ss:Width="36"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="48.6" ss:Span="6"/>
|
||||
<Column ss:Index="12" ss:AutoFitWidth="0" ss:Width="50.4"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="48.6" ss:Span="1"/>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s63"><Data ss:Type="String">Test String 1</Data><Comment
|
||||
ss:Author="Mark"><ss:Data xmlns="http://www.w3.org/TR/REC-html40"><Font
|
||||
html:Face="Tahoma" html:Size="9" html:Color="#000000">Test for a simple colour-formatted string</Font></ss:Data></Comment></Cell>
|
||||
<Cell ss:StyleID="s64"><Data ss:Type="Number">1</Data><NamedCell
|
||||
ss:Name="MarksRange"/></Cell>
|
||||
<Cell ss:StyleID="s64"><Data ss:Type="Number">5</Data><NamedCell
|
||||
ss:Name="MarksRange"/></Cell>
|
||||
<Cell ss:Index="5" ss:StyleID="s65"><Data ss:Type="String">A</Data></Cell>
|
||||
<Cell ss:StyleID="s66"><Data ss:Type="String">E</Data></Cell>
|
||||
<Cell ss:Index="8" ss:Formula="=RC[-6]+RC[-5]"><Data ss:Type="Number">6</Data></Cell>
|
||||
<Cell ss:Index="10" ss:Formula="=RC[-5]&RC[-4]"><Data ss:Type="String">AE</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s65"><Data ss:Type="String">Test - String 2</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">2</Data><NamedCell ss:Name="MarksRange"/></Cell>
|
||||
<Cell ss:StyleID="s64"><Data ss:Type="Number">6</Data><NamedCell
|
||||
ss:Name="MarksRange"/></Cell>
|
||||
<Cell ss:Index="5"><Data ss:Type="String">B</Data></Cell>
|
||||
<Cell><Data ss:Type="String">F</Data></Cell>
|
||||
<Cell ss:Index="8" ss:Formula="=RC[-6]+RC[-5]"><Data ss:Type="Number">8</Data></Cell>
|
||||
<Cell ss:Index="10" ss:Formula="=RC[-5]&RC[-4]"><Data ss:Type="String">BF</Data></Cell>
|
||||
<Cell ss:Index="14" ss:StyleID="s145"><Data ss:Type="String">Dot</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s68"><Data ss:Type="String">Test #3</Data></Cell>
|
||||
<Cell ss:StyleID="s64"><Data ss:Type="Number">3</Data><NamedCell
|
||||
ss:Name="MarksRange"/></Cell>
|
||||
<Cell ss:StyleID="s64"><Data ss:Type="Number">7</Data><NamedCell
|
||||
ss:Name="MarksRange"/></Cell>
|
||||
<Cell ss:Index="5" ss:StyleID="s66"><Data ss:Type="String">C</Data></Cell>
|
||||
<Cell ss:StyleID="s65"><Data ss:Type="String">G</Data></Cell>
|
||||
<Cell ss:Index="8" ss:Formula="=RC[-6]+RC[-5]"><Data ss:Type="Number">10</Data></Cell>
|
||||
<Cell ss:Index="10" ss:Formula="=RC[-5]&RC[-4]"><Data ss:Type="String">CG</Data></Cell>
|
||||
<Cell ss:StyleID="s69"><Data ss:Type="String">Red</Data></Cell>
|
||||
<Cell ss:StyleID="s70"><Data ss:Type="String">Red</Data></Cell>
|
||||
<Cell ss:Index="14" ss:StyleID="s146"><Data ss:Type="String">Dash</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s64"><Data ss:Type="String">Test with (") in string</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">4</Data><NamedCell ss:Name="MarksRange"/></Cell>
|
||||
<Cell ss:StyleID="s64"><Data ss:Type="Number">8</Data><NamedCell
|
||||
ss:Name="MarksRange"/></Cell>
|
||||
<Cell ss:Index="5" ss:StyleID="s72"><Data ss:Type="String">D</Data></Cell>
|
||||
<Cell><Data ss:Type="String">H</Data></Cell>
|
||||
<Cell ss:Index="8" ss:Formula="=RC[-6]+RC[-5]"><Data ss:Type="Number">12</Data></Cell>
|
||||
<Cell ss:Index="10" ss:Formula="=RC[-5]&RC[-4]"><Data ss:Type="String">DH</Data></Cell>
|
||||
<Cell ss:StyleID="s73"><Data ss:Type="String">Orange</Data></Cell>
|
||||
<Cell ss:StyleID="s74"><Data ss:Type="String">Orange</Data></Cell>
|
||||
<Cell ss:Index="14" ss:StyleID="s75"><Data ss:Type="String">Dash/Dot/Dot</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:Index="8" ss:Formula="=SUM(R[-4]C[-6]:R[-1]C[-6])"><Data
|
||||
ss:Type="Number">10</Data></Cell>
|
||||
<Cell ss:Formula="=SUM(R[-4]C[-6]:R[-1]C[-6])"><Data ss:Type="Number">26</Data></Cell>
|
||||
<Cell ss:Formula="=SUM(R[-4]C[-8]:R[-1]C[-7])"><Data ss:Type="Number">36</Data></Cell>
|
||||
<Cell ss:StyleID="s76"><Data ss:Type="String">Yellow</Data></Cell>
|
||||
<Cell ss:StyleID="s77"><Data ss:Type="String">Yellow</Data></Cell>
|
||||
<Cell ss:Index="14" ss:StyleID="s78"><Data ss:Type="String">Dash/Dot</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s79"><Data ss:Type="String">Test #3</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">1.23</Data></Cell>
|
||||
<Cell ss:Formula="=TRUE()"><Data ss:Type="Boolean">1</Data></Cell>
|
||||
<Cell ss:StyleID="s80"><Data ss:Type="Boolean">1</Data></Cell>
|
||||
<Cell ss:Index="8" ss:Formula="=SUM(R[-1]C+R[-2]C)"><Data ss:Type="Number">22</Data></Cell>
|
||||
<Cell ss:Index="11" ss:StyleID="s81"><Data ss:Type="String">Green</Data></Cell>
|
||||
<Cell ss:StyleID="s82"><Data ss:Type="String">Green</Data></Cell>
|
||||
<Cell ss:Index="14" ss:StyleID="s83"><Data ss:Type="String">Thin Line</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s84"><Data ss:Type="String">Test #3</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">2.34</Data></Cell>
|
||||
<Cell ss:Formula="=FALSE()"><Data ss:Type="Boolean">0</Data></Cell>
|
||||
<Cell><Data ss:Type="Boolean">0</Data></Cell>
|
||||
<Cell ss:Index="8" ss:Formula="=SUM(MarksRange)"><Data ss:Type="Number">36</Data></Cell>
|
||||
<Cell ss:Index="11" ss:StyleID="s85"><Data ss:Type="String">Blue</Data></Cell>
|
||||
<Cell ss:StyleID="s86"><Data ss:Type="String">Blue</Data></Cell>
|
||||
<Cell ss:Index="14" ss:StyleID="s87"><Data ss:Type="String">Thick Dash/Dot/Dot</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s88"><Data ss:Type="String">Test #3</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">3.45</Data></Cell>
|
||||
<Cell ss:Index="11" ss:StyleID="s89"><Data ss:Type="String">Purple</Data></Cell>
|
||||
<Cell ss:StyleID="s90"><Data ss:Type="String">Purple</Data></Cell>
|
||||
<Cell ss:Index="14" ss:StyleID="s87"><Data ss:Type="String">Variant Thick Dash/Dot/Dot</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="13.5">
|
||||
<Cell ss:Index="11" ss:StyleID="s91"><Data ss:Type="String">Pink</Data></Cell>
|
||||
<Cell ss:StyleID="s92"><Data ss:Type="String">Pink</Data></Cell>
|
||||
<Cell ss:Index="14" ss:StyleID="s93"><Data ss:Type="String">Thick Dash/Dot</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s80"><Data ss:Type="DateTime">1960-12-19T00:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="3" ss:StyleID="s94"><Data ss:Type="String">TOP</Data></Cell>
|
||||
<Cell ss:Index="7"><Data ss:Type="Number">0</Data></Cell>
|
||||
<Cell ss:Index="11" ss:StyleID="s95"><Data ss:Type="String">Brown</Data></Cell>
|
||||
<Cell ss:StyleID="s74"><Data ss:Type="String">Brown</Data></Cell>
|
||||
<Cell ss:Index="14" ss:StyleID="s96"><Data ss:Type="String">Thick Dash</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s97"><Data ss:Type="Number">1.5</Data></Cell>
|
||||
<Cell ss:Index="7" ss:Formula="=12/0"><Data ss:Type="Error">#DIV/0!</Data></Cell>
|
||||
<Cell ss:Index="14" ss:StyleID="s98"><Data ss:Type="String">Thick Line</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="13.5">
|
||||
<Cell ss:Index="3" ss:StyleID="s99"><Data ss:Type="String">BOTTOM</Data></Cell>
|
||||
<Cell ss:Index="14" ss:StyleID="s100"><Data ss:Type="String">Extra Thick Line</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s101"><Data ss:Type="DateTime">1899-12-31T02:30:00.000</Data></Cell>
|
||||
<Cell ss:Index="6"><Data ss:Type="String">Мойва сушеная</Data><Comment
|
||||
ss:Author="Mark"><ss:Data xmlns="http://www.w3.org/TR/REC-html40"><Font
|
||||
html:Face="Tahoma" html:Size="9" html:Color="#000000">Tests for UTF-8 content</Font></ss:Data></Comment></Cell>
|
||||
<Cell ss:Index="14" ss:StyleID="s102"><Data ss:Type="String">Double Line</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:Index="3" ss:StyleID="s103"><Data ss:Type="String">LEFT</Data></Cell>
|
||||
<Cell ss:Index="6"><Data ss:Type="String">Ärendetext</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s104"><Data ss:Type="DateTime">1960-12-19T01:30:00.000</Data></Cell>
|
||||
<Cell ss:Index="6"><Data ss:Type="String">Højde</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:Index="3" ss:StyleID="s105"><Data ss:Type="String">RIGHT</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="13.5"/>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="27.75">
|
||||
<Cell ss:Index="2" ss:MergeAcross="1" ss:MergeDown="1"
|
||||
ss:StyleID="m1867777004784"><Data ss:Type="String">BOX</Data></Cell>
|
||||
<Cell ss:Index="5" ss:StyleID="s113"/>
|
||||
<Cell ss:Index="7" ss:StyleID="s114"><Data ss:Type="String">Test Column 1</Data></Cell>
|
||||
<Cell ss:StyleID="s114"/>
|
||||
<Cell ss:StyleID="s115"/>
|
||||
<Cell ss:StyleID="s116"/>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="27.75">
|
||||
<Cell ss:Index="7" ss:StyleID="s114"/>
|
||||
<Cell ss:StyleID="s114"><Data ss:Type="String">Test Column 2</Data></Cell>
|
||||
<Cell ss:StyleID="s114"/>
|
||||
<Cell ss:Index="11" ss:StyleID="s147"><Data ss:Type="String">Patterned</Data></Cell>
|
||||
<Cell ss:StyleID="s118"><Data ss:Type="String">Patterned 2</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="27.75">
|
||||
<Cell ss:Index="7" ss:StyleID="s114"/>
|
||||
<Cell ss:StyleID="s114"/>
|
||||
<Cell ss:StyleID="s114"><Data ss:Type="String">Test Column 3</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s62" ss:HRef="https://github.com/PHPOffice/PhpSpreadsheet"><Data
|
||||
ss:Type="String">PhpSpreadsheet</Data></Cell>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s121"><Data ss:Type="String">Underline None</Data></Cell>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:MergeAcross="1" ss:MergeDown="4" ss:StyleID="s123"><Data
|
||||
ss:Type="String">Rotate 90</Data></Cell>
|
||||
<Cell ss:MergeAcross="1" ss:MergeDown="4" ss:StyleID="s125"><Data
|
||||
ss:Type="String">Rotate 45</Data></Cell>
|
||||
<Cell ss:MergeAcross="1" ss:MergeDown="4" ss:StyleID="s127"><Data
|
||||
ss:Type="String">Rotate -90</Data></Cell>
|
||||
<Cell ss:MergeAcross="1" ss:MergeDown="4" ss:StyleID="s129"><Data
|
||||
ss:Type="String">Rotate -45</Data></Cell>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s130"><Data ss:Type="String">Underline 1</Data></Cell>
|
||||
<Cell ss:StyleID="s131"><Data ss:Type="String">Subscript</Data></Cell>
|
||||
<Cell ss:Index="11" ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s132"><Data ss:Type="String">Underline 2</Data></Cell>
|
||||
<Cell ss:StyleID="s133"><Data ss:Type="String">Superscript</Data></Cell>
|
||||
<Cell ss:Index="11" ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s134"><Data ss:Type="String">Underline 3</Data></Cell>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:Index="11" ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s135"><Data ss:Type="String">Underline 4</Data></Cell>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:Index="11" ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:MergeAcross="2" ss:StyleID="s136"><Data ss:Type="String">I don't know if Gnumeric supports Rich Text in the same way as Excel, And this row should be autofit height with text wrap</Data></Cell>
|
||||
<Cell ss:StyleID="s136"/>
|
||||
<Cell ss:StyleID="s136"/>
|
||||
<Cell ss:StyleID="s136"/>
|
||||
<Cell ss:StyleID="s136"/>
|
||||
<Cell ss:StyleID="s136"/>
|
||||
<Cell ss:StyleID="s136"/>
|
||||
<Cell ss:StyleID="s136"/>
|
||||
<Cell ss:StyleID="s136"/>
|
||||
<Cell ss:StyleID="s136"/>
|
||||
<Cell ss:StyleID="s136"/>
|
||||
<Cell ss:StyleID="s136"/>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell ss:MergeAcross="2" ss:StyleID="s139"><Data ss:Type="String">Blue with underline</Data></Cell>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15" ss:Hidden="1">
|
||||
<Cell ss:StyleID="s140"><Data ss:Type="Number">5</Data><NamedCell
|
||||
ss:Name="goodname"/></Cell>
|
||||
<Cell ss:StyleID="s121" ss:Formula="=goodname"><Data ss:Type="Number">5</Data></Cell>
|
||||
<Cell ss:StyleID="s121" ss:Formula="=@badname"><Data ss:Type="Error">#NAME?</Data></Cell>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell ss:StyleID="s121"><Data ss:Type="String">Hidden row above</Data></Cell>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
</Row>
|
||||
</Table>
|
||||
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
|
||||
<PageSetup>
|
||||
<Header x:Margin="0.72"/>
|
||||
<Footer x:Margin="0.72"/>
|
||||
<PageMargins x:Bottom="1.2" x:Left="0.72" x:Right="0.72" x:Top="1.2"/>
|
||||
</PageSetup>
|
||||
<Unsynced/>
|
||||
<Print>
|
||||
<ValidPrinterInfo/>
|
||||
<HorizontalResolution>600</HorizontalResolution>
|
||||
<VerticalResolution>600</VerticalResolution>
|
||||
</Print>
|
||||
<Selected/>
|
||||
<TopRowVisible>3</TopRowVisible>
|
||||
<Panes>
|
||||
<Pane>
|
||||
<Number>3</Number>
|
||||
<ActiveRow>18</ActiveRow>
|
||||
<ActiveCol>10</ActiveCol>
|
||||
</Pane>
|
||||
</Panes>
|
||||
<ProtectObjects>False</ProtectObjects>
|
||||
<ProtectScenarios>False</ProtectScenarios>
|
||||
<AllowFormatCells/>
|
||||
<AllowSizeCols/>
|
||||
<AllowSizeRows/>
|
||||
<AllowInsertCols/>
|
||||
<AllowInsertRows/>
|
||||
<AllowInsertHyperlinks/>
|
||||
<AllowDeleteCols/>
|
||||
<AllowDeleteRows/>
|
||||
<AllowSort/>
|
||||
<AllowFilter/>
|
||||
<AllowUsePivotTables/>
|
||||
</WorksheetOptions>
|
||||
</Worksheet>
|
||||
<Worksheet ss:Name="Report Data">
|
||||
<Table ss:ExpandedColumnCount="11" ss:ExpandedRowCount="16" x:FullColumns="1"
|
||||
x:FullRows="1" ss:DefaultRowHeight="14.55">
|
||||
<Column ss:AutoFitWidth="0" ss:Width="56.4" ss:Span="2"/>
|
||||
<Column ss:Index="4" ss:AutoFitWidth="0" ss:Width="78.599999999999994"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="58.2"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="27.6"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="78.599999999999994"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="68.399999999999991"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="48.6"/>
|
||||
<Column ss:Hidden="1" ss:AutoFitWidth="0" ss:Width="48.6"/>
|
||||
<Column ss:AutoFitWidth="0" ss:Width="48.6"/>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="31.5">
|
||||
<Cell ss:StyleID="s141"/>
|
||||
<Cell ss:StyleID="s141"/>
|
||||
<Cell ss:StyleID="s141"/>
|
||||
<Cell ss:StyleID="s141"/>
|
||||
<Cell ss:StyleID="s141"/>
|
||||
<Cell ss:Index="7" ss:StyleID="s141"/>
|
||||
<Cell ss:StyleID="s141"/>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="31.5">
|
||||
<Cell ss:StyleID="s141"><Data ss:Type="String">Heading 1</Data></Cell>
|
||||
<Cell ss:StyleID="s141"><Data ss:Type="String">Heading 2</Data></Cell>
|
||||
<Cell ss:StyleID="s141"><Data ss:Type="String">Third Heading</Data></Cell>
|
||||
<Cell ss:StyleID="s141"><Data ss:Type="String">Date Heading</Data></Cell>
|
||||
<Cell ss:StyleID="s141"><Data ss:Type="String">Time Heading</Data></Cell>
|
||||
<Cell ss:Index="7" ss:StyleID="s141"><Data ss:Type="String">Adjusted Date</Data></Cell>
|
||||
<Cell ss:StyleID="s141"><Data ss:Type="String">Adjusted Number</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell><Data ss:Type="String">ABC</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">1</Data></Cell>
|
||||
<Cell ss:StyleID="s142"><Data ss:Type="Number">1.1100000000000001</Data></Cell>
|
||||
<Cell ss:StyleID="s143"><Data ss:Type="DateTime">2001-01-01T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s144"><Data ss:Type="DateTime">1899-12-31T01:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="7" ss:StyleID="s143" ss:Formula="=RC[-3]-RC[-5]"><Data
|
||||
ss:Type="DateTime">2000-12-31T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s142" ss:Formula="=RC[-6]*RC[-5]"><Data ss:Type="Number">1.1100000000000001</Data></Cell>
|
||||
<Cell ss:Index="10"><Data ss:Type="String">A</Data></Cell>
|
||||
<Cell ss:Formula="=RC[-9]&RC[-1]"><Data ss:Type="String">1A</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell><Data ss:Type="String">BCD</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">2</Data></Cell>
|
||||
<Cell ss:StyleID="s142"><Data ss:Type="Number">2.2200000000000002</Data></Cell>
|
||||
<Cell ss:StyleID="s143"><Data ss:Type="DateTime">2002-02-02T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s144"><Data ss:Type="DateTime">1899-12-31T02:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="7" ss:StyleID="s143" ss:Formula="=RC[-3]-RC[-5]"><Data
|
||||
ss:Type="DateTime">2002-01-31T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s142" ss:Formula="=RC[-6]*RC[-5]"><Data ss:Type="Number">4.4400000000000004</Data></Cell>
|
||||
<Cell ss:Index="10"><Data ss:Type="String">B</Data></Cell>
|
||||
<Cell ss:Formula="=RC[-9]&RC[-1]"><Data ss:Type="String">2B</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell><Data ss:Type="String">CDE</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">3</Data></Cell>
|
||||
<Cell ss:StyleID="s142"><Data ss:Type="Number">3.33</Data></Cell>
|
||||
<Cell ss:StyleID="s143"><Data ss:Type="DateTime">2003-03-03T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s144"><Data ss:Type="DateTime">1899-12-31T03:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="7" ss:StyleID="s143" ss:Formula="=RC[-3]-RC[-5]"><Data
|
||||
ss:Type="DateTime">2003-02-28T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s142" ss:Formula="=RC[-6]*RC[-5]"><Data ss:Type="Number">9.99</Data></Cell>
|
||||
<Cell ss:Index="10"><Data ss:Type="String">C</Data></Cell>
|
||||
<Cell ss:Formula="=RC[-9]&RC[-1]"><Data ss:Type="String">3C</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell><Data ss:Type="String">DEF</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">4</Data></Cell>
|
||||
<Cell ss:StyleID="s142"><Data ss:Type="Number">4.4400000000000004</Data></Cell>
|
||||
<Cell ss:StyleID="s143"><Data ss:Type="DateTime">2004-04-03T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s144"><Data ss:Type="DateTime">1899-12-31T04:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="7" ss:StyleID="s143" ss:Formula="=RC[-3]-RC[-5]"><Data
|
||||
ss:Type="DateTime">2004-03-30T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s142" ss:Formula="=RC[-6]*RC[-5]"><Data ss:Type="Number">17.760000000000002</Data></Cell>
|
||||
<Cell ss:Index="10"><Data ss:Type="String">D</Data></Cell>
|
||||
<Cell ss:Formula="=RC[-9]&RC[-1]"><Data ss:Type="String">4D</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell><Data ss:Type="String">EFG</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">5</Data></Cell>
|
||||
<Cell ss:StyleID="s142"><Data ss:Type="Number">5.55</Data></Cell>
|
||||
<Cell ss:StyleID="s143"><Data ss:Type="DateTime">2005-05-04T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s144"><Data ss:Type="DateTime">1899-12-31T05:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="7" ss:StyleID="s143" ss:Formula="=RC[-3]-RC[-5]"><Data
|
||||
ss:Type="DateTime">2005-04-29T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s142" ss:Formula="=RC[-6]*RC[-5]"><Data ss:Type="Number">27.75</Data></Cell>
|
||||
<Cell ss:Index="10"><Data ss:Type="String">E</Data></Cell>
|
||||
<Cell ss:Formula="=RC[-9]&RC[-1]"><Data ss:Type="String">5E</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell><Data ss:Type="String">FGH</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">6</Data></Cell>
|
||||
<Cell ss:StyleID="s142"><Data ss:Type="Number">6.66</Data></Cell>
|
||||
<Cell ss:StyleID="s143"><Data ss:Type="DateTime">2006-06-05T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s144"><Data ss:Type="DateTime">1899-12-31T06:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="7" ss:StyleID="s143" ss:Formula="=RC[-3]-RC[-5]"><Data
|
||||
ss:Type="DateTime">2006-05-30T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s142" ss:Formula="=RC[-6]*RC[-5]"><Data ss:Type="Number">39.96</Data></Cell>
|
||||
<Cell ss:Index="10"><Data ss:Type="String">F</Data></Cell>
|
||||
<Cell ss:Formula="=RC[-9]&RC[-1]"><Data ss:Type="String">6F</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell><Data ss:Type="String">GHI</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">7</Data></Cell>
|
||||
<Cell ss:StyleID="s142"><Data ss:Type="Number">7.77</Data></Cell>
|
||||
<Cell ss:StyleID="s143"><Data ss:Type="DateTime">2007-07-06T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s144"><Data ss:Type="DateTime">1899-12-31T07:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="7" ss:StyleID="s143" ss:Formula="=RC[-3]-RC[-5]"><Data
|
||||
ss:Type="DateTime">2007-06-29T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s142" ss:Formula="=RC[-6]*RC[-5]"><Data ss:Type="Number">54.39</Data></Cell>
|
||||
<Cell ss:Index="10"><Data ss:Type="String">G</Data></Cell>
|
||||
<Cell ss:Formula="=RC[-9]&RC[-1]"><Data ss:Type="String">7G</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell><Data ss:Type="String">HIJ</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">8</Data></Cell>
|
||||
<Cell ss:StyleID="s142"><Data ss:Type="Number">8.8800000000000008</Data></Cell>
|
||||
<Cell ss:StyleID="s143"><Data ss:Type="DateTime">2008-08-07T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s144"><Data ss:Type="DateTime">1899-12-31T08:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="7" ss:StyleID="s143" ss:Formula="=RC[-3]-RC[-5]"><Data
|
||||
ss:Type="DateTime">2008-07-30T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s142" ss:Formula="=RC[-6]*RC[-5]"><Data ss:Type="Number">71.040000000000006</Data></Cell>
|
||||
<Cell ss:Index="10"><Data ss:Type="String">H</Data></Cell>
|
||||
<Cell ss:Formula="=RC[-9]&RC[-1]"><Data ss:Type="String">8H</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell><Data ss:Type="String">IJK</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">9</Data></Cell>
|
||||
<Cell ss:StyleID="s142"><Data ss:Type="Number">9.99</Data></Cell>
|
||||
<Cell ss:StyleID="s143"><Data ss:Type="DateTime">2009-09-08T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s144"><Data ss:Type="DateTime">1899-12-31T09:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="7" ss:StyleID="s143" ss:Formula="=RC[-3]-RC[-5]"><Data
|
||||
ss:Type="DateTime">2009-08-30T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s142" ss:Formula="=RC[-6]*RC[-5]"><Data ss:Type="Number">89.91</Data></Cell>
|
||||
<Cell ss:Index="10"><Data ss:Type="String">I</Data></Cell>
|
||||
<Cell ss:Formula="=RC[-9]&RC[-1]"><Data ss:Type="String">9I</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell><Data ss:Type="String">JKL</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">10</Data></Cell>
|
||||
<Cell ss:StyleID="s142"><Data ss:Type="Number">11.1</Data></Cell>
|
||||
<Cell ss:StyleID="s143"><Data ss:Type="DateTime">2010-10-09T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s144"><Data ss:Type="DateTime">1899-12-31T10:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="7" ss:StyleID="s143" ss:Formula="=RC[-3]-RC[-5]"><Data
|
||||
ss:Type="DateTime">2010-09-29T23:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s142" ss:Formula="=RC[-6]*RC[-5]"><Data ss:Type="Number">111</Data></Cell>
|
||||
<Cell ss:Index="10"><Data ss:Type="String">J</Data></Cell>
|
||||
<Cell ss:Formula="=RC[-9]&RC[-1]"><Data ss:Type="String">10J</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell><Data ss:Type="String">KLM</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">11</Data></Cell>
|
||||
<Cell ss:StyleID="s142"><Data ss:Type="Number">12.21</Data></Cell>
|
||||
<Cell ss:StyleID="s143"><Data ss:Type="DateTime">2011-11-11T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s144"><Data ss:Type="DateTime">1899-12-31T11:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="7" ss:StyleID="s143" ss:Formula="=RC[-3]-RC[-5]"><Data
|
||||
ss:Type="DateTime">2011-10-31T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s142" ss:Formula="=RC[-6]*RC[-5]"><Data ss:Type="Number">134.31</Data></Cell>
|
||||
<Cell ss:Index="10"><Data ss:Type="String">K</Data></Cell>
|
||||
<Cell ss:Formula="=RC[-9]&RC[-1]"><Data ss:Type="String">11K</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell><Data ss:Type="String">LMN</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">12</Data></Cell>
|
||||
<Cell ss:StyleID="s142"><Data ss:Type="Number">13.32</Data></Cell>
|
||||
<Cell ss:StyleID="s143"><Data ss:Type="DateTime">2012-12-12T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s144"><Data ss:Type="DateTime">1900-01-12T00:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="7" ss:StyleID="s143" ss:Formula="=RC[-3]-RC[-5]"><Data
|
||||
ss:Type="DateTime">2012-11-30T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s142" ss:Formula="=RC[-6]*RC[-5]"><Data ss:Type="Number">159.84</Data></Cell>
|
||||
<Cell ss:Index="10"><Data ss:Type="String">L</Data></Cell>
|
||||
<Cell ss:Formula="=RC[-9]&RC[-1]"><Data ss:Type="String">12L</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0" ss:Height="15">
|
||||
<Cell><Data ss:Type="String">ZYX</Data></Cell>
|
||||
<Cell><Data ss:Type="Number">-1</Data></Cell>
|
||||
<Cell ss:StyleID="s142"><Data ss:Type="Number">-1.1100000000000001</Data></Cell>
|
||||
<Cell ss:StyleID="s143"><Data ss:Type="DateTime">1999-12-01T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s144"><Data ss:Type="DateTime">1899-12-31T23:00:00.000</Data></Cell>
|
||||
<Cell ss:Index="7" ss:StyleID="s143" ss:Formula="=RC[-3]-RC[-5]"><Data
|
||||
ss:Type="DateTime">1999-12-02T00:00:00.000</Data></Cell>
|
||||
<Cell ss:StyleID="s142" ss:Formula="=RC[-6]*RC[-5]"><Data ss:Type="Number">1.1100000000000001</Data></Cell>
|
||||
<Cell ss:Index="10"><Data ss:Type="String">M</Data></Cell>
|
||||
<Cell ss:Formula="=RC[-9]&RC[-1]"><Data ss:Type="String">-1M</Data></Cell>
|
||||
</Row>
|
||||
<Row ss:AutoFitHeight="0">
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
<Cell ss:StyleID="s121"/>
|
||||
</Row>
|
||||
</Table>
|
||||
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
|
||||
<PageSetup>
|
||||
<Header x:Margin="0.72"/>
|
||||
<Footer x:Margin="0.72"/>
|
||||
<PageMargins x:Bottom="1.2" x:Left="0.72" x:Right="0.72" x:Top="1.2"/>
|
||||
</PageSetup>
|
||||
<Unsynced/>
|
||||
<Print>
|
||||
<ValidPrinterInfo/>
|
||||
<NoOrientation/>
|
||||
<HorizontalResolution>600</HorizontalResolution>
|
||||
<VerticalResolution>600</VerticalResolution>
|
||||
</Print>
|
||||
<Panes>
|
||||
<Pane>
|
||||
<Number>3</Number>
|
||||
<ActiveCol>8</ActiveCol>
|
||||
<RangeSelection>R1C9:R15C11</RangeSelection>
|
||||
</Pane>
|
||||
</Panes>
|
||||
<ProtectObjects>False</ProtectObjects>
|
||||
<ProtectScenarios>False</ProtectScenarios>
|
||||
<AllowFormatCells/>
|
||||
<AllowSizeCols/>
|
||||
<AllowSizeRows/>
|
||||
<AllowInsertCols/>
|
||||
<AllowInsertRows/>
|
||||
<AllowInsertHyperlinks/>
|
||||
<AllowDeleteCols/>
|
||||
<AllowDeleteRows/>
|
||||
<AllowSort/>
|
||||
<AllowFilter/>
|
||||
<AllowUsePivotTables/>
|
||||
</WorksheetOptions>
|
||||
</Worksheet>
|
||||
</Workbook>
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -16,4 +16,5 @@ abstract class Category
|
|||
const CATEGORY_MATH_AND_TRIG = 'Math and Trig';
|
||||
const CATEGORY_STATISTICAL = 'Statistical';
|
||||
const CATEGORY_TEXT_AND_DATA = 'Text and Data';
|
||||
const CATEGORY_WEB = 'Web';
|
||||
}
|
||||
|
|
|
@ -552,7 +552,7 @@ class Database
|
|||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
*
|
||||
* @return float
|
||||
* @return float|string (string if result is an error)
|
||||
*/
|
||||
public static function DVAR($database, $field, $criteria)
|
||||
{
|
||||
|
@ -591,7 +591,7 @@ class Database
|
|||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
*
|
||||
* @return float
|
||||
* @return float|string (string if result is an error)
|
||||
*/
|
||||
public static function DVARP($database, $field, $criteria)
|
||||
{
|
||||
|
|
|
@ -274,9 +274,11 @@ class DateTime
|
|||
$year = ($year !== null) ? StringHelper::testStringAsNumeric($year) : 0;
|
||||
$month = ($month !== null) ? StringHelper::testStringAsNumeric($month) : 0;
|
||||
$day = ($day !== null) ? StringHelper::testStringAsNumeric($day) : 0;
|
||||
if ((!is_numeric($year)) ||
|
||||
if (
|
||||
(!is_numeric($year)) ||
|
||||
(!is_numeric($month)) ||
|
||||
(!is_numeric($day))) {
|
||||
(!is_numeric($day))
|
||||
) {
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$year = (int) $year;
|
||||
|
@ -487,7 +489,7 @@ class DateTime
|
|||
if ($yearFound) {
|
||||
array_unshift($t1, 1);
|
||||
} else {
|
||||
if ($t1[1] > 29) {
|
||||
if (is_numeric($t1[1]) && $t1[1] > 29) {
|
||||
$t1[1] += 1900;
|
||||
array_unshift($t1, 1);
|
||||
} else {
|
||||
|
@ -668,30 +670,19 @@ class DateTime
|
|||
$endMonths = $PHPEndDateObject->format('n');
|
||||
$endYears = $PHPEndDateObject->format('Y');
|
||||
|
||||
$PHPDiffDateObject = $PHPEndDateObject->diff($PHPStartDateObject);
|
||||
|
||||
switch ($unit) {
|
||||
case 'D':
|
||||
$retVal = (int) $difference;
|
||||
|
||||
break;
|
||||
case 'M':
|
||||
$retVal = (int) ($endMonths - $startMonths) + ((int) ($endYears - $startYears) * 12);
|
||||
// We're only interested in full months
|
||||
if ($endDays < $startDays) {
|
||||
--$retVal;
|
||||
}
|
||||
$retVal = (int) 12 * $PHPDiffDateObject->format('%y') + $PHPDiffDateObject->format('%m');
|
||||
|
||||
break;
|
||||
case 'Y':
|
||||
$retVal = (int) ($endYears - $startYears);
|
||||
// We're only interested in full months
|
||||
if ($endMonths < $startMonths) {
|
||||
--$retVal;
|
||||
} elseif (($endMonths == $startMonths) && ($endDays < $startDays)) {
|
||||
// Remove start month
|
||||
--$retVal;
|
||||
// Remove end month
|
||||
--$retVal;
|
||||
}
|
||||
$retVal = (int) $PHPDiffDateObject->format('%y');
|
||||
|
||||
break;
|
||||
case 'MD':
|
||||
|
@ -701,19 +692,12 @@ class DateTime
|
|||
$adjustDays = $PHPEndDateObject->format('j');
|
||||
$retVal += ($adjustDays - $startDays);
|
||||
} else {
|
||||
$retVal = $endDays - $startDays;
|
||||
$retVal = (int) $PHPDiffDateObject->format('%d');
|
||||
}
|
||||
|
||||
break;
|
||||
case 'YM':
|
||||
$retVal = (int) ($endMonths - $startMonths);
|
||||
if ($retVal < 0) {
|
||||
$retVal += 12;
|
||||
}
|
||||
// We're only interested in full months
|
||||
if ($endDays < $startDays) {
|
||||
--$retVal;
|
||||
}
|
||||
$retVal = (int) $PHPDiffDateObject->format('%m');
|
||||
|
||||
break;
|
||||
case 'YD':
|
||||
|
|
|
@ -106,6 +106,20 @@ class Logger
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a series of entries to the calculation engine debug log.
|
||||
*
|
||||
* @param string[] $args
|
||||
*/
|
||||
public function mergeDebugLog(array $args): void
|
||||
{
|
||||
if ($this->writeDebugLog) {
|
||||
foreach ($args as $entry) {
|
||||
$this->writeDebugLog($entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the calculation engine debug log.
|
||||
*/
|
||||
|
|
|
@ -1674,7 +1674,8 @@ class Engineering
|
|||
$imaginary = ($imaginary === null) ? 0.0 : Functions::flattenSingleValue($imaginary);
|
||||
$suffix = ($suffix === null) ? 'i' : Functions::flattenSingleValue($suffix);
|
||||
|
||||
if (((is_numeric($realNumber)) && (is_numeric($imaginary))) &&
|
||||
if (
|
||||
((is_numeric($realNumber)) && (is_numeric($imaginary))) &&
|
||||
(($suffix == 'i') || ($suffix == 'j') || ($suffix == ''))
|
||||
) {
|
||||
$complex = new Complex($realNumber, $imaginary, $suffix);
|
||||
|
@ -2729,11 +2730,13 @@ class Engineering
|
|||
}
|
||||
|
||||
return $value;
|
||||
} elseif ((($fromUOM == 'K') || ($fromUOM == 'kel')) &&
|
||||
} elseif (
|
||||
(($fromUOM == 'K') || ($fromUOM == 'kel')) &&
|
||||
(($toUOM == 'K') || ($toUOM == 'kel'))
|
||||
) {
|
||||
return $value;
|
||||
} elseif ((($fromUOM == 'C') || ($fromUOM == 'cel')) &&
|
||||
} elseif (
|
||||
(($fromUOM == 'C') || ($fromUOM == 'cel')) &&
|
||||
(($toUOM == 'C') || ($toUOM == 'cel'))
|
||||
) {
|
||||
return $value;
|
||||
|
|
|
@ -395,9 +395,11 @@ class Financial
|
|||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
if (($settlement >= $maturity) ||
|
||||
if (
|
||||
($settlement >= $maturity) ||
|
||||
(!self::isValidFrequency($frequency)) ||
|
||||
(($basis < 0) || ($basis > 4))) {
|
||||
(($basis < 0) || ($basis > 4))
|
||||
) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
|
@ -452,9 +454,11 @@ class Financial
|
|||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
if (($settlement >= $maturity) ||
|
||||
if (
|
||||
($settlement >= $maturity) ||
|
||||
(!self::isValidFrequency($frequency)) ||
|
||||
(($basis < 0) || ($basis > 4))) {
|
||||
(($basis < 0) || ($basis > 4))
|
||||
) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
|
@ -520,9 +524,11 @@ class Financial
|
|||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
if (($settlement >= $maturity) ||
|
||||
if (
|
||||
($settlement >= $maturity) ||
|
||||
(!self::isValidFrequency($frequency)) ||
|
||||
(($basis < 0) || ($basis > 4))) {
|
||||
(($basis < 0) || ($basis > 4))
|
||||
) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
|
@ -574,9 +580,11 @@ class Financial
|
|||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
if (($settlement >= $maturity) ||
|
||||
if (
|
||||
($settlement >= $maturity) ||
|
||||
(!self::isValidFrequency($frequency)) ||
|
||||
(($basis < 0) || ($basis > 4))) {
|
||||
(($basis < 0) || ($basis > 4))
|
||||
) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
|
@ -625,9 +633,11 @@ class Financial
|
|||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
if (($settlement >= $maturity) ||
|
||||
if (
|
||||
($settlement >= $maturity) ||
|
||||
(!self::isValidFrequency($frequency)) ||
|
||||
(($basis < 0) || ($basis > 4))) {
|
||||
(($basis < 0) || ($basis > 4))
|
||||
) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
|
@ -678,9 +688,11 @@ class Financial
|
|||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
if (($settlement >= $maturity) ||
|
||||
if (
|
||||
($settlement >= $maturity) ||
|
||||
(!self::isValidFrequency($frequency)) ||
|
||||
(($basis < 0) || ($basis > 4))) {
|
||||
(($basis < 0) || ($basis > 4))
|
||||
) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
|
@ -1619,9 +1631,11 @@ class Financial
|
|||
$frequency = (int) $frequency;
|
||||
$basis = (int) $basis;
|
||||
|
||||
if (($settlement > $maturity) ||
|
||||
if (
|
||||
($settlement > $maturity) ||
|
||||
(!self::isValidFrequency($frequency)) ||
|
||||
(($basis < 0) || ($basis > 4))) {
|
||||
(($basis < 0) || ($basis > 4))
|
||||
) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
|
|
|
@ -490,11 +490,13 @@ class FormulaParser
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!(
|
||||
if (
|
||||
!(
|
||||
(($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
(($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -502,11 +504,13 @@ class FormulaParser
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!(
|
||||
if (
|
||||
!(
|
||||
(($nextToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) && ($nextToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_START)) ||
|
||||
(($nextToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($nextToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_START)) ||
|
||||
($nextToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -538,12 +542,14 @@ class FormulaParser
|
|||
if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == '-') {
|
||||
if ($i == 0) {
|
||||
$token->setTokenType(FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
|
||||
} elseif ((($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) &&
|
||||
} elseif (
|
||||
(($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) &&
|
||||
($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
(($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) &&
|
||||
($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
|
||||
($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)) {
|
||||
($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)
|
||||
) {
|
||||
$token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_MATH);
|
||||
} else {
|
||||
$token->setTokenType(FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
|
||||
|
@ -557,12 +563,14 @@ class FormulaParser
|
|||
if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == '+') {
|
||||
if ($i == 0) {
|
||||
continue;
|
||||
} elseif ((($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) &&
|
||||
} elseif (
|
||||
(($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) &&
|
||||
($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
(($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) &&
|
||||
($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
|
||||
($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)) {
|
||||
($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)
|
||||
) {
|
||||
$token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_MATH);
|
||||
} else {
|
||||
continue;
|
||||
|
@ -573,8 +581,10 @@ class FormulaParser
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX &&
|
||||
$token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
||||
if (
|
||||
$token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX &&
|
||||
$token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING
|
||||
) {
|
||||
if (strpos('<>=', substr($token->getValue(), 0, 1)) !== false) {
|
||||
$token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||
} elseif ($token->getValue() == '&') {
|
||||
|
@ -588,8 +598,10 @@ class FormulaParser
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND &&
|
||||
$token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
||||
if (
|
||||
$token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND &&
|
||||
$token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING
|
||||
) {
|
||||
if (!is_numeric($token->getValue())) {
|
||||
if (strtoupper($token->getValue()) == 'TRUE' || strtoupper($token->getValue()) == 'FALSE') {
|
||||
$token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||
|
|
|
@ -67,7 +67,8 @@ class Functions
|
|||
*/
|
||||
public static function setCompatibilityMode($compatibilityMode)
|
||||
{
|
||||
if (($compatibilityMode == self::COMPATIBILITY_EXCEL) ||
|
||||
if (
|
||||
($compatibilityMode == self::COMPATIBILITY_EXCEL) ||
|
||||
($compatibilityMode == self::COMPATIBILITY_GNUMERIC) ||
|
||||
($compatibilityMode == self::COMPATIBILITY_OPENOFFICE)
|
||||
) {
|
||||
|
@ -106,7 +107,8 @@ class Functions
|
|||
*/
|
||||
public static function setReturnDateType($returnDateType)
|
||||
{
|
||||
if (($returnDateType == self::RETURNDATE_UNIX_TIMESTAMP) ||
|
||||
if (
|
||||
($returnDateType == self::RETURNDATE_UNIX_TIMESTAMP) ||
|
||||
($returnDateType == self::RETURNDATE_PHP_DATETIME_OBJECT) ||
|
||||
($returnDateType == self::RETURNDATE_EXCEL)
|
||||
) {
|
||||
|
@ -645,7 +647,7 @@ class Functions
|
|||
preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellReference, $matches);
|
||||
|
||||
$cellReference = $matches[6] . $matches[7];
|
||||
$worksheetName = trim($matches[3], "'");
|
||||
$worksheetName = str_replace("''", "'", trim($matches[2], "'"));
|
||||
|
||||
$worksheet = (!empty($worksheetName))
|
||||
? $pCell->getWorksheet()->getParent()->getSheetByName($worksheetName)
|
||||
|
|
|
@ -352,4 +352,39 @@ class Logical
|
|||
|
||||
return self::statementIf(Functions::isNa($testValue), $napart, $testValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* IFS.
|
||||
*
|
||||
* Excel Function:
|
||||
* =IFS(testValue1;returnIfTrue1;testValue2;returnIfTrue2;...;testValue_n;returnIfTrue_n)
|
||||
*
|
||||
* testValue1 ... testValue_n
|
||||
* Conditions to Evaluate
|
||||
* returnIfTrue1 ... returnIfTrue_n
|
||||
* Value returned if corresponding testValue (nth) was true
|
||||
*
|
||||
* @param mixed ...$arguments Statement arguments
|
||||
*
|
||||
* @return mixed|string The value of returnIfTrue_n, if testValue_n was true. #N/A if none of testValues was true
|
||||
*/
|
||||
public static function IFS(...$arguments)
|
||||
{
|
||||
if (count($arguments) % 2 != 0) {
|
||||
return Functions::NA();
|
||||
}
|
||||
// We use instance of Exception as a falseValue in order to prevent string collision with value in cell
|
||||
$falseValueException = new Exception();
|
||||
for ($i = 0; $i < count($arguments); $i += 2) {
|
||||
$testValue = ($arguments[$i] === null) ? '' : Functions::flattenSingleValue($arguments[$i]);
|
||||
$returnIfTrue = ($arguments[$i + 1] === null) ? '' : Functions::flattenSingleValue($arguments[$i + 1]);
|
||||
$result = self::statementIf($testValue, $returnIfTrue, $falseValueException);
|
||||
|
||||
if ($result !== $falseValueException) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
return Functions::NA();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ class LookupRef
|
|||
*
|
||||
* @param null|array|string $cellAddress An array or array formula, or a reference to a range of cells for which you want the number of columns
|
||||
*
|
||||
* @return int The number of columns in cellAddress
|
||||
* @return int|string The number of columns in cellAddress, or a string if arguments are invalid
|
||||
*/
|
||||
public static function COLUMNS($cellAddress = null)
|
||||
{
|
||||
|
@ -160,7 +160,7 @@ class LookupRef
|
|||
*
|
||||
* @param null|array|string $cellAddress A reference to a range of cells for which you want the row numbers
|
||||
*
|
||||
* @return int or array of integer
|
||||
* @return int|mixed[]|string
|
||||
*/
|
||||
public static function ROW($cellAddress = null)
|
||||
{
|
||||
|
@ -203,7 +203,7 @@ class LookupRef
|
|||
*
|
||||
* @param null|array|string $cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows
|
||||
*
|
||||
* @return int The number of rows in cellAddress
|
||||
* @return int|string The number of rows in cellAddress, or a string if arguments are invalid
|
||||
*/
|
||||
public static function ROWS($cellAddress = null)
|
||||
{
|
||||
|
@ -286,9 +286,11 @@ class LookupRef
|
|||
[$cellAddress1, $cellAddress2] = explode(':', $cellAddress);
|
||||
}
|
||||
|
||||
if ((!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress1, $matches)) ||
|
||||
(($cellAddress2 !== null) && (!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress2, $matches)))) {
|
||||
if (!preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $cellAddress1, $matches)) {
|
||||
if (
|
||||
(!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress1, $matches)) ||
|
||||
(($cellAddress2 !== null) && (!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress2, $matches)))
|
||||
) {
|
||||
if (!preg_match('/^' . Calculation::CALCULATION_REGEXP_DEFINEDNAME . '$/i', $cellAddress1, $matches)) {
|
||||
return Functions::REF();
|
||||
}
|
||||
|
||||
|
@ -485,10 +487,18 @@ class LookupRef
|
|||
return Functions::NA();
|
||||
}
|
||||
|
||||
if ($matchType == 1) {
|
||||
// If match_type is 1 the list has to be processed from last to first
|
||||
|
||||
$lookupArray = array_reverse($lookupArray);
|
||||
$keySet = array_reverse(array_keys($lookupArray));
|
||||
}
|
||||
|
||||
// Lookup_array should contain only number, text, or logical values, or empty (null) cells
|
||||
foreach ($lookupArray as $i => $lookupArrayValue) {
|
||||
// check the type of the value
|
||||
if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) &&
|
||||
if (
|
||||
(!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) &&
|
||||
(!is_bool($lookupArrayValue)) && ($lookupArrayValue !== null)
|
||||
) {
|
||||
return Functions::NA();
|
||||
|
@ -498,24 +508,17 @@ class LookupRef
|
|||
$lookupArray[$i] = StringHelper::strToLower($lookupArrayValue);
|
||||
}
|
||||
if (($lookupArrayValue === null) && (($matchType == 1) || ($matchType == -1))) {
|
||||
$lookupArray = array_slice($lookupArray, 0, $i - 1);
|
||||
unset($lookupArray[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($matchType == 1) {
|
||||
// If match_type is 1 the list has to be processed from last to first
|
||||
|
||||
$lookupArray = array_reverse($lookupArray);
|
||||
$keySet = array_reverse(array_keys($lookupArray));
|
||||
}
|
||||
|
||||
// **
|
||||
// find the match
|
||||
// **
|
||||
|
||||
if ($matchType === 0 || $matchType === 1) {
|
||||
foreach ($lookupArray as $i => $lookupArrayValue) {
|
||||
$typeMatch = gettype($lookupValue) === gettype($lookupArrayValue);
|
||||
$typeMatch = ((gettype($lookupValue) === gettype($lookupArrayValue)) || (is_numeric($lookupValue) && is_numeric($lookupArrayValue)));
|
||||
$exactTypeMatch = $typeMatch && $lookupArrayValue === $lookupValue;
|
||||
$nonOnlyNumericExactMatch = !$typeMatch && $lookupArrayValue === $lookupValue;
|
||||
$exactMatch = $exactTypeMatch || $nonOnlyNumericExactMatch;
|
||||
|
@ -750,18 +753,23 @@ class LookupRef
|
|||
$firstLower = StringHelper::strToLower($rowData[$firstColumn]);
|
||||
|
||||
// break if we have passed possible keys
|
||||
if ((is_numeric($lookup_value) && is_numeric($rowData[$firstColumn]) && ($rowData[$firstColumn] > $lookup_value)) ||
|
||||
(!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]) && ($firstLower > $lookupLower))) {
|
||||
if (
|
||||
(is_numeric($lookup_value) && is_numeric($rowData[$firstColumn]) && ($rowData[$firstColumn] > $lookup_value)) ||
|
||||
(!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]) && ($firstLower > $lookupLower))
|
||||
) {
|
||||
break;
|
||||
}
|
||||
// remember the last key, but only if datatypes match
|
||||
if ((is_numeric($lookup_value) && is_numeric($rowData[$firstColumn])) ||
|
||||
(!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]))) {
|
||||
if (
|
||||
(is_numeric($lookup_value) && is_numeric($rowData[$firstColumn])) ||
|
||||
(!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]))
|
||||
) {
|
||||
if ($not_exact_match) {
|
||||
$rowNumber = $rowKey;
|
||||
|
||||
continue;
|
||||
} elseif (($firstLower == $lookupLower)
|
||||
} elseif (
|
||||
($firstLower == $lookupLower)
|
||||
// Spreadsheets software returns first exact match,
|
||||
// we have sorted and we might have broken key orders
|
||||
// we want the first one (by its initial index)
|
||||
|
@ -807,7 +815,7 @@ class LookupRef
|
|||
return Functions::REF();
|
||||
}
|
||||
$f = array_keys($lookup_array);
|
||||
$firstRow = array_pop($f);
|
||||
$firstRow = reset($f);
|
||||
if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array))) {
|
||||
return Functions::REF();
|
||||
}
|
||||
|
@ -823,10 +831,12 @@ class LookupRef
|
|||
$lookupLower = StringHelper::strToLower($lookup_value);
|
||||
$rowDataLower = StringHelper::strToLower($rowData);
|
||||
|
||||
if ($not_exact_match && (
|
||||
if (
|
||||
$not_exact_match && (
|
||||
($bothNumeric && $rowData > $lookup_value) ||
|
||||
($bothNotNumeric && $rowDataLower > $lookupLower)
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -836,7 +846,8 @@ class LookupRef
|
|||
$rowNumber = $rowKey;
|
||||
|
||||
continue;
|
||||
} elseif ($rowDataLower === $lookupLower
|
||||
} elseif (
|
||||
$rowDataLower === $lookupLower
|
||||
&& ($rowNumber === null || $rowKey < $rowNumber)
|
||||
) {
|
||||
$rowNumber = $rowKey;
|
||||
|
|
|
@ -147,8 +147,10 @@ class MathTrig
|
|||
$xCoordinate = ($xCoordinate !== null) ? $xCoordinate : 0.0;
|
||||
$yCoordinate = ($yCoordinate !== null) ? $yCoordinate : 0.0;
|
||||
|
||||
if (((is_numeric($xCoordinate)) || (is_bool($xCoordinate))) &&
|
||||
((is_numeric($yCoordinate))) || (is_bool($yCoordinate))) {
|
||||
if (
|
||||
((is_numeric($xCoordinate)) || (is_bool($xCoordinate))) &&
|
||||
((is_numeric($yCoordinate))) || (is_bool($yCoordinate))
|
||||
) {
|
||||
$xCoordinate = (float) $xCoordinate;
|
||||
$yCoordinate = (float) $yCoordinate;
|
||||
|
||||
|
@ -224,8 +226,10 @@ class MathTrig
|
|||
$number = Functions::flattenSingleValue($number);
|
||||
$significance = Functions::flattenSingleValue($significance);
|
||||
|
||||
if (($significance === null) &&
|
||||
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)) {
|
||||
if (
|
||||
($significance === null) &&
|
||||
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)
|
||||
) {
|
||||
$significance = $number / abs($number);
|
||||
}
|
||||
|
||||
|
@ -331,8 +335,10 @@ class MathTrig
|
|||
return Functions::NAN();
|
||||
}
|
||||
$factLoop = floor($factVal);
|
||||
if ((Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) &&
|
||||
($factVal > $factLoop)) {
|
||||
if (
|
||||
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) &&
|
||||
($factVal > $factLoop)
|
||||
) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
|
@ -398,8 +404,10 @@ class MathTrig
|
|||
$number = Functions::flattenSingleValue($number);
|
||||
$significance = Functions::flattenSingleValue($significance);
|
||||
|
||||
if (($significance === null) &&
|
||||
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)) {
|
||||
if (
|
||||
($significance === null) &&
|
||||
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)
|
||||
) {
|
||||
$significance = $number / abs($number);
|
||||
}
|
||||
|
||||
|
@ -863,7 +871,7 @@ class MathTrig
|
|||
*
|
||||
* Returns the ratio of the factorial of a sum of values to the product of factorials.
|
||||
*
|
||||
* @param array of mixed Data Series
|
||||
* @param mixed[] $args An array of mixed values for the Data Series
|
||||
*
|
||||
* @return float|string The result, or a string containing an error
|
||||
*/
|
||||
|
@ -1141,7 +1149,7 @@ class MathTrig
|
|||
*
|
||||
* Returns the sum of a power series
|
||||
*
|
||||
* @param array of mixed Data Series
|
||||
* @param mixed[] $args An array of mixed values for the Data Series
|
||||
*
|
||||
* @return float|string The result, or a string containing an error
|
||||
*/
|
||||
|
@ -1265,21 +1273,22 @@ class MathTrig
|
|||
*
|
||||
* Returns a subtotal in a list or database.
|
||||
*
|
||||
* @param int the number 1 to 11 that specifies which function to
|
||||
* @param int $functionType
|
||||
* A number 1 to 11 that specifies which function to
|
||||
* use in calculating subtotals within a range
|
||||
* list
|
||||
* Numbers 101 to 111 shadow the functions of 1 to 11
|
||||
* but ignore any values in the range that are
|
||||
* in hidden rows or columns
|
||||
* @param array of mixed Data Series
|
||||
* @param mixed[] $args A mixed data series of values
|
||||
*
|
||||
* @return float|string
|
||||
*/
|
||||
public static function SUBTOTAL(...$args)
|
||||
public static function SUBTOTAL($functionType, ...$args)
|
||||
{
|
||||
$cellReference = array_pop($args);
|
||||
$aArgs = Functions::flattenArrayIndexed($args);
|
||||
$subtotal = array_shift($aArgs);
|
||||
$subtotal = Functions::flattenSingleValue($functionType);
|
||||
|
||||
// Calculate
|
||||
if ((is_numeric($subtotal)) && (!is_string($subtotal))) {
|
||||
|
@ -1381,8 +1390,10 @@ class MathTrig
|
|||
$testCondition = '=' . $arg . $condition;
|
||||
$sumValue = array_key_exists($key, $sumArgs) ? $sumArgs[$key] : 0;
|
||||
|
||||
if (is_numeric($sumValue) &&
|
||||
Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
|
||||
if (
|
||||
is_numeric($sumValue) &&
|
||||
Calculation::getInstance()->_calculateFormulaValue($testCondition)
|
||||
) {
|
||||
// Is it a value within our criteria and only numeric can be added to the result
|
||||
$returnValue += $sumValue;
|
||||
}
|
||||
|
@ -1532,8 +1543,10 @@ class MathTrig
|
|||
|
||||
$result = 0;
|
||||
for ($i = 0; $i < $count; ++$i) {
|
||||
if (((is_numeric($array1[$i])) && (!is_string($array1[$i]))) &&
|
||||
((is_numeric($array2[$i])) && (!is_string($array2[$i])))) {
|
||||
if (
|
||||
((is_numeric($array1[$i])) && (!is_string($array1[$i]))) &&
|
||||
((is_numeric($array2[$i])) && (!is_string($array2[$i])))
|
||||
) {
|
||||
$result += ($array1[$i] * $array1[$i]) - ($array2[$i] * $array2[$i]);
|
||||
}
|
||||
}
|
||||
|
@ -1557,8 +1570,10 @@ class MathTrig
|
|||
|
||||
$result = 0;
|
||||
for ($i = 0; $i < $count; ++$i) {
|
||||
if (((is_numeric($array1[$i])) && (!is_string($array1[$i]))) &&
|
||||
((is_numeric($array2[$i])) && (!is_string($array2[$i])))) {
|
||||
if (
|
||||
((is_numeric($array1[$i])) && (!is_string($array1[$i]))) &&
|
||||
((is_numeric($array2[$i])) && (!is_string($array2[$i])))
|
||||
) {
|
||||
$result += ($array1[$i] * $array1[$i]) + ($array2[$i] * $array2[$i]);
|
||||
}
|
||||
}
|
||||
|
@ -1582,8 +1597,10 @@ class MathTrig
|
|||
|
||||
$result = 0;
|
||||
for ($i = 0; $i < $count; ++$i) {
|
||||
if (((is_numeric($array1[$i])) && (!is_string($array1[$i]))) &&
|
||||
((is_numeric($array2[$i])) && (!is_string($array2[$i])))) {
|
||||
if (
|
||||
((is_numeric($array1[$i])) && (!is_string($array1[$i]))) &&
|
||||
((is_numeric($array2[$i])) && (!is_string($array2[$i])))
|
||||
) {
|
||||
$result += ($array1[$i] - $array2[$i]) * ($array1[$i] - $array2[$i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -530,9 +530,11 @@ class Statistical
|
|||
*/
|
||||
private static function testAcceptedBoolean($arg, $k)
|
||||
{
|
||||
if ((is_bool($arg)) &&
|
||||
if (
|
||||
(is_bool($arg)) &&
|
||||
((!Functions::isCellValue($k) && (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_EXCEL)) ||
|
||||
(Functions::getCompatibilityMode() === Functions::COMPATIBILITY_OPENOFFICE))) {
|
||||
(Functions::getCompatibilityMode() === Functions::COMPATIBILITY_OPENOFFICE))
|
||||
) {
|
||||
$arg = (int) $arg;
|
||||
}
|
||||
|
||||
|
@ -547,9 +549,11 @@ class Statistical
|
|||
*/
|
||||
private static function isAcceptedCountable($arg, $k)
|
||||
{
|
||||
if (((is_numeric($arg)) && (!is_string($arg))) ||
|
||||
if (
|
||||
((is_numeric($arg)) && (!is_string($arg))) ||
|
||||
((is_numeric($arg)) && (!Functions::isCellValue($k)) &&
|
||||
(Functions::getCompatibilityMode() !== Functions::COMPATIBILITY_GNUMERIC))) {
|
||||
(Functions::getCompatibilityMode() !== Functions::COMPATIBILITY_GNUMERIC))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -664,8 +668,10 @@ class Statistical
|
|||
$aCount = 0;
|
||||
// Loop through arguments
|
||||
foreach (Functions::flattenArrayIndexed($args) as $k => $arg) {
|
||||
if ((is_bool($arg)) &&
|
||||
(!Functions::isMatrixValue($k))) {
|
||||
if (
|
||||
(is_bool($arg)) &&
|
||||
(!Functions::isMatrixValue($k))
|
||||
) {
|
||||
} else {
|
||||
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) && ($arg != '')))) {
|
||||
if (is_bool($arg)) {
|
||||
|
@ -779,7 +785,7 @@ class Statistical
|
|||
/**
|
||||
* BETAINV.
|
||||
*
|
||||
* Returns the inverse of the beta distribution.
|
||||
* Returns the inverse of the Beta distribution.
|
||||
*
|
||||
* @param float $probability Probability at which you want to evaluate the distribution
|
||||
* @param float $alpha Parameter to the distribution
|
||||
|
@ -1414,9 +1420,11 @@ class Statistical
|
|||
$aCount = -1;
|
||||
foreach ($aArgs as $k => $arg) {
|
||||
// Is it a numeric value?
|
||||
if ((is_bool($arg)) &&
|
||||
if (
|
||||
(is_bool($arg)) &&
|
||||
((!Functions::isCellValue($k)) ||
|
||||
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) {
|
||||
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))
|
||||
) {
|
||||
$arg = (int) $arg;
|
||||
}
|
||||
if ((is_numeric($arg)) && (!is_string($arg))) {
|
||||
|
@ -1437,7 +1445,7 @@ class Statistical
|
|||
return $returnValue;
|
||||
}
|
||||
|
||||
return self::NA();
|
||||
return Functions::NA();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1475,6 +1483,62 @@ class Statistical
|
|||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
private static function betaFunction($a, $b)
|
||||
{
|
||||
return (self::gamma($a) * self::gamma($b)) / self::gamma($a + $b);
|
||||
}
|
||||
|
||||
private static function regularizedIncompleteBeta($value, $a, $b)
|
||||
{
|
||||
return self::incompleteBeta($value, $a, $b) / self::betaFunction($a, $b);
|
||||
}
|
||||
|
||||
/**
|
||||
* F.DIST.
|
||||
*
|
||||
* Returns the F probability distribution.
|
||||
* You can use this function to determine whether two data sets have different degrees of diversity.
|
||||
* For example, you can examine the test scores of men and women entering high school, and determine
|
||||
* if the variability in the females is different from that found in the males.
|
||||
*
|
||||
* @param float $value Value of the function
|
||||
* @param int $u The numerator degrees of freedom
|
||||
* @param int $v The denominator degrees of freedom
|
||||
* @param bool $cumulative If cumulative is TRUE, F.DIST returns the cumulative distribution function;
|
||||
* if FALSE, it returns the probability density function.
|
||||
*
|
||||
* @return float|string
|
||||
*/
|
||||
public static function FDIST2($value, $u, $v, $cumulative)
|
||||
{
|
||||
$value = Functions::flattenSingleValue($value);
|
||||
$u = Functions::flattenSingleValue($u);
|
||||
$v = Functions::flattenSingleValue($v);
|
||||
$cumulative = Functions::flattenSingleValue($cumulative);
|
||||
|
||||
if (is_numeric($value) && is_numeric($u) && is_numeric($v)) {
|
||||
if ($value < 0 || $u < 1 || $v < 1) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
$cumulative = (bool) $cumulative;
|
||||
$u = (int) $u;
|
||||
$v = (int) $v;
|
||||
|
||||
if ($cumulative) {
|
||||
$adjustedValue = ($u * $value) / ($u * $value + $v);
|
||||
|
||||
return self::incompleteBeta($adjustedValue, $u / 2, $v / 2);
|
||||
}
|
||||
|
||||
return (self::gamma(($v + $u) / 2) / (self::gamma($u / 2) * self::gamma($v / 2))) *
|
||||
(($u / $v) ** ($u / 2)) *
|
||||
(($value ** (($u - 2) / 2)) / ((1 + ($u / $v) * $value) ** (($u + $v) / 2)));
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
/**
|
||||
* FISHER.
|
||||
*
|
||||
|
@ -1556,6 +1620,27 @@ class Statistical
|
|||
return $bestFitLinear->getValueOfYForX($xValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* GAMMA.
|
||||
*
|
||||
* Return the gamma function value.
|
||||
*
|
||||
* @param float $value
|
||||
*
|
||||
* @return float|string The result, or a string containing an error
|
||||
*/
|
||||
public static function GAMMAFunction($value)
|
||||
{
|
||||
$value = Functions::flattenSingleValue($value);
|
||||
if (!is_numeric($value)) {
|
||||
return Functions::VALUE();
|
||||
} elseif ((((int) $value) == ((float) $value)) && $value <= 0.0) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
return self::gamma($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* GAMMADIST.
|
||||
*
|
||||
|
@ -1593,7 +1678,7 @@ class Statistical
|
|||
/**
|
||||
* GAMMAINV.
|
||||
*
|
||||
* Returns the inverse of the beta distribution.
|
||||
* Returns the inverse of the Gamma distribution.
|
||||
*
|
||||
* @param float $probability Probability at which you want to evaluate the distribution
|
||||
* @param float $alpha Parameter to the distribution
|
||||
|
@ -1616,7 +1701,6 @@ class Statistical
|
|||
$xHi = $alpha * $beta * 5;
|
||||
|
||||
$x = $xNew = 1;
|
||||
$error = $pdf = 0;
|
||||
$dx = 1024;
|
||||
$i = 0;
|
||||
|
||||
|
@ -1677,6 +1761,26 @@ class Statistical
|
|||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
/**
|
||||
* GAUSS.
|
||||
*
|
||||
* Calculates the probability that a member of a standard normal population will fall between
|
||||
* the mean and z standard deviations from the mean.
|
||||
*
|
||||
* @param float $value
|
||||
*
|
||||
* @return float|string The result, or a string containing an error
|
||||
*/
|
||||
public static function GAUSS($value)
|
||||
{
|
||||
$value = Functions::flattenSingleValue($value);
|
||||
if (!is_numeric($value)) {
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
return self::NORMDIST($value, 0, 1, true) - 0.5;
|
||||
}
|
||||
|
||||
/**
|
||||
* GEOMEAN.
|
||||
*
|
||||
|
@ -1796,12 +1900,17 @@ class Statistical
|
|||
*/
|
||||
public static function HYPGEOMDIST($sampleSuccesses, $sampleNumber, $populationSuccesses, $populationNumber)
|
||||
{
|
||||
$sampleSuccesses = floor(Functions::flattenSingleValue($sampleSuccesses));
|
||||
$sampleNumber = floor(Functions::flattenSingleValue($sampleNumber));
|
||||
$populationSuccesses = floor(Functions::flattenSingleValue($populationSuccesses));
|
||||
$populationNumber = floor(Functions::flattenSingleValue($populationNumber));
|
||||
$sampleSuccesses = Functions::flattenSingleValue($sampleSuccesses);
|
||||
$sampleNumber = Functions::flattenSingleValue($sampleNumber);
|
||||
$populationSuccesses = Functions::flattenSingleValue($populationSuccesses);
|
||||
$populationNumber = Functions::flattenSingleValue($populationNumber);
|
||||
|
||||
if ((is_numeric($sampleSuccesses)) && (is_numeric($sampleNumber)) && (is_numeric($populationSuccesses)) && (is_numeric($populationNumber))) {
|
||||
$sampleSuccesses = floor($sampleSuccesses);
|
||||
$sampleNumber = floor($sampleNumber);
|
||||
$populationSuccesses = floor($populationSuccesses);
|
||||
$populationNumber = floor($populationNumber);
|
||||
|
||||
if (($sampleSuccesses < 0) || ($sampleSuccesses > $sampleNumber) || ($sampleSuccesses > $populationSuccesses)) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
@ -1871,8 +1980,10 @@ class Statistical
|
|||
$count = $summer = 0;
|
||||
// Loop through arguments
|
||||
foreach ($aArgs as $k => $arg) {
|
||||
if ((is_bool($arg)) &&
|
||||
(!Functions::isMatrixValue($k))) {
|
||||
if (
|
||||
(is_bool($arg)) &&
|
||||
(!Functions::isMatrixValue($k))
|
||||
) {
|
||||
} else {
|
||||
// Is it a numeric value?
|
||||
if ((is_numeric($arg)) && (!is_string($arg))) {
|
||||
|
@ -1907,11 +2018,12 @@ class Statistical
|
|||
public static function LARGE(...$args)
|
||||
{
|
||||
$aArgs = Functions::flattenArray($args);
|
||||
|
||||
// Calculate
|
||||
$entry = floor(array_pop($aArgs));
|
||||
$entry = array_pop($aArgs);
|
||||
|
||||
if ((is_numeric($entry)) && (!is_string($entry))) {
|
||||
$entry = (int) floor($entry);
|
||||
|
||||
// Calculate
|
||||
$mArgs = [];
|
||||
foreach ($aArgs as $arg) {
|
||||
// Is it a numeric value?
|
||||
|
@ -1920,7 +2032,7 @@ class Statistical
|
|||
}
|
||||
}
|
||||
$count = self::COUNT($mArgs);
|
||||
$entry = floor(--$entry);
|
||||
--$entry;
|
||||
if (($entry < 0) || ($entry >= $count) || ($count == 0)) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
@ -2117,6 +2229,42 @@ class Statistical
|
|||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
/**
|
||||
* LOGNORM.DIST.
|
||||
*
|
||||
* Returns the lognormal distribution of x, where ln(x) is normally distributed
|
||||
* with parameters mean and standard_dev.
|
||||
*
|
||||
* @param float $value
|
||||
* @param float $mean
|
||||
* @param float $stdDev
|
||||
* @param bool $cumulative
|
||||
*
|
||||
* @return float|string The result, or a string containing an error
|
||||
*/
|
||||
public static function LOGNORMDIST2($value, $mean, $stdDev, $cumulative = false)
|
||||
{
|
||||
$value = Functions::flattenSingleValue($value);
|
||||
$mean = Functions::flattenSingleValue($mean);
|
||||
$stdDev = Functions::flattenSingleValue($stdDev);
|
||||
$cumulative = (bool) Functions::flattenSingleValue($cumulative);
|
||||
|
||||
if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
|
||||
if (($value <= 0) || ($stdDev <= 0)) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
||||
if ($cumulative === true) {
|
||||
return self::NORMSDIST2((log($value) - $mean) / $stdDev, true);
|
||||
}
|
||||
|
||||
return (1 / (sqrt(2 * M_PI) * $stdDev * $value)) *
|
||||
exp(0 - ((log($value) - $mean) ** 2 / (2 * $stdDev ** 2)));
|
||||
}
|
||||
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
/**
|
||||
* MAX.
|
||||
*
|
||||
|
@ -2623,10 +2771,36 @@ class Statistical
|
|||
public static function NORMSDIST($value)
|
||||
{
|
||||
$value = Functions::flattenSingleValue($value);
|
||||
if (!is_numeric($value)) {
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
return self::NORMDIST($value, 0, 1, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* NORM.S.DIST.
|
||||
*
|
||||
* Returns the standard normal cumulative distribution function. The distribution has
|
||||
* a mean of 0 (zero) and a standard deviation of one. Use this function in place of a
|
||||
* table of standard normal curve areas.
|
||||
*
|
||||
* @param float $value
|
||||
* @param bool $cumulative
|
||||
*
|
||||
* @return float|string The result, or a string containing an error
|
||||
*/
|
||||
public static function NORMSDIST2($value, $cumulative)
|
||||
{
|
||||
$value = Functions::flattenSingleValue($value);
|
||||
if (!is_numeric($value)) {
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$cumulative = (bool) Functions::flattenSingleValue($cumulative);
|
||||
|
||||
return self::NORMDIST($value, 0, 1, $cumulative);
|
||||
}
|
||||
|
||||
/**
|
||||
* NORMSINV.
|
||||
*
|
||||
|
@ -2699,7 +2873,7 @@ class Statistical
|
|||
* @param int $value the number whose rank you want to find
|
||||
* @param int $significance the number of significant digits for the returned percentage value
|
||||
*
|
||||
* @return float
|
||||
* @return float|string (string if result is an error)
|
||||
*/
|
||||
public static function PERCENTRANK($valueSet, $value, $significance = 3)
|
||||
{
|
||||
|
@ -2925,8 +3099,10 @@ class Statistical
|
|||
$count = $summer = 0;
|
||||
// Loop through arguments
|
||||
foreach ($aArgs as $k => $arg) {
|
||||
if ((is_bool($arg)) &&
|
||||
(!Functions::isMatrixValue($k))) {
|
||||
if (
|
||||
(is_bool($arg)) &&
|
||||
(!Functions::isMatrixValue($k))
|
||||
) {
|
||||
} else {
|
||||
// Is it a numeric value?
|
||||
if ((is_numeric($arg)) && (!is_string($arg))) {
|
||||
|
@ -2993,6 +3169,8 @@ class Statistical
|
|||
$entry = array_pop($aArgs);
|
||||
|
||||
if ((is_numeric($entry)) && (!is_string($entry))) {
|
||||
$entry = (int) floor($entry);
|
||||
|
||||
$mArgs = [];
|
||||
foreach ($aArgs as $arg) {
|
||||
// Is it a numeric value?
|
||||
|
@ -3001,7 +3179,7 @@ class Statistical
|
|||
}
|
||||
}
|
||||
$count = self::COUNT($mArgs);
|
||||
$entry = floor(--$entry);
|
||||
--$entry;
|
||||
if (($entry < 0) || ($entry >= $count) || ($count == 0)) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
|
@ -3065,8 +3243,10 @@ class Statistical
|
|||
if ($aMean !== null) {
|
||||
$aCount = -1;
|
||||
foreach ($aArgs as $k => $arg) {
|
||||
if ((is_bool($arg)) &&
|
||||
((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) {
|
||||
if (
|
||||
(is_bool($arg)) &&
|
||||
((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))
|
||||
) {
|
||||
$arg = (int) $arg;
|
||||
}
|
||||
// Is it a numeric value?
|
||||
|
@ -3111,8 +3291,10 @@ class Statistical
|
|||
if ($aMean !== null) {
|
||||
$aCount = -1;
|
||||
foreach ($aArgs as $k => $arg) {
|
||||
if ((is_bool($arg)) &&
|
||||
(!Functions::isMatrixValue($k))) {
|
||||
if (
|
||||
(is_bool($arg)) &&
|
||||
(!Functions::isMatrixValue($k))
|
||||
) {
|
||||
} else {
|
||||
// Is it a numeric value?
|
||||
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) {
|
||||
|
@ -3161,8 +3343,10 @@ class Statistical
|
|||
if ($aMean !== null) {
|
||||
$aCount = 0;
|
||||
foreach ($aArgs as $k => $arg) {
|
||||
if ((is_bool($arg)) &&
|
||||
((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) {
|
||||
if (
|
||||
(is_bool($arg)) &&
|
||||
((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))
|
||||
) {
|
||||
$arg = (int) $arg;
|
||||
}
|
||||
// Is it a numeric value?
|
||||
|
@ -3206,8 +3390,10 @@ class Statistical
|
|||
if ($aMean !== null) {
|
||||
$aCount = 0;
|
||||
foreach ($aArgs as $k => $arg) {
|
||||
if ((is_bool($arg)) &&
|
||||
(!Functions::isMatrixValue($k))) {
|
||||
if (
|
||||
(is_bool($arg)) &&
|
||||
(!Functions::isMatrixValue($k))
|
||||
) {
|
||||
} else {
|
||||
// Is it a numeric value?
|
||||
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) {
|
||||
|
@ -3297,7 +3483,6 @@ class Statistical
|
|||
$ttheta = atan2($value, sqrt($tterm));
|
||||
$tc = cos($ttheta);
|
||||
$ts = sin($ttheta);
|
||||
$tsum = 0;
|
||||
|
||||
if (($degrees % 2) == 1) {
|
||||
$ti = 3;
|
||||
|
@ -3473,7 +3658,7 @@ class Statistical
|
|||
*
|
||||
* @param mixed ...$args Data values
|
||||
*
|
||||
* @return float
|
||||
* @return float|string (string if result is an error)
|
||||
*/
|
||||
public static function VARFunc(...$args)
|
||||
{
|
||||
|
@ -3515,7 +3700,7 @@ class Statistical
|
|||
*
|
||||
* @param mixed ...$args Data values
|
||||
*
|
||||
* @return float
|
||||
* @return float|string (string if result is an error)
|
||||
*/
|
||||
public static function VARA(...$args)
|
||||
{
|
||||
|
@ -3527,11 +3712,15 @@ class Statistical
|
|||
$aArgs = Functions::flattenArrayIndexed($args);
|
||||
$aCount = 0;
|
||||
foreach ($aArgs as $k => $arg) {
|
||||
if ((is_string($arg)) &&
|
||||
(Functions::isValue($k))) {
|
||||
if (
|
||||
(is_string($arg)) &&
|
||||
(Functions::isValue($k))
|
||||
) {
|
||||
return Functions::VALUE();
|
||||
} elseif ((is_string($arg)) &&
|
||||
(!Functions::isMatrixValue($k))) {
|
||||
} elseif (
|
||||
(is_string($arg)) &&
|
||||
(!Functions::isMatrixValue($k))
|
||||
) {
|
||||
} else {
|
||||
// Is it a numeric value?
|
||||
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) {
|
||||
|
@ -3566,7 +3755,7 @@ class Statistical
|
|||
*
|
||||
* @param mixed ...$args Data values
|
||||
*
|
||||
* @return float
|
||||
* @return float|string (string if result is an error)
|
||||
*/
|
||||
public static function VARP(...$args)
|
||||
{
|
||||
|
@ -3609,7 +3798,7 @@ class Statistical
|
|||
*
|
||||
* @param mixed ...$args Data values
|
||||
*
|
||||
* @return float
|
||||
* @return float|string (string if result is an error)
|
||||
*/
|
||||
public static function VARPA(...$args)
|
||||
{
|
||||
|
@ -3621,11 +3810,15 @@ class Statistical
|
|||
$aArgs = Functions::flattenArrayIndexed($args);
|
||||
$aCount = 0;
|
||||
foreach ($aArgs as $k => $arg) {
|
||||
if ((is_string($arg)) &&
|
||||
(Functions::isValue($k))) {
|
||||
if (
|
||||
(is_string($arg)) &&
|
||||
(Functions::isValue($k))
|
||||
) {
|
||||
return Functions::VALUE();
|
||||
} elseif ((is_string($arg)) &&
|
||||
(!Functions::isMatrixValue($k))) {
|
||||
} elseif (
|
||||
(is_string($arg)) &&
|
||||
(!Functions::isMatrixValue($k))
|
||||
) {
|
||||
} else {
|
||||
// Is it a numeric value?
|
||||
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) {
|
||||
|
@ -3661,7 +3854,7 @@ class Statistical
|
|||
* @param float $beta Beta Parameter
|
||||
* @param bool $cumulative
|
||||
*
|
||||
* @return float
|
||||
* @return float|string (string if result is an error)
|
||||
*/
|
||||
public static function WEIBULL($value, $alpha, $beta, $cumulative)
|
||||
{
|
||||
|
@ -3695,7 +3888,7 @@ class Statistical
|
|||
* @param float $m0 Alpha Parameter
|
||||
* @param float $sigma Beta Parameter
|
||||
*
|
||||
* @return float|string
|
||||
* @return float|string (string if result is an error)
|
||||
*/
|
||||
public static function ZTEST($dataSet, $m0, $sigma = null)
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation;
|
||||
|
||||
use DateTimeInterface;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
@ -98,7 +99,7 @@ class TextData
|
|||
*
|
||||
* @param string $characters Value
|
||||
*
|
||||
* @return int
|
||||
* @return int|string A string if arguments are invalid
|
||||
*/
|
||||
public static function ASCIICODE($characters)
|
||||
{
|
||||
|
@ -543,7 +544,7 @@ class TextData
|
|||
*
|
||||
* @param mixed $value Value to check
|
||||
*
|
||||
* @return bool
|
||||
* @return DateTimeInterface|float|int|string A string if arguments are invalid
|
||||
*/
|
||||
public static function VALUE($value = '')
|
||||
{
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
|
||||
class Web
|
||||
{
|
||||
/**
|
||||
* WEBSERVICE.
|
||||
*
|
||||
* Returns data from a web service on the Internet or Intranet.
|
||||
*
|
||||
* Excel Function:
|
||||
* Webservice(url)
|
||||
*
|
||||
* @return string the output resulting from a call to the webservice
|
||||
*/
|
||||
public static function WEBSERVICE(string $url)
|
||||
{
|
||||
$url = trim($url);
|
||||
if (strlen($url) > 2048) {
|
||||
return Functions::VALUE(); // Invalid URL length
|
||||
}
|
||||
|
||||
if (!preg_match('/^http[s]?:\/\//', $url)) {
|
||||
return Functions::VALUE(); // Invalid protocol
|
||||
}
|
||||
|
||||
// Get results from the the webservice
|
||||
$client = Settings::getHttpClient();
|
||||
$requestFactory = Settings::getRequestFactory();
|
||||
$request = $requestFactory->createRequest('GET', $url);
|
||||
|
||||
try {
|
||||
$response = $client->sendRequest($request);
|
||||
} catch (ClientExceptionInterface $e) {
|
||||
return Functions::VALUE(); // cURL error
|
||||
}
|
||||
|
||||
if ($response->getStatusCode() != 200) {
|
||||
return Functions::VALUE(); // cURL error
|
||||
}
|
||||
|
||||
$output = $response->getBody()->getContents();
|
||||
if (strlen($output) > 32767) {
|
||||
return Functions::VALUE(); // Output not a string or too long
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
|
@ -163,6 +163,7 @@ HYPERLINK
|
|||
HYPGEOMDIST
|
||||
IF
|
||||
IFERROR
|
||||
IFS
|
||||
IMABS
|
||||
IMAGINARY
|
||||
IMARGUMENT
|
||||
|
|
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Cell;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
|
||||
class AddressHelper
|
||||
{
|
||||
/**
|
||||
* Converts an R1C1 format cell address to an A1 format cell address.
|
||||
*/
|
||||
public static function convertToA1(
|
||||
string $address,
|
||||
int $currentRowNumber = 1,
|
||||
int $currentColumnNumber = 1
|
||||
): string {
|
||||
$validityCheck = preg_match('/^(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))$/i', $address, $cellReference);
|
||||
|
||||
if ($validityCheck === 0) {
|
||||
throw new Exception('Invalid R1C1-format Cell Reference');
|
||||
}
|
||||
|
||||
$rowReference = $cellReference[2];
|
||||
// Empty R reference is the current row
|
||||
if ($rowReference === '') {
|
||||
$rowReference = (string) $currentRowNumber;
|
||||
}
|
||||
// Bracketed R references are relative to the current row
|
||||
if ($rowReference[0] === '[') {
|
||||
$rowReference = $currentRowNumber + trim($rowReference, '[]');
|
||||
}
|
||||
$columnReference = $cellReference[4];
|
||||
// Empty C reference is the current column
|
||||
if ($columnReference === '') {
|
||||
$columnReference = (string) $currentColumnNumber;
|
||||
}
|
||||
// Bracketed C references are relative to the current column
|
||||
if (is_string($columnReference) && $columnReference[0] === '[') {
|
||||
$columnReference = $currentColumnNumber + trim($columnReference, '[]');
|
||||
}
|
||||
|
||||
if ($columnReference <= 0 || $rowReference <= 0) {
|
||||
throw new Exception('Invalid R1C1-format Cell Reference, Value out of range');
|
||||
}
|
||||
$A1CellReference = Coordinate::stringFromColumnIndex($columnReference) . $rowReference;
|
||||
|
||||
return $A1CellReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a formula that uses R1C1 format cell address to an A1 format cell address.
|
||||
*/
|
||||
public static function convertFormulaToA1(
|
||||
string $formula,
|
||||
int $currentRowNumber = 1,
|
||||
int $currentColumnNumber = 1
|
||||
): string {
|
||||
if (substr($formula, 0, 3) == 'of:') {
|
||||
$formula = substr($formula, 3);
|
||||
$temp = explode('"', $formula);
|
||||
$key = false;
|
||||
foreach ($temp as &$value) {
|
||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||
if ($key = !$key) {
|
||||
$value = str_replace(['[.', '.', ']'], '', $value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Convert R1C1 style references to A1 style references (but only when not quoted)
|
||||
$temp = explode('"', $formula);
|
||||
$key = false;
|
||||
foreach ($temp as &$value) {
|
||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||
if ($key = !$key) {
|
||||
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences, PREG_SET_ORDER + PREG_OFFSET_CAPTURE);
|
||||
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
|
||||
// through the formula from left to right. Reversing means that we work right to left.through
|
||||
// the formula
|
||||
$cellReferences = array_reverse($cellReferences);
|
||||
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
|
||||
// then modify the formula to use that new reference
|
||||
foreach ($cellReferences as $cellReference) {
|
||||
$A1CellReference = self::convertToA1($cellReference[0][0], $currentRowNumber, $currentColumnNumber);
|
||||
$value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
// Then rebuild the formula string
|
||||
$formula = implode('"', $temp);
|
||||
|
||||
return $formula;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an A1 format cell address to an R1C1 format cell address.
|
||||
* If $currentRowNumber or $currentColumnNumber are provided, then the R1C1 address will be formatted as a relative address.
|
||||
*/
|
||||
public static function convertToR1C1(
|
||||
string $address,
|
||||
?int $currentRowNumber = null,
|
||||
?int $currentColumnNumber = null
|
||||
): string {
|
||||
$validityCheck = preg_match('/^\$?([A-Z]{1,3})\$?(\d{1,7})$/i', $address, $cellReference);
|
||||
|
||||
if ($validityCheck === 0) {
|
||||
throw new Exception('Invalid A1-format Cell Reference');
|
||||
}
|
||||
|
||||
$columnId = Coordinate::columnIndexFromString($cellReference[1]);
|
||||
$rowId = (int) $cellReference[2];
|
||||
|
||||
if ($currentRowNumber !== null) {
|
||||
if ($rowId === $currentRowNumber) {
|
||||
$rowId = '';
|
||||
} else {
|
||||
$rowId = '[' . ($rowId - $currentRowNumber) . ']';
|
||||
}
|
||||
}
|
||||
|
||||
if ($currentColumnNumber !== null) {
|
||||
if ($columnId === $currentColumnNumber) {
|
||||
$columnId = '';
|
||||
} else {
|
||||
$columnId = '[' . ($columnId - $currentColumnNumber) . ']';
|
||||
}
|
||||
}
|
||||
|
||||
$R1C1Address = "R{$rowId}C{$columnId}";
|
||||
|
||||
return $R1C1Address;
|
||||
}
|
||||
}
|
|
@ -251,9 +251,11 @@ class Cell
|
|||
{
|
||||
if ($this->dataType == DataType::TYPE_FORMULA) {
|
||||
try {
|
||||
$index = $this->getWorksheet()->getParent()->getActiveSheetIndex();
|
||||
$result = Calculation::getInstance(
|
||||
$this->getWorksheet()->getParent()
|
||||
)->calculateCellValue($this, $resetLog);
|
||||
$this->getWorksheet()->getParent()->setActiveSheetIndex($index);
|
||||
// We don't yet handle array returns
|
||||
if (is_array($result)) {
|
||||
while (is_array($result)) {
|
||||
|
@ -263,6 +265,8 @@ class Cell
|
|||
} catch (Exception $ex) {
|
||||
if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->calculatedValue !== null)) {
|
||||
return $this->calculatedValue; // Fallback for calculations referencing external files.
|
||||
} elseif (strpos($ex->getMessage(), 'undefined name') !== false) {
|
||||
return \PhpOffice\PhpSpreadsheet\Calculation\Functions::NAME();
|
||||
}
|
||||
|
||||
throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(
|
||||
|
|
|
@ -312,32 +312,59 @@ abstract class Coordinate
|
|||
/**
|
||||
* Extract all cell references in range, which may be comprised of multiple cell ranges.
|
||||
*
|
||||
* @param string $pRange Range (e.g. A1 or A1:C10 or A1:E10 A20:E25)
|
||||
* @param string $cellRange Range: e.g. 'A1' or 'A1:C10' or 'A1:E10,A20:E25' or 'A1:E5 C3:G7' or 'A1:C1,A3:C3 B1:C3'
|
||||
*
|
||||
* @return array Array containing single cell references
|
||||
*/
|
||||
public static function extractAllCellReferencesInRange($pRange)
|
||||
public static function extractAllCellReferencesInRange($cellRange): array
|
||||
{
|
||||
$returnValue = [];
|
||||
[$ranges, $operators] = self::getCellBlocksFromRangeString($cellRange);
|
||||
|
||||
// Explode spaces
|
||||
$cellBlocks = self::getCellBlocksFromRangeString($pRange);
|
||||
foreach ($cellBlocks as $cellBlock) {
|
||||
$returnValue = array_merge($returnValue, self::getReferencesForCellBlock($cellBlock));
|
||||
$cells = [];
|
||||
foreach ($ranges as $range) {
|
||||
$cells[] = self::getReferencesForCellBlock($range);
|
||||
}
|
||||
|
||||
$cells = self::processRangeSetOperators($operators, $cells);
|
||||
|
||||
if (empty($cells)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$cellList = array_merge(...$cells);
|
||||
$cellList = self::sortCellReferenceArray($cellList);
|
||||
|
||||
return $cellList;
|
||||
}
|
||||
|
||||
private static function processRangeSetOperators(array $operators, array $cells): array
|
||||
{
|
||||
for ($offset = 0; $offset < count($operators); ++$offset) {
|
||||
$operator = $operators[$offset];
|
||||
if ($operator !== ' ') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$cells[$offset] = array_intersect($cells[$offset], $cells[$offset + 1]);
|
||||
unset($operators[$offset], $cells[$offset + 1]);
|
||||
$operators = array_values($operators);
|
||||
$cells = array_values($cells);
|
||||
--$offset;
|
||||
}
|
||||
|
||||
return $cells;
|
||||
}
|
||||
|
||||
private static function sortCellReferenceArray(array $cellList): array
|
||||
{
|
||||
// Sort the result by column and row
|
||||
$sortKeys = [];
|
||||
foreach (array_unique($returnValue) as $coord) {
|
||||
$column = '';
|
||||
$row = 0;
|
||||
|
||||
sscanf($coord, '%[A-Z]%d', $column, $row);
|
||||
foreach ($cellList as $coord) {
|
||||
[$column, $row] = sscanf($coord, '%[A-Z]%d');
|
||||
$sortKeys[sprintf('%3s%09d', $column, $row)] = $coord;
|
||||
}
|
||||
ksort($sortKeys);
|
||||
|
||||
// Return value
|
||||
return array_values($sortKeys);
|
||||
}
|
||||
|
||||
|
@ -482,15 +509,25 @@ abstract class Coordinate
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the individual cell blocks from a range string, splitting by space and removing any $ characters.
|
||||
* Get the individual cell blocks from a range string, removing any $ characters.
|
||||
* then splitting by operators and returning an array with ranges and operators.
|
||||
*
|
||||
* @param string $pRange
|
||||
* @param string $rangeString
|
||||
*
|
||||
* @return string[]
|
||||
* @return array[]
|
||||
*/
|
||||
private static function getCellBlocksFromRangeString($pRange)
|
||||
private static function getCellBlocksFromRangeString($rangeString)
|
||||
{
|
||||
return explode(' ', str_replace('$', '', strtoupper($pRange)));
|
||||
$rangeString = str_replace('$', '', strtoupper($rangeString));
|
||||
|
||||
// split range sets on intersection (space) or union (,) operators
|
||||
$tokens = preg_split('/([ ,])/', $rangeString, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
// separate the range sets and the operators into arrays
|
||||
$split = array_chunk($tokens, 2);
|
||||
$ranges = array_column($split, 0);
|
||||
$operators = array_column($split, 1);
|
||||
|
||||
return [$ranges, $operators];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,8 +21,6 @@ use ScatterPlot;
|
|||
use Spline;
|
||||
use StockPlot;
|
||||
|
||||
require_once __DIR__ . '/Polyfill.php';
|
||||
|
||||
class JpGraph implements IRenderer
|
||||
{
|
||||
private static $width = 640;
|
||||
|
@ -219,9 +217,11 @@ class JpGraph implements IRenderer
|
|||
break;
|
||||
case 't':
|
||||
$this->graph->legend->SetPos(0.5, 0.01, 'center', 'top'); // top
|
||||
|
||||
break;
|
||||
case 'b':
|
||||
$this->graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); // bottom
|
||||
|
||||
break;
|
||||
default:
|
||||
$this->graph->legend->SetPos(0.01, 0.01, 'right', 'top'); // top-right
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
// This is a dirty workaround to output JpGraph charts even when antialiasing is not available
|
||||
if (!function_exists('imageantialias')) {
|
||||
function imageantialias(...$args): void
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
}
|
|
@ -0,0 +1,263 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
abstract class DefinedName
|
||||
{
|
||||
protected const REGEXP_IDENTIFY_FORMULA = '[^_\p{N}\p{L}:, \$\'!]';
|
||||
|
||||
/**
|
||||
* Name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* Worksheet on which the defined name can be resolved.
|
||||
*
|
||||
* @var Worksheet
|
||||
*/
|
||||
protected $worksheet;
|
||||
|
||||
/**
|
||||
* Value of the named object.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
/**
|
||||
* Is the defined named local? (i.e. can only be used on $this->worksheet).
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $localOnly;
|
||||
|
||||
/**
|
||||
* Scope.
|
||||
*
|
||||
* @var Worksheet
|
||||
*/
|
||||
protected $scope;
|
||||
|
||||
/**
|
||||
* Whether this is a named range or a named formula.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $isFormula;
|
||||
|
||||
/**
|
||||
* Create a new Defined Name.
|
||||
*/
|
||||
public function __construct(
|
||||
string $name,
|
||||
?Worksheet $worksheet = null,
|
||||
?string $value = null,
|
||||
bool $localOnly = false,
|
||||
?Worksheet $scope = null
|
||||
) {
|
||||
if ($worksheet === null) {
|
||||
$worksheet = $scope;
|
||||
}
|
||||
|
||||
// Set local members
|
||||
$this->name = $name;
|
||||
$this->worksheet = $worksheet;
|
||||
$this->value = (string) $value;
|
||||
$this->localOnly = $localOnly;
|
||||
// If local only, then the scope will be set to worksheet unless a scope is explicitly set
|
||||
$this->scope = ($localOnly === true) ? (($scope === null) ? $worksheet : $scope) : null;
|
||||
// If the range string contains characters that aren't associated with the range definition (A-Z,1-9
|
||||
// for cell references, and $, or the range operators (colon comma or space), quotes and ! for
|
||||
// worksheet names
|
||||
// then this is treated as a named formula, and not a named range
|
||||
$this->isFormula = self::testIfFormula($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new defined name, either a range or a formula.
|
||||
*/
|
||||
public static function createInstance(
|
||||
string $name,
|
||||
?Worksheet $worksheet = null,
|
||||
?string $value = null,
|
||||
bool $localOnly = false,
|
||||
?Worksheet $scope = null
|
||||
): self {
|
||||
$value = (string) $value;
|
||||
$isFormula = self::testIfFormula($value);
|
||||
if ($isFormula) {
|
||||
return new NamedFormula($name, $worksheet, $value, $localOnly, $scope);
|
||||
}
|
||||
|
||||
return new NamedRange($name, $worksheet, $value, $localOnly, $scope);
|
||||
}
|
||||
|
||||
public static function testIfFormula(string $value): bool
|
||||
{
|
||||
if (substr($value, 0, 1) === '=') {
|
||||
$value = substr($value, 1);
|
||||
}
|
||||
|
||||
if (is_numeric($value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$segMatcher = false;
|
||||
foreach (explode("'", $value) as $subVal) {
|
||||
// Only test in alternate array entries (the non-quoted blocks)
|
||||
if (
|
||||
($segMatcher = !$segMatcher) &&
|
||||
(preg_match('/' . self::REGEXP_IDENTIFY_FORMULA . '/miu', $subVal))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name.
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name.
|
||||
*/
|
||||
public function setName(string $name): self
|
||||
{
|
||||
if (!empty($name)) {
|
||||
// Old title
|
||||
$oldTitle = $this->name;
|
||||
|
||||
// Re-attach
|
||||
if ($this->worksheet !== null) {
|
||||
$this->worksheet->getParent()->removeNamedRange($this->name, $this->worksheet);
|
||||
}
|
||||
$this->name = $name;
|
||||
|
||||
if ($this->worksheet !== null) {
|
||||
$this->worksheet->getParent()->addNamedRange($this);
|
||||
}
|
||||
|
||||
// New title
|
||||
$newTitle = $this->name;
|
||||
ReferenceHelper::getInstance()->updateNamedFormulas($this->worksheet->getParent(), $oldTitle, $newTitle);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get worksheet.
|
||||
*/
|
||||
public function getWorksheet(): ?Worksheet
|
||||
{
|
||||
return $this->worksheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set worksheet.
|
||||
*/
|
||||
public function setWorksheet(?Worksheet $value): self
|
||||
{
|
||||
$this->worksheet = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get range or formula value.
|
||||
*/
|
||||
public function getValue(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set range or formula value.
|
||||
*/
|
||||
public function setValue(string $value): self
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get localOnly.
|
||||
*/
|
||||
public function getLocalOnly(): bool
|
||||
{
|
||||
return $this->localOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set localOnly.
|
||||
*/
|
||||
public function setLocalOnly(bool $value): self
|
||||
{
|
||||
$this->localOnly = $value;
|
||||
$this->scope = $value ? $this->worksheet : null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get scope.
|
||||
*/
|
||||
public function getScope(): ?Worksheet
|
||||
{
|
||||
return $this->scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set scope.
|
||||
*/
|
||||
public function setScope(?Worksheet $value): self
|
||||
{
|
||||
$this->scope = $value;
|
||||
$this->localOnly = $value !== null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether this is a named range or a named formula.
|
||||
*/
|
||||
public function isFormula(): bool
|
||||
{
|
||||
return $this->isFormula;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a named range to a regular cell range or formula.
|
||||
*/
|
||||
public static function resolveName(string $pDefinedName, Worksheet $pSheet): ?self
|
||||
{
|
||||
return $pSheet->getParent()->getDefinedName($pDefinedName, $pSheet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -457,11 +457,14 @@ class Properties
|
|||
*/
|
||||
public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null)
|
||||
{
|
||||
if (($propertyType === null) || (!in_array($propertyType, [self::PROPERTY_TYPE_INTEGER,
|
||||
if (
|
||||
($propertyType === null) || (!in_array($propertyType, [self::PROPERTY_TYPE_INTEGER,
|
||||
self::PROPERTY_TYPE_FLOAT,
|
||||
self::PROPERTY_TYPE_STRING,
|
||||
self::PROPERTY_TYPE_DATE,
|
||||
self::PROPERTY_TYPE_BOOLEAN, ]))) {
|
||||
self::PROPERTY_TYPE_BOOLEAN,
|
||||
]))
|
||||
) {
|
||||
if ($propertyValue === null) {
|
||||
$propertyType = self::PROPERTY_TYPE_STRING;
|
||||
} elseif (is_float($propertyValue)) {
|
||||
|
|
|
@ -694,9 +694,9 @@ class Html
|
|||
return implode('', $values[0]);
|
||||
}
|
||||
|
||||
protected function colourNameLookup($rgb)
|
||||
public static function colourNameLookup(string $rgb): string
|
||||
{
|
||||
return self::$colourMap[$rgb];
|
||||
return self::$colourMap[$rgb] ?? '';
|
||||
}
|
||||
|
||||
protected function startFontTag($tag): void
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class NamedFormula extends DefinedName
|
||||
{
|
||||
/**
|
||||
* Create a new Named Formula.
|
||||
*/
|
||||
public function __construct(
|
||||
string $name,
|
||||
?Worksheet $worksheet = null,
|
||||
?string $formula = null,
|
||||
bool $localOnly = false,
|
||||
?Worksheet $scope = null
|
||||
) {
|
||||
// Validate data
|
||||
if (empty($formula)) {
|
||||
throw new Exception('Tou must specify a Formula value for a Named Formula');
|
||||
}
|
||||
parent::__construct($name, $worksheet, $formula, $localOnly, $scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the formula value.
|
||||
*/
|
||||
public function getFormula(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the formula value.
|
||||
*/
|
||||
public function setFormula(string $formula): self
|
||||
{
|
||||
if (!empty($formula)) {
|
||||
$this->value = $formula;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
|
@ -2,234 +2,54 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class NamedRange
|
||||
class NamedRange extends DefinedName
|
||||
{
|
||||
/**
|
||||
* Range name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* Worksheet on which the named range can be resolved.
|
||||
*
|
||||
* @var Worksheet
|
||||
*/
|
||||
private $worksheet;
|
||||
|
||||
/**
|
||||
* Range of the referenced cells.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $range;
|
||||
|
||||
/**
|
||||
* Is the named range local? (i.e. can only be used on $this->worksheet).
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $localOnly;
|
||||
|
||||
/**
|
||||
* Scope.
|
||||
*
|
||||
* @var Worksheet
|
||||
*/
|
||||
private $scope;
|
||||
|
||||
/**
|
||||
* Create a new Named Range.
|
||||
*
|
||||
* @param string $pName
|
||||
* @param string $pRange
|
||||
* @param bool $pLocalOnly
|
||||
* @param null|Worksheet $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope.
|
||||
*/
|
||||
public function __construct($pName, Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
|
||||
{
|
||||
// Validate data
|
||||
if (($pName === null) || ($pWorksheet === null) || ($pRange === null)) {
|
||||
throw new Exception('Parameters can not be null.');
|
||||
public function __construct(
|
||||
string $name,
|
||||
?Worksheet $worksheet = null,
|
||||
string $range = 'A1',
|
||||
bool $localOnly = false,
|
||||
?Worksheet $scope = null
|
||||
) {
|
||||
if ($worksheet === null && $scope === null) {
|
||||
throw new Exception('You must specify a worksheet or a scope for a Named Range');
|
||||
}
|
||||
|
||||
// Set local members
|
||||
$this->name = $pName;
|
||||
$this->worksheet = $pWorksheet;
|
||||
$this->range = $pRange;
|
||||
$this->localOnly = $pLocalOnly;
|
||||
$this->scope = ($pLocalOnly == true) ? (($pScope == null) ? $pWorksheet : $pScope) : null;
|
||||
parent::__construct($name, $worksheet, $range, $localOnly, $scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name.
|
||||
*
|
||||
* @return string
|
||||
* Get the range value.
|
||||
*/
|
||||
public function getName()
|
||||
public function getRange(): string
|
||||
{
|
||||
return $this->name;
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
* Set the range value.
|
||||
*/
|
||||
public function setName($value)
|
||||
public function setRange(string $range): self
|
||||
{
|
||||
if ($value !== null) {
|
||||
// Old title
|
||||
$oldTitle = $this->name;
|
||||
|
||||
// Re-attach
|
||||
if ($this->worksheet !== null) {
|
||||
$this->worksheet->getParent()->removeNamedRange($this->name, $this->worksheet);
|
||||
}
|
||||
$this->name = $value;
|
||||
|
||||
if ($this->worksheet !== null) {
|
||||
$this->worksheet->getParent()->addNamedRange($this);
|
||||
}
|
||||
|
||||
// New title
|
||||
$newTitle = $this->name;
|
||||
ReferenceHelper::getInstance()->updateNamedFormulas($this->worksheet->getParent(), $oldTitle, $newTitle);
|
||||
if (!empty($range)) {
|
||||
$this->value = $range;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get worksheet.
|
||||
*
|
||||
* @return Worksheet
|
||||
*/
|
||||
public function getWorksheet()
|
||||
public function getCellsInRange(): array
|
||||
{
|
||||
return $this->worksheet;
|
||||
$range = $this->value;
|
||||
if (substr($range, 0, 1) === '=') {
|
||||
$range = substr($range, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set worksheet.
|
||||
*
|
||||
* @param Worksheet $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setWorksheet(?Worksheet $value = null)
|
||||
{
|
||||
if ($value !== null) {
|
||||
$this->worksheet = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get range.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRange()
|
||||
{
|
||||
return $this->range;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set range.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setRange($value)
|
||||
{
|
||||
if ($value !== null) {
|
||||
$this->range = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get localOnly.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getLocalOnly()
|
||||
{
|
||||
return $this->localOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set localOnly.
|
||||
*
|
||||
* @param bool $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLocalOnly($value)
|
||||
{
|
||||
$this->localOnly = $value;
|
||||
$this->scope = $value ? $this->worksheet : null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get scope.
|
||||
*
|
||||
* @return null|Worksheet
|
||||
*/
|
||||
public function getScope()
|
||||
{
|
||||
return $this->scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set scope.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setScope(?Worksheet $value = null)
|
||||
{
|
||||
$this->scope = $value;
|
||||
$this->localOnly = $value != null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a named range to a regular cell range.
|
||||
*
|
||||
* @param string $pNamedRange Named range
|
||||
* @param null|Worksheet $pSheet Scope. Use null for global scope
|
||||
*
|
||||
* @return NamedRange
|
||||
*/
|
||||
public static function resolveRange($pNamedRange, Worksheet $pSheet)
|
||||
{
|
||||
return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
return Coordinate::extractAllCellReferencesInRange($range);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Reader;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\File;
|
||||
|
||||
|
@ -133,13 +134,9 @@ abstract class BaseReader implements IReader
|
|||
|
||||
public function getSecurityScanner()
|
||||
{
|
||||
if (property_exists($this, 'securityScanner')) {
|
||||
return $this->securityScanner;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open file for reading.
|
||||
*
|
||||
|
@ -147,12 +144,18 @@ abstract class BaseReader implements IReader
|
|||
*/
|
||||
protected function openFile($pFilename): void
|
||||
{
|
||||
if ($pFilename) {
|
||||
File::assertFile($pFilename);
|
||||
|
||||
// Open file
|
||||
$this->fileHandle = fopen($pFilename, 'rb');
|
||||
if ($this->fileHandle === false) {
|
||||
throw new Exception('Could not open file ' . $pFilename . ' for reading.');
|
||||
$fileHandle = fopen($pFilename, 'rb');
|
||||
} else {
|
||||
$fileHandle = false;
|
||||
}
|
||||
if ($fileHandle !== false) {
|
||||
$this->fileHandle = $fileHandle;
|
||||
} else {
|
||||
throw new ReaderException('Could not open file ' . $pFilename . ' for reading.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -523,6 +523,7 @@ class Csv extends BaseReader
|
|||
// Attempt to guess mimetype
|
||||
$type = mime_content_type($pFilename);
|
||||
$supportedTypes = [
|
||||
'application/csv',
|
||||
'text/csv',
|
||||
'text/plain',
|
||||
'inode/x-empty',
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Reader\Gnumeric;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\PageMargins;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup as WorksheetPageSetup;
|
||||
use SimpleXMLElement;
|
||||
|
||||
class PageSetup
|
||||
{
|
||||
/**
|
||||
* @var Spreadsheet
|
||||
*/
|
||||
private $spreadsheet;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $gnm;
|
||||
|
||||
public function __construct(Spreadsheet $spreadsheet, string $gnm)
|
||||
{
|
||||
$this->spreadsheet = $spreadsheet;
|
||||
$this->gnm = $gnm;
|
||||
}
|
||||
|
||||
public function printInformation(SimpleXMLElement $sheet): self
|
||||
{
|
||||
if (isset($sheet->PrintInformation)) {
|
||||
$printInformation = $sheet->PrintInformation[0];
|
||||
$scale = (string) $printInformation->Scale->attributes()['percentage'];
|
||||
$pageOrder = (string) $printInformation->order;
|
||||
$orientation = (string) $printInformation->orientation;
|
||||
$horizontalCentered = (string) $printInformation->hcenter->attributes()['value'];
|
||||
$verticalCentered = (string) $printInformation->vcenter->attributes()['value'];
|
||||
|
||||
$this->spreadsheet->getActiveSheet()->getPageSetup()
|
||||
->setPageOrder($pageOrder === 'r_then_d' ? WorksheetPageSetup::PAGEORDER_OVER_THEN_DOWN : WorksheetPageSetup::PAGEORDER_DOWN_THEN_OVER)
|
||||
->setScale((int) $scale)
|
||||
->setOrientation($orientation ?? WorksheetPageSetup::ORIENTATION_DEFAULT)
|
||||
->setHorizontalCentered((bool) $horizontalCentered)
|
||||
->setVerticalCentered((bool) $verticalCentered);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function sheetMargins(SimpleXMLElement $sheet): self
|
||||
{
|
||||
if (isset($sheet->PrintInformation, $sheet->PrintInformation->Margins)) {
|
||||
$marginSet = [
|
||||
// Default Settings
|
||||
'top' => 0.75,
|
||||
'header' => 0.3,
|
||||
'left' => 0.7,
|
||||
'right' => 0.7,
|
||||
'bottom' => 0.75,
|
||||
'footer' => 0.3,
|
||||
];
|
||||
|
||||
$marginSet = $this->buildMarginSet($sheet, $marginSet);
|
||||
$this->adjustMargins($marginSet);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function buildMarginSet(SimpleXMLElement $sheet, array $marginSet): array
|
||||
{
|
||||
foreach ($sheet->PrintInformation->Margins->children($this->gnm, true) as $key => $margin) {
|
||||
$marginAttributes = $margin->attributes();
|
||||
$marginSize = ($marginAttributes['Points']) ?? 72; // Default is 72pt
|
||||
// Convert value in points to inches
|
||||
$marginSize = PageMargins::fromPoints((float) $marginSize);
|
||||
$marginSet[$key] = $marginSize;
|
||||
}
|
||||
|
||||
return $marginSet;
|
||||
}
|
||||
|
||||
private function adjustMargins(array $marginSet): void
|
||||
{
|
||||
foreach ($marginSet as $key => $marginSize) {
|
||||
// Gnumeric is quirky in the way it displays the header/footer values:
|
||||
// header is actually the sum of top and header; footer is actually the sum of bottom and footer
|
||||
// then top is actually the header value, and bottom is actually the footer value
|
||||
switch ($key) {
|
||||
case 'left':
|
||||
case 'right':
|
||||
$this->sheetMargin($key, $marginSize);
|
||||
|
||||
break;
|
||||
case 'top':
|
||||
$this->sheetMargin($key, $marginSet['header'] ?? 0);
|
||||
|
||||
break;
|
||||
case 'bottom':
|
||||
$this->sheetMargin($key, $marginSet['footer'] ?? 0);
|
||||
|
||||
break;
|
||||
case 'header':
|
||||
$this->sheetMargin($key, ($marginSet['top'] ?? 0) - $marginSize);
|
||||
|
||||
break;
|
||||
case 'footer':
|
||||
$this->sheetMargin($key, ($marginSet['bottom'] ?? 0) - $marginSize);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function sheetMargin(string $key, float $marginSize): void
|
||||
{
|
||||
switch ($key) {
|
||||
case 'top':
|
||||
$this->spreadsheet->getActiveSheet()->getPageMargins()->setTop($marginSize);
|
||||
|
||||
break;
|
||||
case 'bottom':
|
||||
$this->spreadsheet->getActiveSheet()->getPageMargins()->setBottom($marginSize);
|
||||
|
||||
break;
|
||||
case 'left':
|
||||
$this->spreadsheet->getActiveSheet()->getPageMargins()->setLeft($marginSize);
|
||||
|
||||
break;
|
||||
case 'right':
|
||||
$this->spreadsheet->getActiveSheet()->getPageMargins()->setRight($marginSize);
|
||||
|
||||
break;
|
||||
case 'header':
|
||||
$this->spreadsheet->getActiveSheet()->getPageMargins()->setHeader($marginSize);
|
||||
|
||||
break;
|
||||
case 'footer':
|
||||
$this->spreadsheet->getActiveSheet()->getPageMargins()->setFooter($marginSize);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ use PhpOffice\PhpSpreadsheet\Style\Font;
|
|||
use PhpOffice\PhpSpreadsheet\Style\Style;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use Throwable;
|
||||
|
||||
/** PhpSpreadsheet root directory */
|
||||
class Html extends BaseReader
|
||||
|
@ -219,9 +220,13 @@ class Html extends BaseReader
|
|||
/**
|
||||
* Set input encoding.
|
||||
*
|
||||
* @deprecated no use is made of this property
|
||||
*
|
||||
* @param string $pValue Input encoding, eg: 'ANSI'
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setInputEncoding($pValue)
|
||||
{
|
||||
|
@ -233,7 +238,11 @@ class Html extends BaseReader
|
|||
/**
|
||||
* Get input encoding.
|
||||
*
|
||||
* @deprecated no use is made of this property
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getInputEncoding()
|
||||
{
|
||||
|
@ -289,86 +298,72 @@ class Html extends BaseReader
|
|||
$cellContent = (string) '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $row
|
||||
* @param string $column
|
||||
* @param string $cellContent
|
||||
*/
|
||||
protected function processDomElement(DOMNode $element, Worksheet $sheet, &$row, &$column, &$cellContent): void
|
||||
private function processDomElementBody(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child): void
|
||||
{
|
||||
foreach ($element->childNodes as $child) {
|
||||
if ($child instanceof DOMText) {
|
||||
$domText = preg_replace('/\s+/u', ' ', trim($child->nodeValue));
|
||||
if (is_string($cellContent)) {
|
||||
// simply append the text if the cell content is a plain text string
|
||||
$cellContent .= $domText;
|
||||
}
|
||||
// but if we have a rich text run instead, we need to append it correctly
|
||||
// TODO
|
||||
} elseif ($child instanceof DOMElement) {
|
||||
$attributeArray = [];
|
||||
foreach ($child->attributes as $attribute) {
|
||||
$attributeArray[$attribute->name] = $attribute->value;
|
||||
}
|
||||
|
||||
switch ($child->nodeName) {
|
||||
case 'meta':
|
||||
foreach ($attributeArray as $attributeName => $attributeValue) {
|
||||
// Extract character set, so we can convert to UTF-8 if required
|
||||
if ($attributeName === 'charset') {
|
||||
$this->setInputEncoding($attributeValue);
|
||||
}
|
||||
}
|
||||
if ($child->nodeName === 'body') {
|
||||
$row = 1;
|
||||
$column = 'A';
|
||||
$cellContent = '';
|
||||
$this->tableLevel = 0;
|
||||
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||
} else {
|
||||
$this->processDomElementTitle($sheet, $row, $column, $cellContent, $child, $attributeArray);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'title':
|
||||
private function processDomElementTitle(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void
|
||||
{
|
||||
if ($child->nodeName === 'title') {
|
||||
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||
$sheet->setTitle($cellContent, true, false);
|
||||
$cellContent = '';
|
||||
} else {
|
||||
$this->processDomElementSpanEtc($sheet, $row, $column, $cellContent, $child, $attributeArray);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'span':
|
||||
case 'div':
|
||||
case 'font':
|
||||
case 'i':
|
||||
case 'em':
|
||||
case 'strong':
|
||||
case 'b':
|
||||
private static $spanEtc = ['span', 'div', 'font', 'i', 'em', 'strong', 'b'];
|
||||
|
||||
private function processDomElementSpanEtc(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void
|
||||
{
|
||||
if (in_array($child->nodeName, self::$spanEtc)) {
|
||||
if (isset($attributeArray['class']) && $attributeArray['class'] === 'comment') {
|
||||
$sheet->getComment($column . $row)
|
||||
->getText()
|
||||
->createTextRun($child->textContent);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if ($cellContent > '') {
|
||||
$cellContent .= ' ';
|
||||
}
|
||||
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||
if ($cellContent > '') {
|
||||
$cellContent .= ' ';
|
||||
}
|
||||
|
||||
if (isset($this->formats[$child->nodeName])) {
|
||||
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
|
||||
}
|
||||
|
||||
break;
|
||||
case 'hr':
|
||||
$this->flushCell($sheet, $column, $row, $cellContent);
|
||||
++$row;
|
||||
if (isset($this->formats[$child->nodeName])) {
|
||||
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
|
||||
} else {
|
||||
$cellContent = '----------';
|
||||
$this->processDomElementHr($sheet, $row, $column, $cellContent, $child, $attributeArray);
|
||||
}
|
||||
}
|
||||
|
||||
private function processDomElementHr(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void
|
||||
{
|
||||
if ($child->nodeName === 'hr') {
|
||||
$this->flushCell($sheet, $column, $row, $cellContent);
|
||||
++$row;
|
||||
if (isset($this->formats[$child->nodeName])) {
|
||||
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
|
||||
}
|
||||
++$row;
|
||||
// Add a break after a horizontal rule, simply by allowing the code to dropthru
|
||||
// no break
|
||||
case 'br':
|
||||
}
|
||||
// fall through to br
|
||||
$this->processDomElementBr($sheet, $row, $column, $cellContent, $child, $attributeArray);
|
||||
}
|
||||
|
||||
private function processDomElementBr(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void
|
||||
{
|
||||
if ($child->nodeName === 'br' || $child->nodeName === 'hr') {
|
||||
if ($this->tableLevel > 0) {
|
||||
// If we're inside a table, replace with a \n and set the cell to wrap
|
||||
$cellContent .= "\n";
|
||||
|
@ -378,9 +373,14 @@ class Html extends BaseReader
|
|||
$this->flushCell($sheet, $column, $row, $cellContent);
|
||||
++$row;
|
||||
}
|
||||
} else {
|
||||
$this->processDomElementA($sheet, $row, $column, $cellContent, $child, $attributeArray);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'a':
|
||||
private function processDomElementA(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void
|
||||
{
|
||||
if ($child->nodeName === 'a') {
|
||||
foreach ($attributeArray as $attributeName => $attributeValue) {
|
||||
switch ($attributeName) {
|
||||
case 'href':
|
||||
|
@ -396,22 +396,23 @@ class Html extends BaseReader
|
|||
}
|
||||
}
|
||||
}
|
||||
$cellContent .= ' ';
|
||||
// no idea why this should be needed
|
||||
//$cellContent .= ' ';
|
||||
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||
} else {
|
||||
$this->processDomElementH1Etc($sheet, $row, $column, $cellContent, $child, $attributeArray);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'h1':
|
||||
case 'h2':
|
||||
case 'h3':
|
||||
case 'h4':
|
||||
case 'h5':
|
||||
case 'h6':
|
||||
case 'ol':
|
||||
case 'ul':
|
||||
case 'p':
|
||||
private static $h1Etc = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'ul', 'p'];
|
||||
|
||||
private function processDomElementH1Etc(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void
|
||||
{
|
||||
if (in_array($child->nodeName, self::$h1Etc)) {
|
||||
if ($this->tableLevel > 0) {
|
||||
// If we're inside a table, replace with a \n
|
||||
$cellContent .= "\n";
|
||||
$cellContent .= $cellContent ? "\n" : '';
|
||||
$sheet->getStyle($column . $row)->getAlignment()->setWrapText(true);
|
||||
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||
} else {
|
||||
if ($cellContent > '') {
|
||||
|
@ -428,12 +429,17 @@ class Html extends BaseReader
|
|||
++$row;
|
||||
$column = 'A';
|
||||
}
|
||||
} else {
|
||||
$this->processDomElementLi($sheet, $row, $column, $cellContent, $child, $attributeArray);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'li':
|
||||
private function processDomElementLi(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void
|
||||
{
|
||||
if ($child->nodeName === 'li') {
|
||||
if ($this->tableLevel > 0) {
|
||||
// If we're inside a table, replace with a \n
|
||||
$cellContent .= "\n";
|
||||
$cellContent .= $cellContent ? "\n" : '';
|
||||
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||
} else {
|
||||
if ($cellContent > '') {
|
||||
|
@ -444,13 +450,23 @@ class Html extends BaseReader
|
|||
$this->flushCell($sheet, $column, $row, $cellContent);
|
||||
$column = 'A';
|
||||
}
|
||||
} else {
|
||||
$this->processDomElementImg($sheet, $row, $column, $cellContent, $child, $attributeArray);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'img':
|
||||
private function processDomElementImg(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void
|
||||
{
|
||||
if ($child->nodeName === 'img') {
|
||||
$this->insertImage($sheet, $column, $row, $attributeArray);
|
||||
} else {
|
||||
$this->processDomElementTable($sheet, $row, $column, $cellContent, $child, $attributeArray);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'table':
|
||||
private function processDomElementTable(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void
|
||||
{
|
||||
if ($child->nodeName === 'table') {
|
||||
$this->flushCell($sheet, $column, $row, $cellContent);
|
||||
$column = $this->setTableStartColumn($column);
|
||||
if ($this->tableLevel > 1) {
|
||||
|
@ -463,14 +479,14 @@ class Html extends BaseReader
|
|||
} else {
|
||||
++$row;
|
||||
}
|
||||
} else {
|
||||
$this->processDomElementTr($sheet, $row, $column, $cellContent, $child, $attributeArray);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'thead':
|
||||
case 'tbody':
|
||||
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||
|
||||
break;
|
||||
case 'tr':
|
||||
private function processDomElementTr(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void
|
||||
{
|
||||
if ($child->nodeName === 'tr') {
|
||||
$column = $this->getTableStartColumn();
|
||||
$cellContent = '';
|
||||
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||
|
@ -480,21 +496,88 @@ class Html extends BaseReader
|
|||
}
|
||||
|
||||
++$row;
|
||||
} else {
|
||||
$this->processDomElementThTdOther($sheet, $row, $column, $cellContent, $child, $attributeArray);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'th':
|
||||
case 'td':
|
||||
private function processDomElementThTdOther(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void
|
||||
{
|
||||
if ($child->nodeName !== 'td' && $child->nodeName !== 'th') {
|
||||
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||
} else {
|
||||
$this->processDomElementThTd($sheet, $row, $column, $cellContent, $child, $attributeArray);
|
||||
}
|
||||
}
|
||||
|
||||
private function processDomElementBgcolor(Worksheet $sheet, int $row, string $column, array $attributeArray): void
|
||||
{
|
||||
if (isset($attributeArray['bgcolor'])) {
|
||||
$sheet->getStyle("$column$row")->applyFromArray(
|
||||
[
|
||||
'fill' => [
|
||||
'fillType' => Fill::FILL_SOLID,
|
||||
'color' => ['rgb' => $this->getStyleColor($attributeArray['bgcolor'])],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function processDomElementWidth(Worksheet $sheet, string $column, array $attributeArray): void
|
||||
{
|
||||
if (isset($attributeArray['width'])) {
|
||||
$sheet->getColumnDimension($column)->setWidth($attributeArray['width']);
|
||||
}
|
||||
}
|
||||
|
||||
private function processDomElementHeight(Worksheet $sheet, int $row, array $attributeArray): void
|
||||
{
|
||||
if (isset($attributeArray['height'])) {
|
||||
$sheet->getRowDimension($row)->setRowHeight($attributeArray['height']);
|
||||
}
|
||||
}
|
||||
|
||||
private function processDomElementAlign(Worksheet $sheet, int $row, string $column, array $attributeArray): void
|
||||
{
|
||||
if (isset($attributeArray['align'])) {
|
||||
$sheet->getStyle($column . $row)->getAlignment()->setHorizontal($attributeArray['align']);
|
||||
}
|
||||
}
|
||||
|
||||
private function processDomElementVAlign(Worksheet $sheet, int $row, string $column, array $attributeArray): void
|
||||
{
|
||||
if (isset($attributeArray['valign'])) {
|
||||
$sheet->getStyle($column . $row)->getAlignment()->setVertical($attributeArray['valign']);
|
||||
}
|
||||
}
|
||||
|
||||
private function processDomElementDataFormat(Worksheet $sheet, int $row, string $column, array $attributeArray): void
|
||||
{
|
||||
if (isset($attributeArray['data-format'])) {
|
||||
$sheet->getStyle($column . $row)->getNumberFormat()->setFormatCode($attributeArray['data-format']);
|
||||
}
|
||||
}
|
||||
|
||||
private function processDomElementThTd(Worksheet $sheet, int &$row, string &$column, string &$cellContent, DOMElement $child, array &$attributeArray): void
|
||||
{
|
||||
while (isset($this->rowspan[$column . $row])) {
|
||||
++$column;
|
||||
}
|
||||
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||
|
||||
// apply inline style
|
||||
$this->applyInlineStyle($sheet, $row, $column, $attributeArray);
|
||||
|
||||
$this->flushCell($sheet, $column, $row, $cellContent);
|
||||
|
||||
$this->processDomElementBgcolor($sheet, $row, $column, $attributeArray);
|
||||
$this->processDomElementWidth($sheet, $column, $attributeArray);
|
||||
$this->processDomElementHeight($sheet, $row, $attributeArray);
|
||||
$this->processDomElementAlign($sheet, $row, $column, $attributeArray);
|
||||
$this->processDomElementVAlign($sheet, $row, $column, $attributeArray);
|
||||
$this->processDomElementDataFormat($sheet, $row, $column, $attributeArray);
|
||||
|
||||
if (isset($attributeArray['rowspan'], $attributeArray['colspan'])) {
|
||||
//create merging rowspan and colspan
|
||||
$columnTo = $column;
|
||||
|
@ -522,51 +605,24 @@ class Html extends BaseReader
|
|||
}
|
||||
$sheet->mergeCells($column . $row . ':' . $columnTo . $row);
|
||||
$column = $columnTo;
|
||||
} elseif (isset($attributeArray['bgcolor'])) {
|
||||
$sheet->getStyle($column . $row)->applyFromArray(
|
||||
[
|
||||
'fill' => [
|
||||
'fillType' => Fill::FILL_SOLID,
|
||||
'color' => ['rgb' => $attributeArray['bgcolor']],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($attributeArray['width'])) {
|
||||
$sheet->getColumnDimension($column)->setWidth($attributeArray['width']);
|
||||
}
|
||||
|
||||
if (isset($attributeArray['height'])) {
|
||||
$sheet->getRowDimension($row)->setRowHeight($attributeArray['height']);
|
||||
}
|
||||
|
||||
if (isset($attributeArray['align'])) {
|
||||
$sheet->getStyle($column . $row)->getAlignment()->setHorizontal($attributeArray['align']);
|
||||
}
|
||||
|
||||
if (isset($attributeArray['valign'])) {
|
||||
$sheet->getStyle($column . $row)->getAlignment()->setVertical($attributeArray['valign']);
|
||||
}
|
||||
|
||||
if (isset($attributeArray['data-format'])) {
|
||||
$sheet->getStyle($column . $row)->getNumberFormat()->setFormatCode($attributeArray['data-format']);
|
||||
}
|
||||
|
||||
++$column;
|
||||
|
||||
break;
|
||||
case 'body':
|
||||
$row = 1;
|
||||
$column = 'A';
|
||||
$cellContent = '';
|
||||
$this->tableLevel = 0;
|
||||
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||
|
||||
break;
|
||||
default:
|
||||
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||
}
|
||||
|
||||
protected function processDomElement(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent): void
|
||||
{
|
||||
foreach ($element->childNodes as $child) {
|
||||
if ($child instanceof DOMText) {
|
||||
$domText = preg_replace('/\s+/u', ' ', trim($child->nodeValue));
|
||||
if (is_string($cellContent)) {
|
||||
// simply append the text if the cell content is a plain text string
|
||||
$cellContent .= $domText;
|
||||
}
|
||||
// but if we have a rich text run instead, we need to append it correctly
|
||||
// TODO
|
||||
} elseif ($child instanceof DOMElement) {
|
||||
$this->processDomElementBody($sheet, $row, $column, $cellContent, $child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -588,7 +644,11 @@ class Html extends BaseReader
|
|||
// Create a new DOM object
|
||||
$dom = new DOMDocument();
|
||||
// Reload the HTML file into the DOM object
|
||||
try {
|
||||
$loaded = $dom->loadHTML(mb_convert_encoding($this->securityScanner->scanFile($pFilename), 'HTML-ENTITIES', 'UTF-8'));
|
||||
} catch (Throwable $e) {
|
||||
$loaded = false;
|
||||
}
|
||||
if ($loaded === false) {
|
||||
throw new Exception('Failed to load ' . $pFilename . ' as a DOM Document');
|
||||
}
|
||||
|
@ -606,7 +666,11 @@ class Html extends BaseReader
|
|||
// Create a new DOM object
|
||||
$dom = new DOMDocument();
|
||||
// Reload the HTML file into the DOM object
|
||||
try {
|
||||
$loaded = $dom->loadHTML(mb_convert_encoding($this->securityScanner->scan($content), 'HTML-ENTITIES', 'UTF-8'));
|
||||
} catch (Throwable $e) {
|
||||
$loaded = false;
|
||||
}
|
||||
if ($loaded === false) {
|
||||
throw new Exception('Failed to load content as a DOM Document');
|
||||
}
|
||||
|
@ -682,7 +746,26 @@ class Html extends BaseReader
|
|||
return;
|
||||
}
|
||||
|
||||
if (isset($attributeArray['rowspan'], $attributeArray['colspan'])) {
|
||||
$columnTo = $column;
|
||||
for ($i = 0; $i < (int) $attributeArray['colspan'] - 1; ++$i) {
|
||||
++$columnTo;
|
||||
}
|
||||
$range = $column . $row . ':' . $columnTo . ($row + (int) $attributeArray['rowspan'] - 1);
|
||||
$cellStyle = $sheet->getStyle($range);
|
||||
} elseif (isset($attributeArray['rowspan'])) {
|
||||
$range = $column . $row . ':' . $column . ($row + (int) $attributeArray['rowspan'] - 1);
|
||||
$cellStyle = $sheet->getStyle($range);
|
||||
} elseif (isset($attributeArray['colspan'])) {
|
||||
$columnTo = $column;
|
||||
for ($i = 0; $i < (int) $attributeArray['colspan'] - 1; ++$i) {
|
||||
++$columnTo;
|
||||
}
|
||||
$range = $column . $row . ':' . $columnTo . $row;
|
||||
$cellStyle = $sheet->getStyle($range);
|
||||
} else {
|
||||
$cellStyle = $sheet->getStyle($column . $row);
|
||||
}
|
||||
|
||||
// add color styles (background & text) from dom element,currently support : td & th, using ONLY inline css style with RGB color
|
||||
$styles = explode(';', $attributeArray['style']);
|
||||
|
@ -837,7 +920,7 @@ class Html extends BaseReader
|
|||
return substr($value, 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
return \PhpOffice\PhpSpreadsheet\Helper\Html::colourNameLookup((string) $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -853,7 +936,7 @@ class Html extends BaseReader
|
|||
$src = urldecode($attributes['src']);
|
||||
$width = isset($attributes['width']) ? (float) $attributes['width'] : null;
|
||||
$height = isset($attributes['height']) ? (float) $attributes['height'] : null;
|
||||
$name = isset($attributes['alt']) ? (float) $attributes['alt'] : null;
|
||||
$name = $attributes['alt'] ?? null;
|
||||
|
||||
$drawing = new Drawing();
|
||||
$drawing->setPath($src);
|
||||
|
@ -884,6 +967,28 @@ class Html extends BaseReader
|
|||
);
|
||||
}
|
||||
|
||||
private static $borderMappings = [
|
||||
'dash-dot' => Border::BORDER_DASHDOT,
|
||||
'dash-dot-dot' => Border::BORDER_DASHDOTDOT,
|
||||
'dashed' => Border::BORDER_DASHED,
|
||||
'dotted' => Border::BORDER_DOTTED,
|
||||
'double' => Border::BORDER_DOUBLE,
|
||||
'hair' => Border::BORDER_HAIR,
|
||||
'medium' => Border::BORDER_MEDIUM,
|
||||
'medium-dashed' => Border::BORDER_MEDIUMDASHED,
|
||||
'medium-dash-dot' => Border::BORDER_MEDIUMDASHDOT,
|
||||
'medium-dash-dot-dot' => Border::BORDER_MEDIUMDASHDOTDOT,
|
||||
'none' => Border::BORDER_NONE,
|
||||
'slant-dash-dot' => Border::BORDER_SLANTDASHDOT,
|
||||
'solid' => Border::BORDER_THIN,
|
||||
'thick' => Border::BORDER_THICK,
|
||||
];
|
||||
|
||||
public static function getBorderMappings(): array
|
||||
{
|
||||
return self::$borderMappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map html border style to PhpSpreadsheet border style.
|
||||
*
|
||||
|
@ -893,38 +998,7 @@ class Html extends BaseReader
|
|||
*/
|
||||
public function getBorderStyle($style)
|
||||
{
|
||||
switch ($style) {
|
||||
case 'solid':
|
||||
return Border::BORDER_THIN;
|
||||
case 'dashed':
|
||||
return Border::BORDER_DASHED;
|
||||
case 'dotted':
|
||||
return Border::BORDER_DOTTED;
|
||||
case 'medium':
|
||||
return Border::BORDER_MEDIUM;
|
||||
case 'thick':
|
||||
return Border::BORDER_THICK;
|
||||
case 'none':
|
||||
return Border::BORDER_NONE;
|
||||
case 'dash-dot':
|
||||
return Border::BORDER_DASHDOT;
|
||||
case 'dash-dot-dot':
|
||||
return Border::BORDER_DASHDOTDOT;
|
||||
case 'double':
|
||||
return Border::BORDER_DOUBLE;
|
||||
case 'hair':
|
||||
return Border::BORDER_HAIR;
|
||||
case 'medium-dash-dot':
|
||||
return Border::BORDER_MEDIUMDASHDOT;
|
||||
case 'medium-dash-dot-dot':
|
||||
return Border::BORDER_MEDIUMDASHDOTDOT;
|
||||
case 'medium-dashed':
|
||||
return Border::BORDER_MEDIUMDASHED;
|
||||
case 'slant-dash-dot':
|
||||
return Border::BORDER_SLANTDASHDOT;
|
||||
}
|
||||
|
||||
return null;
|
||||
return (array_key_exists($style, self::$borderMappings)) ? self::$borderMappings[$style] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,6 +11,9 @@ use DOMNode;
|
|||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\DefinedName;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Ods\PageSettings;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Ods\Properties as DocumentProperties;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner;
|
||||
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
||||
|
@ -19,6 +22,7 @@ use PhpOffice\PhpSpreadsheet\Shared\Date;
|
|||
use PhpOffice\PhpSpreadsheet\Shared\File;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use XMLReader;
|
||||
use ZipArchive;
|
||||
|
||||
|
@ -75,11 +79,9 @@ class Ods extends BaseReader
|
|||
}
|
||||
|
||||
$zip->close();
|
||||
|
||||
return $mimeType === 'application/vnd.oasis.opendocument.spreadsheet';
|
||||
}
|
||||
|
||||
return false;
|
||||
return $mimeType === 'application/vnd.oasis.opendocument.spreadsheet';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,8 +96,8 @@ class Ods extends BaseReader
|
|||
File::assertFile($pFilename);
|
||||
|
||||
$zip = new ZipArchive();
|
||||
if (!$zip->open($pFilename)) {
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! Error opening file.');
|
||||
if ($zip->open($pFilename) !== true) {
|
||||
throw new ReaderException('Could not open ' . $pFilename . ' for reading! Error opening file.');
|
||||
}
|
||||
|
||||
$worksheetNames = [];
|
||||
|
@ -148,8 +150,8 @@ class Ods extends BaseReader
|
|||
$worksheetInfo = [];
|
||||
|
||||
$zip = new ZipArchive();
|
||||
if (!$zip->open($pFilename)) {
|
||||
throw new Exception('Could not open ' . $pFilename . ' for reading! Error opening file.');
|
||||
if ($zip->open($pFilename) !== true) {
|
||||
throw new ReaderException('Could not open ' . $pFilename . ' for reading! Error opening file.');
|
||||
}
|
||||
|
||||
$xml = new XMLReader();
|
||||
|
@ -197,18 +199,18 @@ class Ods extends BaseReader
|
|||
// Step into the row
|
||||
$xml->read();
|
||||
do {
|
||||
$doread = true;
|
||||
if ($xml->name == 'table:table-cell' && $xml->nodeType == XMLReader::ELEMENT) {
|
||||
if (!$xml->isEmptyElement) {
|
||||
++$currCells;
|
||||
$xml->next();
|
||||
} else {
|
||||
$xml->read();
|
||||
$doread = false;
|
||||
}
|
||||
} elseif ($xml->name == 'table:covered-table-cell' && $xml->nodeType == XMLReader::ELEMENT) {
|
||||
$mergeSize = $xml->getAttribute('table:number-columns-repeated');
|
||||
$currCells += (int) $mergeSize;
|
||||
$xml->read();
|
||||
} else {
|
||||
}
|
||||
if ($doread) {
|
||||
$xml->read();
|
||||
}
|
||||
} while ($xml->name != 'table:table-row');
|
||||
|
@ -257,13 +259,13 @@ class Ods extends BaseReader
|
|||
$GMT = new DateTimeZone('UTC');
|
||||
|
||||
$zip = new ZipArchive();
|
||||
if (!$zip->open($pFilename)) {
|
||||
if ($zip->open($pFilename) !== true) {
|
||||
throw new Exception("Could not open {$pFilename} for reading! Error opening file.");
|
||||
}
|
||||
|
||||
// Meta
|
||||
|
||||
$xml = simplexml_load_string(
|
||||
$xml = @simplexml_load_string(
|
||||
$this->securityScanner->scan($zip->getFromName('meta.xml')),
|
||||
'SimpleXMLElement',
|
||||
Settings::getLibXmlLoaderOptions()
|
||||
|
@ -276,7 +278,17 @@ class Ods extends BaseReader
|
|||
|
||||
(new DocumentProperties($spreadsheet))->load($xml, $namespacesMeta);
|
||||
|
||||
// Content
|
||||
// Styles
|
||||
|
||||
$dom = new DOMDocument('1.01', 'UTF-8');
|
||||
$dom->loadXML(
|
||||
$this->securityScanner->scan($zip->getFromName('styles.xml')),
|
||||
Settings::getLibXmlLoaderOptions()
|
||||
);
|
||||
|
||||
$pageSettings = new PageSettings($dom);
|
||||
|
||||
// Main Content
|
||||
|
||||
$dom = new DOMDocument('1.01', 'UTF-8');
|
||||
$dom->loadXML(
|
||||
|
@ -289,6 +301,10 @@ class Ods extends BaseReader
|
|||
$textNs = $dom->lookupNamespaceUri('text');
|
||||
$xlinkNs = $dom->lookupNamespaceUri('xlink');
|
||||
|
||||
$pageSettings->readStyleCrossReferences($dom);
|
||||
|
||||
// Content
|
||||
|
||||
$spreadsheets = $dom->getElementsByTagNameNS($officeNs, 'body')
|
||||
->item(0)
|
||||
->getElementsByTagNameNS($officeNs, 'spreadsheet');
|
||||
|
@ -303,12 +319,16 @@ class Ods extends BaseReader
|
|||
$worksheetName = $worksheetDataSet->getAttributeNS($tableNs, 'name');
|
||||
|
||||
// Check loadSheetsOnly
|
||||
if (isset($this->loadSheetsOnly)
|
||||
if (
|
||||
isset($this->loadSheetsOnly)
|
||||
&& $worksheetName
|
||||
&& !in_array($worksheetName, $this->loadSheetsOnly)) {
|
||||
&& !in_array($worksheetName, $this->loadSheetsOnly)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$worksheetStyleName = $worksheetDataSet->getAttributeNS($tableNs, 'style-name');
|
||||
|
||||
// Create sheet
|
||||
if ($worksheetID > 0) {
|
||||
$spreadsheet->createSheet(); // First sheet is added by default
|
||||
|
@ -319,7 +339,7 @@ class Ods extends BaseReader
|
|||
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in
|
||||
// formula cells... during the load, all formulae should be correct, and we're simply
|
||||
// bringing the worksheet name in line with the formula, not the reverse
|
||||
$spreadsheet->getActiveSheet()->setTitle($worksheetName, false, false);
|
||||
$spreadsheet->getActiveSheet()->setTitle((string) $worksheetName, false, false);
|
||||
}
|
||||
|
||||
// Go through every child of table element
|
||||
|
@ -448,9 +468,10 @@ class Ods extends BaseReader
|
|||
$type = DataType::TYPE_NUMERIC;
|
||||
$dataValue = (float) $cellData->getAttributeNS($officeNs, 'value');
|
||||
|
||||
if (floor($dataValue) == $dataValue) {
|
||||
$dataValue = (int) $dataValue;
|
||||
}
|
||||
// percentage should always be float
|
||||
//if (floor($dataValue) == $dataValue) {
|
||||
// $dataValue = (int) $dataValue;
|
||||
//}
|
||||
$formatting = NumberFormat::FORMAT_PERCENTAGE_00;
|
||||
|
||||
break;
|
||||
|
@ -471,8 +492,6 @@ class Ods extends BaseReader
|
|||
if (floor($dataValue) == $dataValue) {
|
||||
if ($dataValue == (int) $dataValue) {
|
||||
$dataValue = (int) $dataValue;
|
||||
} else {
|
||||
$dataValue = (float) $dataValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -530,30 +549,7 @@ class Ods extends BaseReader
|
|||
if ($hasCalculatedValue) {
|
||||
$type = DataType::TYPE_FORMULA;
|
||||
$cellDataFormula = substr($cellDataFormula, strpos($cellDataFormula, ':=') + 1);
|
||||
$temp = explode('"', $cellDataFormula);
|
||||
$tKey = false;
|
||||
foreach ($temp as &$value) {
|
||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||
if ($tKey = !$tKey) {
|
||||
// Cell range reference in another sheet
|
||||
$value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/U', '$1!$2:$3', $value);
|
||||
|
||||
// Cell reference in another sheet
|
||||
$value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/U', '$1!$2', $value);
|
||||
|
||||
// Cell range reference
|
||||
$value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/U', '$1:$2', $value);
|
||||
|
||||
// Simple cell reference
|
||||
$value = preg_replace('/\[\.([^\.]+)\]/U', '$1', $value);
|
||||
|
||||
$value = Calculation::translateSeparator(';', ',', $value, $inBraces);
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
|
||||
// Then rebuild the formula string
|
||||
$cellDataFormula = implode('"', $temp);
|
||||
$cellDataFormula = $this->convertToExcelFormulaValue($cellDataFormula);
|
||||
}
|
||||
|
||||
if ($cellData->hasAttributeNS($tableNs, 'number-columns-repeated')) {
|
||||
|
@ -609,7 +605,8 @@ class Ods extends BaseReader
|
|||
}
|
||||
|
||||
// Merged cells
|
||||
if ($cellData->hasAttributeNS($tableNs, 'number-columns-spanned')
|
||||
if (
|
||||
$cellData->hasAttributeNS($tableNs, 'number-columns-spanned')
|
||||
|| $cellData->hasAttributeNS($tableNs, 'number-rows-spanned')
|
||||
) {
|
||||
if (($type !== DataType::TYPE_NULL) || (!$this->readDataOnly)) {
|
||||
|
@ -641,10 +638,14 @@ class Ods extends BaseReader
|
|||
break;
|
||||
}
|
||||
}
|
||||
$pageSettings->setPrintSettingsForWorksheet($spreadsheet->getActiveSheet(), $worksheetStyleName);
|
||||
++$worksheetID;
|
||||
}
|
||||
}
|
||||
|
||||
$this->readDefinedRanges($spreadsheet, $workbookData, $tableNs);
|
||||
$this->readDefinedExpressions($spreadsheet, $workbookData, $tableNs);
|
||||
}
|
||||
$spreadsheet->setActiveSheetIndex(0);
|
||||
// Return
|
||||
return $spreadsheet;
|
||||
}
|
||||
|
@ -696,4 +697,99 @@ class Ods extends BaseReader
|
|||
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function convertToExcelAddressValue(string $openOfficeAddress): string
|
||||
{
|
||||
$excelAddress = $openOfficeAddress;
|
||||
|
||||
// Cell range 3-d reference
|
||||
// As we don't support 3-d ranges, we're just going to take a quick and dirty approach
|
||||
// and assume that the second worksheet reference is the same as the first
|
||||
$excelAddress = preg_replace('/\$?([^\.]+)\.([^\.]+):\$?([^\.]+)\.([^\.]+)/miu', '$1!$2:$4', $excelAddress);
|
||||
// Cell range reference in another sheet
|
||||
$excelAddress = preg_replace('/\$?([^\.]+)\.([^\.]+):\.([^\.]+)/miu', '$1!$2:$3', $excelAddress);
|
||||
// Cell reference in another sheet
|
||||
$excelAddress = preg_replace('/\$?([^\.]+)\.([^\.]+)/miu', '$1!$2', $excelAddress);
|
||||
// Cell range reference
|
||||
$excelAddress = preg_replace('/\.([^\.]+):\.([^\.]+)/miu', '$1:$2', $excelAddress);
|
||||
// Simple cell reference
|
||||
$excelAddress = preg_replace('/\.([^\.]+)/miu', '$1', $excelAddress);
|
||||
|
||||
return $excelAddress;
|
||||
}
|
||||
|
||||
private function convertToExcelFormulaValue(string $openOfficeFormula): string
|
||||
{
|
||||
$temp = explode('"', $openOfficeFormula);
|
||||
$tKey = false;
|
||||
foreach ($temp as &$value) {
|
||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||
if ($tKey = !$tKey) {
|
||||
// Cell range reference in another sheet
|
||||
$value = preg_replace('/\[\$?([^\.]+)\.([^\.]+):\.([^\.]+)\]/miu', '$1!$2:$3', $value);
|
||||
// Cell reference in another sheet
|
||||
$value = preg_replace('/\[\$?([^\.]+)\.([^\.]+)\]/miu', '$1!$2', $value);
|
||||
// Cell range reference
|
||||
$value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/miu', '$1:$2', $value);
|
||||
// Simple cell reference
|
||||
$value = preg_replace('/\[\.([^\.]+)\]/miu', '$1', $value);
|
||||
|
||||
$value = Calculation::translateSeparator(';', ',', $value, $inBraces);
|
||||
}
|
||||
}
|
||||
|
||||
// Then rebuild the formula string
|
||||
$excelFormula = implode('"', $temp);
|
||||
|
||||
return $excelFormula;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read any Named Ranges that are defined in this spreadsheet.
|
||||
*/
|
||||
private function readDefinedRanges(Spreadsheet $spreadsheet, DOMElement $workbookData, string $tableNs): void
|
||||
{
|
||||
$namedRanges = $workbookData->getElementsByTagNameNS($tableNs, 'named-range');
|
||||
foreach ($namedRanges as $definedNameElement) {
|
||||
$definedName = $definedNameElement->getAttributeNS($tableNs, 'name');
|
||||
$baseAddress = $definedNameElement->getAttributeNS($tableNs, 'base-cell-address');
|
||||
$range = $definedNameElement->getAttributeNS($tableNs, 'cell-range-address');
|
||||
|
||||
$baseAddress = $this->convertToExcelAddressValue($baseAddress);
|
||||
$range = $this->convertToExcelAddressValue($range);
|
||||
|
||||
$this->addDefinedName($spreadsheet, $baseAddress, $definedName, $range);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read any Named Formulae that are defined in this spreadsheet.
|
||||
*/
|
||||
private function readDefinedExpressions(Spreadsheet $spreadsheet, DOMElement $workbookData, string $tableNs): void
|
||||
{
|
||||
$namedExpressions = $workbookData->getElementsByTagNameNS($tableNs, 'named-expression');
|
||||
foreach ($namedExpressions as $definedNameElement) {
|
||||
$definedName = $definedNameElement->getAttributeNS($tableNs, 'name');
|
||||
$baseAddress = $definedNameElement->getAttributeNS($tableNs, 'base-cell-address');
|
||||
$expression = $definedNameElement->getAttributeNS($tableNs, 'expression');
|
||||
|
||||
$baseAddress = $this->convertToExcelAddressValue($baseAddress);
|
||||
$expression = $this->convertToExcelFormulaValue($expression);
|
||||
|
||||
$this->addDefinedName($spreadsheet, $baseAddress, $definedName, $expression);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assess scope and store the Defined Name.
|
||||
*/
|
||||
private function addDefinedName(Spreadsheet $spreadsheet, string $baseAddress, string $definedName, string $value): void
|
||||
{
|
||||
[$sheetReference] = Worksheet::extractSheetTitle($baseAddress, true);
|
||||
$worksheet = $spreadsheet->getSheetByName($sheetReference);
|
||||
// Worksheet might still be null if we're only loading selected sheets rather than the full spreadsheet
|
||||
if ($worksheet !== null) {
|
||||
$spreadsheet->addDefinedName(DefinedName::createInstance((string) $definedName, $worksheet, $value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Reader\Ods;
|
||||
|
||||
use DOMDocument;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class PageSettings
|
||||
{
|
||||
private $officeNs;
|
||||
|
||||
private $stylesNs;
|
||||
|
||||
private $stylesFo;
|
||||
|
||||
private $pageLayoutStyles = [];
|
||||
|
||||
private $masterStylesCrossReference = [];
|
||||
|
||||
private $masterPrintStylesCrossReference = [];
|
||||
|
||||
public function __construct(DOMDocument $styleDom)
|
||||
{
|
||||
$this->setDomNameSpaces($styleDom);
|
||||
$this->readPageSettingStyles($styleDom);
|
||||
$this->readStyleMasterLookup($styleDom);
|
||||
}
|
||||
|
||||
private function setDomNameSpaces(DOMDocument $styleDom): void
|
||||
{
|
||||
$this->officeNs = $styleDom->lookupNamespaceUri('office');
|
||||
$this->stylesNs = $styleDom->lookupNamespaceUri('style');
|
||||
$this->stylesFo = $styleDom->lookupNamespaceUri('fo');
|
||||
}
|
||||
|
||||
private function readPageSettingStyles(DOMDocument $styleDom): void
|
||||
{
|
||||
$styles = $styleDom->getElementsByTagNameNS($this->officeNs, 'automatic-styles')
|
||||
->item(0)
|
||||
->getElementsByTagNameNS($this->stylesNs, 'page-layout');
|
||||
|
||||
foreach ($styles as $styleSet) {
|
||||
$styleName = $styleSet->getAttributeNS($this->stylesNs, 'name');
|
||||
$pageLayoutProperties = $styleSet->getElementsByTagNameNS($this->stylesNs, 'page-layout-properties')[0];
|
||||
$styleOrientation = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'print-orientation');
|
||||
$styleScale = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'scale-to');
|
||||
$stylePrintOrder = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'print-page-order');
|
||||
$centered = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'table-centering');
|
||||
|
||||
$marginLeft = $pageLayoutProperties->getAttributeNS($this->stylesFo, 'margin-left');
|
||||
$marginRight = $pageLayoutProperties->getAttributeNS($this->stylesFo, 'margin-right');
|
||||
$marginTop = $pageLayoutProperties->getAttributeNS($this->stylesFo, 'margin-top');
|
||||
$marginBottom = $pageLayoutProperties->getAttributeNS($this->stylesFo, 'margin-bottom');
|
||||
$header = $styleSet->getElementsByTagNameNS($this->stylesNs, 'header-style')[0];
|
||||
$headerProperties = $header->getElementsByTagNameNS($this->stylesNs, 'header-footer-properties')[0];
|
||||
$marginHeader = $headerProperties->getAttributeNS($this->stylesFo, 'min-height');
|
||||
$footer = $styleSet->getElementsByTagNameNS($this->stylesNs, 'footer-style')[0];
|
||||
$footerProperties = $footer->getElementsByTagNameNS($this->stylesNs, 'header-footer-properties')[0];
|
||||
$marginFooter = $footerProperties->getAttributeNS($this->stylesFo, 'min-height');
|
||||
|
||||
$this->pageLayoutStyles[$styleName] = (object) [
|
||||
'orientation' => $styleOrientation ?: PageSetup::ORIENTATION_DEFAULT,
|
||||
'scale' => $styleScale ?: 100,
|
||||
'printOrder' => $stylePrintOrder,
|
||||
'horizontalCentered' => $centered === 'horizontal' || $centered === 'both',
|
||||
'verticalCentered' => $centered === 'vertical' || $centered === 'both',
|
||||
// margin size is already stored in inches, so no UOM conversion is required
|
||||
'marginLeft' => (float) $marginLeft ?? 0.7,
|
||||
'marginRight' => (float) $marginRight ?? 0.7,
|
||||
'marginTop' => (float) $marginTop ?? 0.3,
|
||||
'marginBottom' => (float) $marginBottom ?? 0.3,
|
||||
'marginHeader' => (float) $marginHeader ?? 0.45,
|
||||
'marginFooter' => (float) $marginFooter ?? 0.45,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
private function readStyleMasterLookup(DOMDocument $styleDom): void
|
||||
{
|
||||
$styleMasterLookup = $styleDom->getElementsByTagNameNS($this->officeNs, 'master-styles')
|
||||
->item(0)
|
||||
->getElementsByTagNameNS($this->stylesNs, 'master-page');
|
||||
|
||||
foreach ($styleMasterLookup as $styleMasterSet) {
|
||||
$styleMasterName = $styleMasterSet->getAttributeNS($this->stylesNs, 'name');
|
||||
$pageLayoutName = $styleMasterSet->getAttributeNS($this->stylesNs, 'page-layout-name');
|
||||
$this->masterPrintStylesCrossReference[$styleMasterName] = $pageLayoutName;
|
||||
}
|
||||
}
|
||||
|
||||
public function readStyleCrossReferences(DOMDocument $contentDom): void
|
||||
{
|
||||
$styleXReferences = $contentDom->getElementsByTagNameNS($this->officeNs, 'automatic-styles')
|
||||
->item(0)
|
||||
->getElementsByTagNameNS($this->stylesNs, 'style');
|
||||
|
||||
foreach ($styleXReferences as $styleXreferenceSet) {
|
||||
$styleXRefName = $styleXreferenceSet->getAttributeNS($this->stylesNs, 'name');
|
||||
$stylePageLayoutName = $styleXreferenceSet->getAttributeNS($this->stylesNs, 'master-page-name');
|
||||
if (!empty($stylePageLayoutName)) {
|
||||
$this->masterStylesCrossReference[$styleXRefName] = $stylePageLayoutName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setPrintSettingsForWorksheet(Worksheet $worksheet, string $styleName): void
|
||||
{
|
||||
if (!array_key_exists($styleName, $this->masterStylesCrossReference)) {
|
||||
return;
|
||||
}
|
||||
$masterStyleName = $this->masterStylesCrossReference[$styleName];
|
||||
|
||||
if (!array_key_exists($masterStyleName, $this->masterPrintStylesCrossReference)) {
|
||||
return;
|
||||
}
|
||||
$printSettingsIndex = $this->masterPrintStylesCrossReference[$masterStyleName];
|
||||
|
||||
if (!array_key_exists($printSettingsIndex, $this->pageLayoutStyles)) {
|
||||
return;
|
||||
}
|
||||
$printSettings = $this->pageLayoutStyles[$printSettingsIndex];
|
||||
|
||||
$worksheet->getPageSetup()
|
||||
->setOrientation($printSettings->orientation ?? PageSetup::ORIENTATION_DEFAULT)
|
||||
->setPageOrder($printSettings->printOrder === 'ltr' ? PageSetup::PAGEORDER_OVER_THEN_DOWN : PageSetup::PAGEORDER_DOWN_THEN_OVER)
|
||||
->setScale((int) trim($printSettings->scale, '%'))
|
||||
->setHorizontalCentered($printSettings->horizontalCentered)
|
||||
->setVerticalCentered($printSettings->verticalCentered);
|
||||
|
||||
$worksheet->getPageMargins()
|
||||
->setLeft($printSettings->marginLeft)
|
||||
->setRight($printSettings->marginRight)
|
||||
->setTop($printSettings->marginTop)
|
||||
->setBottom($printSettings->marginBottom)
|
||||
->setHeader($printSettings->marginHeader)
|
||||
->setFooter($printSettings->marginFooter);
|
||||
}
|
||||
}
|
|
@ -54,15 +54,11 @@ class Properties
|
|||
$docProps->setLastModifiedBy($propertyValue);
|
||||
|
||||
break;
|
||||
case 'creation-date':
|
||||
case 'date':
|
||||
$creationDate = strtotime($propertyValue);
|
||||
$docProps->setCreated($creationDate);
|
||||
$docProps->setModified($creationDate);
|
||||
|
||||
break;
|
||||
case 'keyword':
|
||||
$docProps->setKeywords($propertyValue);
|
||||
|
||||
break;
|
||||
case 'description':
|
||||
$docProps->setDescription($propertyValue);
|
||||
|
|
|
@ -63,7 +63,7 @@ class XmlScanner
|
|||
|
||||
private function disableEntityLoaderCheck(): void
|
||||
{
|
||||
if (Settings::getLibXmlDisableEntityLoader()) {
|
||||
if (Settings::getLibXmlDisableEntityLoader() && \PHP_VERSION_ID < 80000) {
|
||||
$libxmlDisableEntityLoaderValue = libxml_disable_entity_loader(true);
|
||||
|
||||
if (self::$libxmlDisableEntityLoaderValue === null) {
|
||||
|
@ -74,7 +74,7 @@ class XmlScanner
|
|||
|
||||
public static function shutdown(): void
|
||||
{
|
||||
if (self::$libxmlDisableEntityLoaderValue !== null) {
|
||||
if (self::$libxmlDisableEntityLoaderValue !== null && \PHP_VERSION_ID < 80000) {
|
||||
libxml_disable_entity_loader(self::$libxmlDisableEntityLoaderValue);
|
||||
self::$libxmlDisableEntityLoaderValue = null;
|
||||
}
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Reader;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
|
@ -38,6 +40,20 @@ class Slk extends BaseReader
|
|||
*/
|
||||
private $format = 0;
|
||||
|
||||
/**
|
||||
* Fonts.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $fonts = [];
|
||||
|
||||
/**
|
||||
* Font Count.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $fontcount = 0;
|
||||
|
||||
/**
|
||||
* Create a new SYLK Reader instance.
|
||||
*/
|
||||
|
@ -55,10 +71,9 @@ class Slk extends BaseReader
|
|||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
try {
|
||||
$this->openFile($pFilename);
|
||||
} catch (Exception $e) {
|
||||
} catch (InvalidArgumentException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -78,12 +93,24 @@ class Slk extends BaseReader
|
|||
return $hasDelimiter && $hasId;
|
||||
}
|
||||
|
||||
private function canReadOrBust(string $pFilename): void
|
||||
{
|
||||
if (!$this->canRead($pFilename)) {
|
||||
throw new ReaderException($pFilename . ' is an Invalid SYLK file.');
|
||||
}
|
||||
$this->openFile($pFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set input encoding.
|
||||
*
|
||||
* @deprecated no use is made of this property
|
||||
*
|
||||
* @param string $pValue Input encoding, eg: 'ANSI'
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function setInputEncoding($pValue)
|
||||
{
|
||||
|
@ -95,7 +122,11 @@ class Slk extends BaseReader
|
|||
/**
|
||||
* Get input encoding.
|
||||
*
|
||||
* @deprecated no use is made of this property
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getInputEncoding()
|
||||
{
|
||||
|
@ -112,22 +143,16 @@ class Slk extends BaseReader
|
|||
public function listWorksheetInfo($pFilename)
|
||||
{
|
||||
// Open file
|
||||
if (!$this->canRead($pFilename)) {
|
||||
throw new Exception($pFilename . ' is an Invalid Spreadsheet file.');
|
||||
}
|
||||
$this->openFile($pFilename);
|
||||
$this->canReadOrBust($pFilename);
|
||||
$fileHandle = $this->fileHandle;
|
||||
rewind($fileHandle);
|
||||
|
||||
$worksheetInfo = [];
|
||||
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
|
||||
$worksheetInfo[0]['lastColumnLetter'] = 'A';
|
||||
$worksheetInfo[0]['lastColumnIndex'] = 0;
|
||||
$worksheetInfo[0]['totalRows'] = 0;
|
||||
$worksheetInfo[0]['totalColumns'] = 0;
|
||||
$worksheetInfo[0]['worksheetName'] = basename($pFilename, '.slk');
|
||||
|
||||
// loop through one row (line) at a time in the file
|
||||
$rowIndex = 0;
|
||||
$columnIndex = 0;
|
||||
while (($rowData = fgets($fileHandle)) !== false) {
|
||||
$columnIndex = 0;
|
||||
|
||||
|
@ -139,28 +164,26 @@ class Slk extends BaseReader
|
|||
$rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData)))));
|
||||
|
||||
$dataType = array_shift($rowData);
|
||||
if ($dataType == 'C') {
|
||||
// Read cell value data
|
||||
if ($dataType == 'B') {
|
||||
foreach ($rowData as $rowDatum) {
|
||||
switch ($rowDatum[0]) {
|
||||
case 'C':
|
||||
case 'X':
|
||||
$columnIndex = substr($rowDatum, 1) - 1;
|
||||
|
||||
break;
|
||||
case 'R':
|
||||
case 'Y':
|
||||
$rowIndex = substr($rowDatum, 1);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$worksheetInfo[0]['totalRows'] = max($worksheetInfo[0]['totalRows'], $rowIndex);
|
||||
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], $columnIndex);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$worksheetInfo[0]['lastColumnIndex'] = $columnIndex;
|
||||
$worksheetInfo[0]['totalRows'] = $rowIndex;
|
||||
$worksheetInfo[0]['lastColumnLetter'] = Coordinate::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex'] + 1);
|
||||
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
|
||||
|
||||
|
@ -186,120 +209,25 @@ class Slk extends BaseReader
|
|||
return $this->loadIntoExisting($pFilename, $spreadsheet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
|
||||
*
|
||||
* @param string $pFilename
|
||||
*
|
||||
* @return Spreadsheet
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet)
|
||||
private $colorArray = [
|
||||
'FF00FFFF', // 0 - cyan
|
||||
'FF000000', // 1 - black
|
||||
'FFFFFFFF', // 2 - white
|
||||
'FFFF0000', // 3 - red
|
||||
'FF00FF00', // 4 - green
|
||||
'FF0000FF', // 5 - blue
|
||||
'FFFFFF00', // 6 - yellow
|
||||
'FFFF00FF', // 7 - magenta
|
||||
];
|
||||
|
||||
private $fontStyleMappings = [
|
||||
'B' => 'bold',
|
||||
'I' => 'italic',
|
||||
'U' => 'underline',
|
||||
];
|
||||
|
||||
private function processFormula(string $rowDatum, bool &$hasCalculatedValue, string &$cellDataFormula, string $row, string $column): void
|
||||
{
|
||||
// Open file
|
||||
if (!$this->canRead($pFilename)) {
|
||||
throw new Exception($pFilename . ' is an Invalid Spreadsheet file.');
|
||||
}
|
||||
$this->openFile($pFilename);
|
||||
$fileHandle = $this->fileHandle;
|
||||
rewind($fileHandle);
|
||||
|
||||
// Create new Worksheets
|
||||
while ($spreadsheet->getSheetCount() <= $this->sheetIndex) {
|
||||
$spreadsheet->createSheet();
|
||||
}
|
||||
$spreadsheet->setActiveSheetIndex($this->sheetIndex);
|
||||
|
||||
$fromFormats = ['\-', '\ '];
|
||||
$toFormats = ['-', ' '];
|
||||
|
||||
// Loop through file
|
||||
$column = $row = '';
|
||||
|
||||
// loop through one row (line) at a time in the file
|
||||
while (($rowData = fgets($fileHandle)) !== false) {
|
||||
// convert SYLK encoded $rowData to UTF-8
|
||||
$rowData = StringHelper::SYLKtoUTF8($rowData);
|
||||
|
||||
// explode each row at semicolons while taking into account that literal semicolon (;)
|
||||
// is escaped like this (;;)
|
||||
$rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData)))));
|
||||
|
||||
$dataType = array_shift($rowData);
|
||||
// Read shared styles
|
||||
if ($dataType == 'P') {
|
||||
$formatArray = [];
|
||||
foreach ($rowData as $rowDatum) {
|
||||
switch ($rowDatum[0]) {
|
||||
case 'P':
|
||||
$formatArray['numberFormat']['formatCode'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1));
|
||||
|
||||
break;
|
||||
case 'E':
|
||||
case 'F':
|
||||
$formatArray['font']['name'] = substr($rowDatum, 1);
|
||||
|
||||
break;
|
||||
case 'L':
|
||||
$formatArray['font']['size'] = substr($rowDatum, 1);
|
||||
|
||||
break;
|
||||
case 'S':
|
||||
$styleSettings = substr($rowDatum, 1);
|
||||
$iMax = strlen($styleSettings);
|
||||
for ($i = 0; $i < $iMax; ++$i) {
|
||||
switch ($styleSettings[$i]) {
|
||||
case 'I':
|
||||
$formatArray['font']['italic'] = true;
|
||||
|
||||
break;
|
||||
case 'D':
|
||||
$formatArray['font']['bold'] = true;
|
||||
|
||||
break;
|
||||
case 'T':
|
||||
$formatArray['borders']['top']['borderStyle'] = Border::BORDER_THIN;
|
||||
|
||||
break;
|
||||
case 'B':
|
||||
$formatArray['borders']['bottom']['borderStyle'] = Border::BORDER_THIN;
|
||||
|
||||
break;
|
||||
case 'L':
|
||||
$formatArray['borders']['left']['borderStyle'] = Border::BORDER_THIN;
|
||||
|
||||
break;
|
||||
case 'R':
|
||||
$formatArray['borders']['right']['borderStyle'] = Border::BORDER_THIN;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->formats['P' . $this->format++] = $formatArray;
|
||||
// Read cell value data
|
||||
} elseif ($dataType == 'C') {
|
||||
$hasCalculatedValue = false;
|
||||
$cellData = $cellDataFormula = '';
|
||||
foreach ($rowData as $rowDatum) {
|
||||
switch ($rowDatum[0]) {
|
||||
case 'C':
|
||||
case 'X':
|
||||
$column = substr($rowDatum, 1);
|
||||
|
||||
break;
|
||||
case 'R':
|
||||
case 'Y':
|
||||
$row = substr($rowDatum, 1);
|
||||
|
||||
break;
|
||||
case 'K':
|
||||
$cellData = substr($rowDatum, 1);
|
||||
|
||||
break;
|
||||
case 'E':
|
||||
$cellDataFormula = '=' . substr($rowDatum, 1);
|
||||
// Convert R1C1 style references to A1 style references (but only when not quoted)
|
||||
$temp = explode('"', $cellDataFormula);
|
||||
|
@ -343,22 +271,58 @@ class Slk extends BaseReader
|
|||
// Then rebuild the formula string
|
||||
$cellDataFormula = implode('"', $temp);
|
||||
$hasCalculatedValue = true;
|
||||
}
|
||||
|
||||
private function processCRecord(array $rowData, Spreadsheet &$spreadsheet, string &$row, string &$column): void
|
||||
{
|
||||
// Read cell value data
|
||||
$hasCalculatedValue = false;
|
||||
$cellDataFormula = $cellData = '';
|
||||
foreach ($rowData as $rowDatum) {
|
||||
switch ($rowDatum[0]) {
|
||||
case 'C':
|
||||
case 'X':
|
||||
$column = substr($rowDatum, 1);
|
||||
|
||||
break;
|
||||
case 'R':
|
||||
case 'Y':
|
||||
$row = substr($rowDatum, 1);
|
||||
|
||||
break;
|
||||
case 'K':
|
||||
$cellData = substr($rowDatum, 1);
|
||||
|
||||
break;
|
||||
case 'E':
|
||||
$this->processFormula($rowDatum, $hasCalculatedValue, $cellDataFormula, $row, $column);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
$columnLetter = Coordinate::stringFromColumnIndex($column);
|
||||
$columnLetter = Coordinate::stringFromColumnIndex((int) $column);
|
||||
$cellData = Calculation::unwrapResult($cellData);
|
||||
|
||||
// Set cell value
|
||||
$spreadsheet->getActiveSheet()->getCell($columnLetter . $row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
|
||||
$this->processCFinal($spreadsheet, $hasCalculatedValue, $cellDataFormula, $cellData, "$columnLetter$row");
|
||||
}
|
||||
|
||||
private function processCFinal(Spreadsheet &$spreadsheet, bool $hasCalculatedValue, string $cellDataFormula, string $cellData, string $coordinate): void
|
||||
{
|
||||
// Set cell value
|
||||
$spreadsheet->getActiveSheet()->getCell($coordinate)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
|
||||
if ($hasCalculatedValue) {
|
||||
$cellData = Calculation::unwrapResult($cellData);
|
||||
$spreadsheet->getActiveSheet()->getCell($columnLetter . $row)->setCalculatedValue($cellData);
|
||||
$spreadsheet->getActiveSheet()->getCell($coordinate)->setCalculatedValue($cellData);
|
||||
}
|
||||
}
|
||||
|
||||
private function processFRecord(array $rowData, Spreadsheet &$spreadsheet, string &$row, string &$column): void
|
||||
{
|
||||
// Read cell formatting
|
||||
} elseif ($dataType == 'F') {
|
||||
$formatStyle = $columnWidth = $styleSettings = '';
|
||||
$formatStyle = $columnWidth = '';
|
||||
$startCol = $endCol = '';
|
||||
$fontStyle = '';
|
||||
$styleData = [];
|
||||
foreach ($rowData as $rowDatum) {
|
||||
switch ($rowDatum[0]) {
|
||||
|
@ -381,78 +345,203 @@ class Slk extends BaseReader
|
|||
|
||||
break;
|
||||
case 'S':
|
||||
$this->styleSettings($rowDatum, $styleData, $fontStyle);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->addFormats($spreadsheet, $formatStyle, $row, $column);
|
||||
$this->addFonts($spreadsheet, $fontStyle, $row, $column);
|
||||
$this->addStyle($spreadsheet, $styleData, $row, $column);
|
||||
$this->addWidth($spreadsheet, $columnWidth, $startCol, $endCol);
|
||||
}
|
||||
|
||||
private $styleSettingsFont = ['D' => 'bold', 'I' => 'italic'];
|
||||
|
||||
private $styleSettingsBorder = [
|
||||
'B' => 'bottom',
|
||||
'L' => 'left',
|
||||
'R' => 'right',
|
||||
'T' => 'top',
|
||||
];
|
||||
|
||||
private function styleSettings(string $rowDatum, array &$styleData, string &$fontStyle): void
|
||||
{
|
||||
$styleSettings = substr($rowDatum, 1);
|
||||
$iMax = strlen($styleSettings);
|
||||
for ($i = 0; $i < $iMax; ++$i) {
|
||||
switch ($styleSettings[$i]) {
|
||||
case 'I':
|
||||
$styleData['font']['italic'] = true;
|
||||
|
||||
break;
|
||||
case 'D':
|
||||
$styleData['font']['bold'] = true;
|
||||
|
||||
break;
|
||||
case 'T':
|
||||
$styleData['borders']['top']['borderStyle'] = Border::BORDER_THIN;
|
||||
|
||||
break;
|
||||
case 'B':
|
||||
$styleData['borders']['bottom']['borderStyle'] = Border::BORDER_THIN;
|
||||
|
||||
break;
|
||||
case 'L':
|
||||
$styleData['borders']['left']['borderStyle'] = Border::BORDER_THIN;
|
||||
|
||||
break;
|
||||
case 'R':
|
||||
$styleData['borders']['right']['borderStyle'] = Border::BORDER_THIN;
|
||||
|
||||
break;
|
||||
$char = $styleSettings[$i];
|
||||
if (array_key_exists($char, $this->styleSettingsFont)) {
|
||||
$styleData['font'][$this->styleSettingsFont[$char]] = true;
|
||||
} elseif (array_key_exists($char, $this->styleSettingsBorder)) {
|
||||
$styleData['borders'][$this->styleSettingsBorder[$char]]['borderStyle'] = Border::BORDER_THIN;
|
||||
} elseif ($char == 'S') {
|
||||
$styleData['fill']['fillType'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY125;
|
||||
} elseif ($char == 'M') {
|
||||
if (preg_match('/M([1-9]\\d*)/', $styleSettings, $matches)) {
|
||||
$fontStyle = $matches[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (($formatStyle > '') && ($column > '') && ($row > '')) {
|
||||
$columnLetter = Coordinate::stringFromColumnIndex($column);
|
||||
private function addFormats(Spreadsheet &$spreadsheet, string $formatStyle, string $row, string $column): void
|
||||
{
|
||||
if ($formatStyle && $column > '' && $row > '') {
|
||||
$columnLetter = Coordinate::stringFromColumnIndex((int) $column);
|
||||
if (isset($this->formats[$formatStyle])) {
|
||||
$spreadsheet->getActiveSheet()->getStyle($columnLetter . $row)->applyFromArray($this->formats[$formatStyle]);
|
||||
}
|
||||
}
|
||||
if ((!empty($styleData)) && ($column > '') && ($row > '')) {
|
||||
}
|
||||
|
||||
private function addFonts(Spreadsheet &$spreadsheet, string $fontStyle, string $row, string $column): void
|
||||
{
|
||||
if ($fontStyle && $column > '' && $row > '') {
|
||||
$columnLetter = Coordinate::stringFromColumnIndex((int) $column);
|
||||
if (isset($this->fonts[$fontStyle])) {
|
||||
$spreadsheet->getActiveSheet()->getStyle($columnLetter . $row)->applyFromArray($this->fonts[$fontStyle]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function addStyle(Spreadsheet &$spreadsheet, array $styleData, string $row, string $column): void
|
||||
{
|
||||
if ((!empty($styleData)) && $column > '' && $row > '') {
|
||||
$columnLetter = Coordinate::stringFromColumnIndex($column);
|
||||
$spreadsheet->getActiveSheet()->getStyle($columnLetter . $row)->applyFromArray($styleData);
|
||||
}
|
||||
}
|
||||
|
||||
private function addWidth(Spreadsheet $spreadsheet, string $columnWidth, string $startCol, string $endCol): void
|
||||
{
|
||||
if ($columnWidth > '') {
|
||||
if ($startCol == $endCol) {
|
||||
$startCol = Coordinate::stringFromColumnIndex($startCol);
|
||||
$startCol = Coordinate::stringFromColumnIndex((int) $startCol);
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
|
||||
} else {
|
||||
$startCol = Coordinate::stringFromColumnIndex($startCol);
|
||||
$endCol = Coordinate::stringFromColumnIndex($endCol);
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension($startCol)->setWidth((float) $columnWidth);
|
||||
do {
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth);
|
||||
} while ($startCol != $endCol);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
private function processPRecord(array $rowData, Spreadsheet &$spreadsheet): void
|
||||
{
|
||||
// Read shared styles
|
||||
$formatArray = [];
|
||||
$fromFormats = ['\-', '\ '];
|
||||
$toFormats = ['-', ' '];
|
||||
foreach ($rowData as $rowDatum) {
|
||||
switch ($rowDatum[0]) {
|
||||
case 'C':
|
||||
case 'X':
|
||||
$column = substr($rowDatum, 1);
|
||||
case 'P':
|
||||
$formatArray['numberFormat']['formatCode'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1));
|
||||
|
||||
break;
|
||||
case 'R':
|
||||
case 'Y':
|
||||
$row = substr($rowDatum, 1);
|
||||
case 'E':
|
||||
case 'F':
|
||||
$formatArray['font']['name'] = substr($rowDatum, 1);
|
||||
|
||||
break;
|
||||
case 'M':
|
||||
$formatArray['font']['size'] = substr($rowDatum, 1) / 20;
|
||||
|
||||
break;
|
||||
case 'L':
|
||||
$this->processPColors($rowDatum, $formatArray);
|
||||
|
||||
break;
|
||||
case 'S':
|
||||
$this->processPFontStyles($rowDatum, $formatArray);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->processPFinal($spreadsheet, $formatArray);
|
||||
}
|
||||
|
||||
private function processPColors(string $rowDatum, array &$formatArray): void
|
||||
{
|
||||
if (preg_match('/L([1-9]\\d*)/', $rowDatum, $matches)) {
|
||||
$fontColor = $matches[1] % 8;
|
||||
$formatArray['font']['color']['argb'] = $this->colorArray[$fontColor];
|
||||
}
|
||||
}
|
||||
|
||||
private function processPFontStyles(string $rowDatum, array &$formatArray): void
|
||||
{
|
||||
$styleSettings = substr($rowDatum, 1);
|
||||
$iMax = strlen($styleSettings);
|
||||
for ($i = 0; $i < $iMax; ++$i) {
|
||||
if (array_key_exists($styleSettings[$i], $this->fontStyleMappings)) {
|
||||
$formatArray['font'][$this->fontStyleMappings[$styleSettings[$i]]] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function processPFinal(Spreadsheet &$spreadsheet, array $formatArray): void
|
||||
{
|
||||
if (array_key_exists('numberFormat', $formatArray)) {
|
||||
$this->formats['P' . $this->format] = $formatArray;
|
||||
++$this->format;
|
||||
} elseif (array_key_exists('font', $formatArray)) {
|
||||
++$this->fontcount;
|
||||
$this->fonts[$this->fontcount] = $formatArray;
|
||||
if ($this->fontcount === 1) {
|
||||
$spreadsheet->getDefaultStyle()->applyFromArray($formatArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
|
||||
*
|
||||
* @param string $pFilename
|
||||
*
|
||||
* @return Spreadsheet
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet)
|
||||
{
|
||||
// Open file
|
||||
$this->canReadOrBust($pFilename);
|
||||
$fileHandle = $this->fileHandle;
|
||||
rewind($fileHandle);
|
||||
|
||||
// Create new Worksheets
|
||||
while ($spreadsheet->getSheetCount() <= $this->sheetIndex) {
|
||||
$spreadsheet->createSheet();
|
||||
}
|
||||
$spreadsheet->setActiveSheetIndex($this->sheetIndex);
|
||||
$spreadsheet->getActiveSheet()->setTitle(basename($pFilename, '.slk'));
|
||||
|
||||
// Loop through file
|
||||
$column = $row = '';
|
||||
|
||||
// loop through one row (line) at a time in the file
|
||||
while (($rowDataTxt = fgets($fileHandle)) !== false) {
|
||||
// convert SYLK encoded $rowData to UTF-8
|
||||
$rowDataTxt = StringHelper::SYLKtoUTF8($rowDataTxt);
|
||||
|
||||
// explode each row at semicolons while taking into account that literal semicolon (;)
|
||||
// is escaped like this (;;)
|
||||
$rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowDataTxt)))));
|
||||
|
||||
$dataType = array_shift($rowData);
|
||||
if ($dataType == 'P') {
|
||||
// Read shared styles
|
||||
$this->processPRecord($rowData, $spreadsheet);
|
||||
} elseif ($dataType == 'C') {
|
||||
// Read cell value data
|
||||
$this->processCRecord($rowData, $spreadsheet, $row, $column);
|
||||
} elseif ($dataType == 'F') {
|
||||
// Read cell formatting
|
||||
$this->processFRecord($rowData, $spreadsheet, $row, $column);
|
||||
} else {
|
||||
$this->columnRowFromRowData($rowData, $column, $row);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -463,6 +552,18 @@ class Slk extends BaseReader
|
|||
return $spreadsheet;
|
||||
}
|
||||
|
||||
private function columnRowFromRowData(array $rowData, string &$column, string &$row): void
|
||||
{
|
||||
foreach ($rowData as $rowDatum) {
|
||||
$char0 = $rowDatum[0];
|
||||
if ($char0 === 'X' || $char0 == 'C') {
|
||||
$column = substr($rowDatum, 1);
|
||||
} elseif ($char0 === 'Y' || $char0 == 'R') {
|
||||
$row = substr($rowDatum, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sheet index.
|
||||
*
|
||||
|
|
|
@ -439,6 +439,15 @@ class Xls extends BaseReader
|
|||
}
|
||||
}
|
||||
|
||||
public function setCodepage(string $codepage): void
|
||||
{
|
||||
if (!CodePage::validate($codepage)) {
|
||||
throw new PhpSpreadsheetException('Unknown codepage: ' . $codepage);
|
||||
}
|
||||
|
||||
$this->codepage = $codepage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads names of the worksheets from a file, without parsing the whole file to a PhpSpreadsheet object.
|
||||
*
|
||||
|
@ -640,7 +649,7 @@ class Xls extends BaseReader
|
|||
|
||||
// initialize
|
||||
$this->pos = 0;
|
||||
$this->codepage = 'CP1252';
|
||||
$this->codepage = $this->codepage ?: CodePage::DEFAULT_CODE_PAGE;
|
||||
$this->formats = [];
|
||||
$this->objFonts = [];
|
||||
$this->palette = [];
|
||||
|
@ -1266,8 +1275,10 @@ class Xls extends BaseReader
|
|||
// Extract range
|
||||
if (strpos($definedName['formula'], '!') !== false) {
|
||||
$explodes = Worksheet::extractSheetTitle($definedName['formula'], true);
|
||||
if (($docSheet = $this->spreadsheet->getSheetByName($explodes[0])) ||
|
||||
($docSheet = $this->spreadsheet->getSheetByName(trim($explodes[0], "'")))) {
|
||||
if (
|
||||
($docSheet = $this->spreadsheet->getSheetByName($explodes[0])) ||
|
||||
($docSheet = $this->spreadsheet->getSheetByName(trim($explodes[0], "'")))
|
||||
) {
|
||||
$extractedRange = $explodes[1];
|
||||
$extractedRange = str_replace('$', '', $extractedRange);
|
||||
|
||||
|
@ -3435,6 +3446,9 @@ class Xls extends BaseReader
|
|||
|
||||
// offset: 10; size: 2; option flags
|
||||
|
||||
// bit: 0; mask: 0x0001; 0=down then over, 1=over then down
|
||||
$isOverThenDown = (0x0001 & self::getUInt2d($recordData, 10));
|
||||
|
||||
// bit: 1; mask: 0x0002; 0=landscape, 1=portrait
|
||||
$isPortrait = (0x0002 & self::getUInt2d($recordData, 10)) >> 1;
|
||||
|
||||
|
@ -3444,16 +3458,8 @@ class Xls extends BaseReader
|
|||
|
||||
if (!$isNotInit) {
|
||||
$this->phpSheet->getPageSetup()->setPaperSize($paperSize);
|
||||
switch ($isPortrait) {
|
||||
case 0:
|
||||
$this->phpSheet->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE);
|
||||
|
||||
break;
|
||||
case 1:
|
||||
$this->phpSheet->getPageSetup()->setOrientation(PageSetup::ORIENTATION_PORTRAIT);
|
||||
|
||||
break;
|
||||
}
|
||||
$this->phpSheet->getPageSetup()->setPageOrder(((bool) $isOverThenDown) ? PageSetup::PAGEORDER_OVER_THEN_DOWN : PageSetup::PAGEORDER_DOWN_THEN_OVER);
|
||||
$this->phpSheet->getPageSetup()->setOrientation(((bool) $isPortrait) ? PageSetup::ORIENTATION_PORTRAIT : PageSetup::ORIENTATION_LANDSCAPE);
|
||||
|
||||
$this->phpSheet->getPageSetup()->setScale($scale, false);
|
||||
$this->phpSheet->getPageSetup()->setFitToPage((bool) $this->isFitToPages);
|
||||
|
@ -3622,10 +3628,12 @@ class Xls extends BaseReader
|
|||
$this->phpSheet->getColumnDimensionByColumn($i)->setVisible(!$isHidden);
|
||||
$this->phpSheet->getColumnDimensionByColumn($i)->setOutlineLevel($level);
|
||||
$this->phpSheet->getColumnDimensionByColumn($i)->setCollapsed($isCollapsed);
|
||||
if (isset($this->mapCellXfIndex[$xfIndex])) {
|
||||
$this->phpSheet->getColumnDimensionByColumn($i)->setXfIndex($this->mapCellXfIndex[$xfIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ROW.
|
||||
|
@ -3731,7 +3739,7 @@ class Xls extends BaseReader
|
|||
$numValue = self::getIEEE754($rknum);
|
||||
|
||||
$cell = $this->phpSheet->getCell($columnString . ($row + 1));
|
||||
if (!$this->readDataOnly) {
|
||||
if (!$this->readDataOnly && isset($this->mapCellXfIndex[$xfIndex])) {
|
||||
// add style information
|
||||
$cell->setXfIndex($this->mapCellXfIndex[$xfIndex]);
|
||||
}
|
||||
|
@ -3866,7 +3874,7 @@ class Xls extends BaseReader
|
|||
// offset: var; size: 4; RK value
|
||||
$numValue = self::getIEEE754(self::getInt4d($recordData, $offset + 2));
|
||||
$cell = $this->phpSheet->getCell($columnString . ($row + 1));
|
||||
if (!$this->readDataOnly) {
|
||||
if (!$this->readDataOnly && isset($this->mapCellXfIndex[$xfIndex])) {
|
||||
// add style
|
||||
$cell->setXfIndex($this->mapCellXfIndex[$xfIndex]);
|
||||
}
|
||||
|
@ -3910,7 +3918,7 @@ class Xls extends BaseReader
|
|||
$numValue = self::extractNumber(substr($recordData, 6, 8));
|
||||
|
||||
$cell = $this->phpSheet->getCell($columnString . ($row + 1));
|
||||
if (!$this->readDataOnly) {
|
||||
if (!$this->readDataOnly && isset($this->mapCellXfIndex[$xfIndex])) {
|
||||
// add cell style
|
||||
$cell->setXfIndex($this->mapCellXfIndex[$xfIndex]);
|
||||
}
|
||||
|
@ -3993,21 +4001,27 @@ class Xls extends BaseReader
|
|||
|
||||
// read STRING record
|
||||
$value = $this->readString();
|
||||
} elseif ((ord($recordData[6]) == 1)
|
||||
} elseif (
|
||||
(ord($recordData[6]) == 1)
|
||||
&& (ord($recordData[12]) == 255)
|
||||
&& (ord($recordData[13]) == 255)) {
|
||||
&& (ord($recordData[13]) == 255)
|
||||
) {
|
||||
// Boolean formula. Result is in +2; 0=false, 1=true
|
||||
$dataType = DataType::TYPE_BOOL;
|
||||
$value = (bool) ord($recordData[8]);
|
||||
} elseif ((ord($recordData[6]) == 2)
|
||||
} elseif (
|
||||
(ord($recordData[6]) == 2)
|
||||
&& (ord($recordData[12]) == 255)
|
||||
&& (ord($recordData[13]) == 255)) {
|
||||
&& (ord($recordData[13]) == 255)
|
||||
) {
|
||||
// Error formula. Error code is in +2
|
||||
$dataType = DataType::TYPE_ERROR;
|
||||
$value = Xls\ErrorCode::lookup(ord($recordData[8]));
|
||||
} elseif ((ord($recordData[6]) == 3)
|
||||
} elseif (
|
||||
(ord($recordData[6]) == 3)
|
||||
&& (ord($recordData[12]) == 255)
|
||||
&& (ord($recordData[13]) == 255)) {
|
||||
&& (ord($recordData[13]) == 255)
|
||||
) {
|
||||
// Formula result is a null string
|
||||
$dataType = DataType::TYPE_NULL;
|
||||
$value = '';
|
||||
|
@ -4018,7 +4032,7 @@ class Xls extends BaseReader
|
|||
}
|
||||
|
||||
$cell = $this->phpSheet->getCell($columnString . ($row + 1));
|
||||
if (!$this->readDataOnly) {
|
||||
if (!$this->readDataOnly && isset($this->mapCellXfIndex[$xfIndex])) {
|
||||
// add cell style
|
||||
$cell->setXfIndex($this->mapCellXfIndex[$xfIndex]);
|
||||
}
|
||||
|
@ -4156,7 +4170,7 @@ class Xls extends BaseReader
|
|||
break;
|
||||
}
|
||||
|
||||
if (!$this->readDataOnly) {
|
||||
if (!$this->readDataOnly && isset($this->mapCellXfIndex[$xfIndex])) {
|
||||
// add cell style
|
||||
$cell->setXfIndex($this->mapCellXfIndex[$xfIndex]);
|
||||
}
|
||||
|
@ -4194,10 +4208,12 @@ class Xls extends BaseReader
|
|||
// Read cell?
|
||||
if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) {
|
||||
$xfIndex = self::getUInt2d($recordData, 4 + 2 * $i);
|
||||
if (isset($this->mapCellXfIndex[$xfIndex])) {
|
||||
$this->phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->mapCellXfIndex[$xfIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// offset: 6; size 2; index to last column (not needed)
|
||||
}
|
||||
|
@ -4245,7 +4261,7 @@ class Xls extends BaseReader
|
|||
$cell = $this->phpSheet->getCell($columnString . ($row + 1));
|
||||
$cell->setValueExplicit($value, DataType::TYPE_STRING);
|
||||
|
||||
if (!$this->readDataOnly) {
|
||||
if (!$this->readDataOnly && isset($this->mapCellXfIndex[$xfIndex])) {
|
||||
// add cell style
|
||||
$cell->setXfIndex($this->mapCellXfIndex[$xfIndex]);
|
||||
}
|
||||
|
@ -4277,7 +4293,7 @@ class Xls extends BaseReader
|
|||
$xfIndex = self::getUInt2d($recordData, 4);
|
||||
|
||||
// add style information
|
||||
if (!$this->readDataOnly && $this->readEmptyCells) {
|
||||
if (!$this->readDataOnly && $this->readEmptyCells && isset($this->mapCellXfIndex[$xfIndex])) {
|
||||
$this->phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->mapCellXfIndex[$xfIndex]);
|
||||
}
|
||||
}
|
||||
|
@ -4361,11 +4377,22 @@ class Xls extends BaseReader
|
|||
// offset: 10; size: 2; cached magnification factor in page break preview (in percent); 0 = Default (60%)
|
||||
// offset: 12; size: 2; cached magnification factor in normal view (in percent); 0 = Default (100%)
|
||||
// offset: 14; size: 4; not used
|
||||
if (!isset($recordData[10])) {
|
||||
$zoomscaleInPageBreakPreview = 0;
|
||||
} else {
|
||||
$zoomscaleInPageBreakPreview = self::getUInt2d($recordData, 10);
|
||||
}
|
||||
|
||||
if ($zoomscaleInPageBreakPreview === 0) {
|
||||
$zoomscaleInPageBreakPreview = 60;
|
||||
}
|
||||
|
||||
if (!isset($recordData[12])) {
|
||||
$zoomscaleInNormalView = 0;
|
||||
} else {
|
||||
$zoomscaleInNormalView = self::getUInt2d($recordData, 12);
|
||||
}
|
||||
|
||||
if ($zoomscaleInNormalView === 0) {
|
||||
$zoomscaleInNormalView = 100;
|
||||
}
|
||||
|
@ -4591,8 +4618,10 @@ class Xls extends BaseReader
|
|||
if ($this->version == self::XLS_BIFF8 && !$this->readDataOnly) {
|
||||
$cellRangeAddressList = $this->readBIFF8CellRangeAddressList($recordData);
|
||||
foreach ($cellRangeAddressList['cellRangeAddresses'] as $cellRangeAddress) {
|
||||
if ((strpos($cellRangeAddress, ':') !== false) &&
|
||||
($this->includeCellRangeFiltered($cellRangeAddress))) {
|
||||
if (
|
||||
(strpos($cellRangeAddress, ':') !== false) &&
|
||||
($this->includeCellRangeFiltered($cellRangeAddress))
|
||||
) {
|
||||
$this->phpSheet->mergeCells($cellRangeAddress);
|
||||
}
|
||||
}
|
||||
|
@ -4940,6 +4969,7 @@ class Xls extends BaseReader
|
|||
// offset: var; size: $sz1; formula data for first condition (without size field)
|
||||
$formula1 = substr($recordData, $offset, $sz1);
|
||||
$formula1 = pack('v', $sz1) . $formula1; // prepend the length
|
||||
|
||||
try {
|
||||
$formula1 = $this->getFormulaFromStructure($formula1);
|
||||
|
||||
|
@ -4962,6 +4992,7 @@ class Xls extends BaseReader
|
|||
// offset: var; size: $sz2; formula data for second condition (without size field)
|
||||
$formula2 = substr($recordData, $offset, $sz2);
|
||||
$formula2 = pack('v', $sz2) . $formula2; // prepend the length
|
||||
|
||||
try {
|
||||
$formula2 = $this->getFormulaFromStructure($formula2);
|
||||
} catch (PhpSpreadsheetException $e) {
|
||||
|
@ -5759,6 +5790,7 @@ class Xls extends BaseReader
|
|||
$size = 9;
|
||||
$data = self::extractNumber(substr($formulaData, 1));
|
||||
$data = str_replace(',', '.', (string) $data); // in case non-English locale
|
||||
|
||||
break;
|
||||
case 0x20: // array constant
|
||||
case 0x40:
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader;
|
|||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Hyperlink;
|
||||
use PhpOffice\PhpSpreadsheet\NamedRange;
|
||||
use PhpOffice\PhpSpreadsheet\DefinedName;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Xlsx\AutoFilter;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Chart;
|
||||
|
@ -502,8 +502,10 @@ class Xlsx extends BaseReader
|
|||
// We shouldn't override any of the built-in MS Excel values (values below id 164)
|
||||
// But there's a lot of naughty homebrew xlsx writers that do use "reserved" id values that aren't actually used
|
||||
// So we make allowance for them rather than lose formatting masks
|
||||
if ((int) $xf['numFmtId'] < 164 &&
|
||||
NumberFormat::builtInFormatCode((int) $xf['numFmtId']) !== '') {
|
||||
if (
|
||||
(int) $xf['numFmtId'] < 164 &&
|
||||
NumberFormat::builtInFormatCode((int) $xf['numFmtId']) !== ''
|
||||
) {
|
||||
$numFmt = NumberFormat::builtInFormatCode((int) $xf['numFmtId']);
|
||||
}
|
||||
}
|
||||
|
@ -659,6 +661,9 @@ class Xlsx extends BaseReader
|
|||
$coordinates = Coordinate::coordinateFromString($r);
|
||||
|
||||
if (!$this->getReadFilter()->readCell($coordinates[0], (int) $coordinates[1], $docSheet->getTitle())) {
|
||||
if (isset($c->f)) {
|
||||
$this->castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, 'castToError');
|
||||
}
|
||||
++$rowIndex;
|
||||
|
||||
continue;
|
||||
|
@ -763,13 +768,8 @@ class Xlsx extends BaseReader
|
|||
}
|
||||
}
|
||||
|
||||
if (!$this->readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) {
|
||||
$docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection['password'], true);
|
||||
if ($xmlSheet->protectedRanges->protectedRange) {
|
||||
foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) {
|
||||
$docSheet->protectCells((string) $protectedRange['sqref'], (string) $protectedRange['password'], true);
|
||||
}
|
||||
}
|
||||
if ($xmlSheet) {
|
||||
$this->readSheetProtection($docSheet, $xmlSheet);
|
||||
}
|
||||
|
||||
if ($xmlSheet && $xmlSheet->autoFilter && !$this->readDataOnly) {
|
||||
|
@ -1348,11 +1348,6 @@ class Xlsx extends BaseReader
|
|||
foreach ($xmlWorkbook->definedNames->definedName as $definedName) {
|
||||
// Extract range
|
||||
$extractedRange = (string) $definedName;
|
||||
if (($spos = strpos($extractedRange, '!')) !== false) {
|
||||
$extractedRange = substr($extractedRange, 0, $spos) . str_replace('$', '', substr($extractedRange, $spos));
|
||||
} else {
|
||||
$extractedRange = str_replace('$', '', $extractedRange);
|
||||
}
|
||||
|
||||
// Valid range?
|
||||
if (stripos((string) $definedName, '#REF!') !== false || $extractedRange == '') {
|
||||
|
@ -1370,39 +1365,40 @@ class Xlsx extends BaseReader
|
|||
break;
|
||||
default:
|
||||
if ($mapSheetId[(int) $definedName['localSheetId']] !== null) {
|
||||
if (strpos((string) $definedName, '!') !== false) {
|
||||
$range = Worksheet::extractSheetTitle((string) $definedName, true);
|
||||
$scope = $excel->getSheet($mapSheetId[(int) $definedName['localSheetId']]);
|
||||
if (strpos((string) $definedName, '!') !== false) {
|
||||
$range[0] = str_replace("''", "'", $range[0]);
|
||||
$range[0] = str_replace("'", '', $range[0]);
|
||||
if ($worksheet = $docSheet->getParent()->getSheetByName($range[0])) {
|
||||
$extractedRange = str_replace('$', '', $range[1]);
|
||||
$scope = $docSheet->getParent()->getSheet($mapSheetId[(int) $definedName['localSheetId']]);
|
||||
$excel->addNamedRange(new NamedRange((string) $definedName['name'], $worksheet, $extractedRange, true, $scope));
|
||||
if ($worksheet = $excel->getSheetByName($range[0])) {
|
||||
$excel->addDefinedName(DefinedName::createInstance((string) $definedName['name'], $worksheet, $extractedRange, true, $scope));
|
||||
} else {
|
||||
$excel->addDefinedName(DefinedName::createInstance((string) $definedName['name'], $scope, $extractedRange, true, $scope));
|
||||
}
|
||||
} else {
|
||||
$excel->addDefinedName(DefinedName::createInstance((string) $definedName['name'], $scope, $extractedRange, true));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
} elseif (!isset($definedName['localSheetId'])) {
|
||||
$definedRange = (string) $definedName;
|
||||
// "Global" definedNames
|
||||
$locatedSheet = null;
|
||||
$extractedSheetName = '';
|
||||
if (strpos((string) $definedName, '!') !== false) {
|
||||
// Modify range, and extract the first worksheet reference
|
||||
// Need to split on a comma or a space if not in quotes, and extract the first part.
|
||||
$definedNameValueParts = preg_split("/[ ,](?=([^']*'[^']*')*[^']*$)/miuU", $definedRange);
|
||||
// Extract sheet name
|
||||
$extractedSheetName = Worksheet::extractSheetTitle((string) $definedName, true);
|
||||
$extractedSheetName = trim($extractedSheetName[0], "'");
|
||||
[$extractedSheetName] = Worksheet::extractSheetTitle((string) $definedNameValueParts[0], true);
|
||||
$extractedSheetName = trim($extractedSheetName, "'");
|
||||
|
||||
// Locate sheet
|
||||
$locatedSheet = $excel->getSheetByName($extractedSheetName);
|
||||
|
||||
// Modify range
|
||||
[$worksheetName, $extractedRange] = Worksheet::extractSheetTitle($extractedRange, true);
|
||||
}
|
||||
|
||||
if ($locatedSheet !== null) {
|
||||
$excel->addNamedRange(new NamedRange((string) $definedName['name'], $locatedSheet, $extractedRange, false));
|
||||
}
|
||||
$excel->addDefinedName(DefinedName::createInstance((string) $definedName['name'], $locatedSheet, $definedRange, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1725,12 +1721,16 @@ class Xlsx extends BaseReader
|
|||
if (isset($run->rPr->color)) {
|
||||
$objText->getFont()->setColor(new Color(self::readColor($run->rPr->color)));
|
||||
}
|
||||
if ((isset($run->rPr->b['val']) && self::boolean((string) $run->rPr->b['val'])) ||
|
||||
(isset($run->rPr->b) && !isset($run->rPr->b['val']))) {
|
||||
if (
|
||||
(isset($run->rPr->b['val']) && self::boolean((string) $run->rPr->b['val'])) ||
|
||||
(isset($run->rPr->b) && !isset($run->rPr->b['val']))
|
||||
) {
|
||||
$objText->getFont()->setBold(true);
|
||||
}
|
||||
if ((isset($run->rPr->i['val']) && self::boolean((string) $run->rPr->i['val'])) ||
|
||||
(isset($run->rPr->i) && !isset($run->rPr->i['val']))) {
|
||||
if (
|
||||
(isset($run->rPr->i['val']) && self::boolean((string) $run->rPr->i['val'])) ||
|
||||
(isset($run->rPr->i) && !isset($run->rPr->i['val']))
|
||||
) {
|
||||
$objText->getFont()->setItalic(true);
|
||||
}
|
||||
if (isset($run->rPr->vertAlign, $run->rPr->vertAlign['val'])) {
|
||||
|
@ -1747,8 +1747,10 @@ class Xlsx extends BaseReader
|
|||
} elseif (isset($run->rPr->u, $run->rPr->u['val'])) {
|
||||
$objText->getFont()->setUnderline((string) $run->rPr->u['val']);
|
||||
}
|
||||
if ((isset($run->rPr->strike['val']) && self::boolean((string) $run->rPr->strike['val'])) ||
|
||||
(isset($run->rPr->strike) && !isset($run->rPr->strike['val']))) {
|
||||
if (
|
||||
(isset($run->rPr->strike['val']) && self::boolean((string) $run->rPr->strike['val'])) ||
|
||||
(isset($run->rPr->strike) && !isset($run->rPr->strike['val']))
|
||||
) {
|
||||
$objText->getFont()->setStrikethrough(true);
|
||||
}
|
||||
}
|
||||
|
@ -2031,4 +2033,29 @@ class Xlsx extends BaseReader
|
|||
|
||||
return $workbookBasename;
|
||||
}
|
||||
|
||||
private function readSheetProtection(Worksheet $docSheet, SimpleXMLElement $xmlSheet): void
|
||||
{
|
||||
if ($this->readDataOnly || !$xmlSheet->sheetProtection) {
|
||||
return;
|
||||
}
|
||||
|
||||
$algorithmName = (string) $xmlSheet->sheetProtection['algorithmName'];
|
||||
$protection = $docSheet->getProtection();
|
||||
$protection->setAlgorithm($algorithmName);
|
||||
|
||||
if ($algorithmName) {
|
||||
$protection->setPassword((string) $xmlSheet->sheetProtection['hashValue'], true);
|
||||
$protection->setSalt((string) $xmlSheet->sheetProtection['saltValue']);
|
||||
$protection->setSpinCount((int) $xmlSheet->sheetProtection['spinCount']);
|
||||
} else {
|
||||
$protection->setPassword((string) $xmlSheet->sheetProtection['password'], true);
|
||||
}
|
||||
|
||||
if ($xmlSheet->protectedRanges->protectedRange) {
|
||||
foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) {
|
||||
$docSheet->protectCells((string) $protectedRange['sqref'], (string) $protectedRange['password'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,8 +94,10 @@ class ColumnAndRowAttributes extends BaseParserClass
|
|||
// set columns/rows attributes
|
||||
$columnsAttributesAreSet = [];
|
||||
foreach ($columnsAttributes as $columnCoordinate => $columnAttributes) {
|
||||
if ($readFilter === null ||
|
||||
!$this->isFilteredColumn($readFilter, $columnCoordinate, $rowsAttributes)) {
|
||||
if (
|
||||
$readFilter === null ||
|
||||
!$this->isFilteredColumn($readFilter, $columnCoordinate, $rowsAttributes)
|
||||
) {
|
||||
if (!isset($columnsAttributesAreSet[$columnCoordinate])) {
|
||||
$this->setColumnAttributes($columnCoordinate, $columnAttributes);
|
||||
$columnsAttributesAreSet[$columnCoordinate] = true;
|
||||
|
@ -105,8 +107,10 @@ class ColumnAndRowAttributes extends BaseParserClass
|
|||
|
||||
$rowsAttributesAreSet = [];
|
||||
foreach ($rowsAttributes as $rowCoordinate => $rowAttributes) {
|
||||
if ($readFilter === null ||
|
||||
!$this->isFilteredRow($readFilter, $rowCoordinate, $columnsAttributes)) {
|
||||
if (
|
||||
$readFilter === null ||
|
||||
!$this->isFilteredRow($readFilter, $rowCoordinate, $columnsAttributes)
|
||||
) {
|
||||
if (!isset($rowsAttributesAreSet[$rowCoordinate])) {
|
||||
$this->setRowAttributes($rowCoordinate, $rowAttributes);
|
||||
$rowsAttributesAreSet[$rowCoordinate] = true;
|
||||
|
|
|
@ -34,13 +34,15 @@ class ConditionalStyles
|
|||
$conditionals = [];
|
||||
foreach ($xmlSheet->conditionalFormatting as $conditional) {
|
||||
foreach ($conditional->cfRule as $cfRule) {
|
||||
if (((string) $cfRule['type'] == Conditional::CONDITION_NONE
|
||||
if (
|
||||
((string) $cfRule['type'] == Conditional::CONDITION_NONE
|
||||
|| (string) $cfRule['type'] == Conditional::CONDITION_CELLIS
|
||||
|| (string) $cfRule['type'] == Conditional::CONDITION_CONTAINSTEXT
|
||||
|| (string) $cfRule['type'] == Conditional::CONDITION_CONTAINSBLANKS
|
||||
|| (string) $cfRule['type'] == Conditional::CONDITION_NOTCONTAINSBLANKS
|
||||
|| (string) $cfRule['type'] == Conditional::CONDITION_EXPRESSION)
|
||||
&& isset($this->dxfs[(int) ($cfRule['dxfId'])])) {
|
||||
&& isset($this->dxfs[(int) ($cfRule['dxfId'])])
|
||||
) {
|
||||
$conditionals[(string) $conditional['sqref']][(int) ($cfRule['priority'])] = $cfRule;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,10 +65,15 @@ class PageSetup extends BaseParserClass
|
|||
if (isset($xmlSheet->pageSetup['fitToWidth']) && (int) ($xmlSheet->pageSetup['fitToWidth']) >= 0) {
|
||||
$docPageSetup->setFitToWidth((int) ($xmlSheet->pageSetup['fitToWidth']), false);
|
||||
}
|
||||
if (isset($xmlSheet->pageSetup['firstPageNumber'], $xmlSheet->pageSetup['useFirstPageNumber']) &&
|
||||
self::boolean((string) $xmlSheet->pageSetup['useFirstPageNumber'])) {
|
||||
if (
|
||||
isset($xmlSheet->pageSetup['firstPageNumber'], $xmlSheet->pageSetup['useFirstPageNumber']) &&
|
||||
self::boolean((string) $xmlSheet->pageSetup['useFirstPageNumber'])
|
||||
) {
|
||||
$docPageSetup->setFirstPageNumber((int) ($xmlSheet->pageSetup['firstPageNumber']));
|
||||
}
|
||||
if (isset($xmlSheet->pageSetup['pageOrder'])) {
|
||||
$docPageSetup->setPageOrder((string) $xmlSheet->pageSetup['pageOrder']);
|
||||
}
|
||||
|
||||
$relAttributes = $xmlSheet->pageSetup->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
if (isset($relAttributes['id'])) {
|
||||
|
@ -84,26 +89,34 @@ class PageSetup extends BaseParserClass
|
|||
if ($xmlSheet->headerFooter) {
|
||||
$docHeaderFooter = $worksheet->getHeaderFooter();
|
||||
|
||||
if (isset($xmlSheet->headerFooter['differentOddEven']) &&
|
||||
self::boolean((string) $xmlSheet->headerFooter['differentOddEven'])) {
|
||||
if (
|
||||
isset($xmlSheet->headerFooter['differentOddEven']) &&
|
||||
self::boolean((string) $xmlSheet->headerFooter['differentOddEven'])
|
||||
) {
|
||||
$docHeaderFooter->setDifferentOddEven(true);
|
||||
} else {
|
||||
$docHeaderFooter->setDifferentOddEven(false);
|
||||
}
|
||||
if (isset($xmlSheet->headerFooter['differentFirst']) &&
|
||||
self::boolean((string) $xmlSheet->headerFooter['differentFirst'])) {
|
||||
if (
|
||||
isset($xmlSheet->headerFooter['differentFirst']) &&
|
||||
self::boolean((string) $xmlSheet->headerFooter['differentFirst'])
|
||||
) {
|
||||
$docHeaderFooter->setDifferentFirst(true);
|
||||
} else {
|
||||
$docHeaderFooter->setDifferentFirst(false);
|
||||
}
|
||||
if (isset($xmlSheet->headerFooter['scaleWithDoc']) &&
|
||||
!self::boolean((string) $xmlSheet->headerFooter['scaleWithDoc'])) {
|
||||
if (
|
||||
isset($xmlSheet->headerFooter['scaleWithDoc']) &&
|
||||
!self::boolean((string) $xmlSheet->headerFooter['scaleWithDoc'])
|
||||
) {
|
||||
$docHeaderFooter->setScaleWithDocument(false);
|
||||
} else {
|
||||
$docHeaderFooter->setScaleWithDocument(true);
|
||||
}
|
||||
if (isset($xmlSheet->headerFooter['alignWithMargins']) &&
|
||||
!self::boolean((string) $xmlSheet->headerFooter['alignWithMargins'])) {
|
||||
if (
|
||||
isset($xmlSheet->headerFooter['alignWithMargins']) &&
|
||||
!self::boolean((string) $xmlSheet->headerFooter['alignWithMargins'])
|
||||
) {
|
||||
$docHeaderFooter->setAlignWithMargins(false);
|
||||
} else {
|
||||
$docHeaderFooter->setAlignWithMargins(true);
|
||||
|
|
|
@ -59,15 +59,19 @@ class SheetViewOptions extends BaseParserClass
|
|||
private function outlines(SimpleXMLElement $sheetPr): void
|
||||
{
|
||||
if (isset($sheetPr->outlinePr)) {
|
||||
if (isset($sheetPr->outlinePr['summaryRight']) &&
|
||||
!self::boolean((string) $sheetPr->outlinePr['summaryRight'])) {
|
||||
if (
|
||||
isset($sheetPr->outlinePr['summaryRight']) &&
|
||||
!self::boolean((string) $sheetPr->outlinePr['summaryRight'])
|
||||
) {
|
||||
$this->worksheet->setShowSummaryRight(false);
|
||||
} else {
|
||||
$this->worksheet->setShowSummaryRight(true);
|
||||
}
|
||||
|
||||
if (isset($sheetPr->outlinePr['summaryBelow']) &&
|
||||
!self::boolean((string) $sheetPr->outlinePr['summaryBelow'])) {
|
||||
if (
|
||||
isset($sheetPr->outlinePr['summaryBelow']) &&
|
||||
!self::boolean((string) $sheetPr->outlinePr['summaryBelow'])
|
||||
) {
|
||||
$this->worksheet->setShowSummaryBelow(false);
|
||||
} else {
|
||||
$this->worksheet->setShowSummaryBelow(true);
|
||||
|
@ -78,8 +82,10 @@ class SheetViewOptions extends BaseParserClass
|
|||
private function pageSetup(SimpleXMLElement $sheetPr): void
|
||||
{
|
||||
if (isset($sheetPr->pageSetUpPr)) {
|
||||
if (isset($sheetPr->pageSetUpPr['fitToPage']) &&
|
||||
!self::boolean((string) $sheetPr->pageSetUpPr['fitToPage'])) {
|
||||
if (
|
||||
isset($sheetPr->pageSetUpPr['fitToPage']) &&
|
||||
!self::boolean((string) $sheetPr->pageSetUpPr['fitToPage'])
|
||||
) {
|
||||
$this->worksheet->getPageSetup()->setFitToPage(false);
|
||||
} else {
|
||||
$this->worksheet->getPageSetup()->setFitToPage(true);
|
||||
|
@ -89,9 +95,11 @@ class SheetViewOptions extends BaseParserClass
|
|||
|
||||
private function sheetFormat(SimpleXMLElement $sheetFormatPr): void
|
||||
{
|
||||
if (isset($sheetFormatPr['customHeight']) &&
|
||||
if (
|
||||
isset($sheetFormatPr['customHeight']) &&
|
||||
self::boolean((string) $sheetFormatPr['customHeight']) &&
|
||||
isset($sheetFormatPr['defaultRowHeight'])) {
|
||||
isset($sheetFormatPr['defaultRowHeight'])
|
||||
) {
|
||||
$this->worksheet->getDefaultRowDimension()
|
||||
->setRowHeight((float) $sheetFormatPr['defaultRowHeight']);
|
||||
}
|
||||
|
@ -101,8 +109,10 @@ class SheetViewOptions extends BaseParserClass
|
|||
->setWidth((float) $sheetFormatPr['defaultColWidth']);
|
||||
}
|
||||
|
||||
if (isset($sheetFormatPr['zeroHeight']) &&
|
||||
((string) $sheetFormatPr['zeroHeight'] === '1')) {
|
||||
if (
|
||||
isset($sheetFormatPr['zeroHeight']) &&
|
||||
((string) $sheetFormatPr['zeroHeight'] === '1')
|
||||
) {
|
||||
$this->worksheet->getDefaultRowDimension()->setZeroHeight(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,13 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Reader;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\AddressHelper;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\DefinedName;
|
||||
use PhpOffice\PhpSpreadsheet\Document\Properties;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Xml\PageSettings;
|
||||
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
|
@ -14,6 +17,8 @@ use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
|
|||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Borders;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Font;
|
||||
use SimpleXMLElement;
|
||||
|
||||
|
@ -29,13 +34,6 @@ class Xml extends BaseReader
|
|||
*/
|
||||
protected $styles = [];
|
||||
|
||||
/**
|
||||
* Character set used in the file.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $charSet = 'UTF-8';
|
||||
|
||||
/**
|
||||
* Create a new Excel2003XML Reader instance.
|
||||
*/
|
||||
|
@ -45,6 +43,56 @@ class Xml extends BaseReader
|
|||
$this->securityScanner = XmlScanner::getInstance($this);
|
||||
}
|
||||
|
||||
private $fileContents = '';
|
||||
|
||||
private static $mappings = [
|
||||
'borderStyle' => [
|
||||
'1continuous' => Border::BORDER_THIN,
|
||||
'1dash' => Border::BORDER_DASHED,
|
||||
'1dashdot' => Border::BORDER_DASHDOT,
|
||||
'1dashdotdot' => Border::BORDER_DASHDOTDOT,
|
||||
'1dot' => Border::BORDER_DOTTED,
|
||||
'1double' => Border::BORDER_DOUBLE,
|
||||
'2continuous' => Border::BORDER_MEDIUM,
|
||||
'2dash' => Border::BORDER_MEDIUMDASHED,
|
||||
'2dashdot' => Border::BORDER_MEDIUMDASHDOT,
|
||||
'2dashdotdot' => Border::BORDER_MEDIUMDASHDOTDOT,
|
||||
'2dot' => Border::BORDER_DOTTED,
|
||||
'2double' => Border::BORDER_DOUBLE,
|
||||
'3continuous' => Border::BORDER_THICK,
|
||||
'3dash' => Border::BORDER_MEDIUMDASHED,
|
||||
'3dashdot' => Border::BORDER_MEDIUMDASHDOT,
|
||||
'3dashdotdot' => Border::BORDER_MEDIUMDASHDOTDOT,
|
||||
'3dot' => Border::BORDER_DOTTED,
|
||||
'3double' => Border::BORDER_DOUBLE,
|
||||
],
|
||||
'fillType' => [
|
||||
'solid' => Fill::FILL_SOLID,
|
||||
'gray75' => Fill::FILL_PATTERN_DARKGRAY,
|
||||
'gray50' => Fill::FILL_PATTERN_MEDIUMGRAY,
|
||||
'gray25' => Fill::FILL_PATTERN_LIGHTGRAY,
|
||||
'gray125' => Fill::FILL_PATTERN_GRAY125,
|
||||
'gray0625' => Fill::FILL_PATTERN_GRAY0625,
|
||||
'horzstripe' => Fill::FILL_PATTERN_DARKHORIZONTAL, // horizontal stripe
|
||||
'vertstripe' => Fill::FILL_PATTERN_DARKVERTICAL, // vertical stripe
|
||||
'reversediagstripe' => Fill::FILL_PATTERN_DARKUP, // reverse diagonal stripe
|
||||
'diagstripe' => Fill::FILL_PATTERN_DARKDOWN, // diagonal stripe
|
||||
'diagcross' => Fill::FILL_PATTERN_DARKGRID, // diagoanl crosshatch
|
||||
'thickdiagcross' => Fill::FILL_PATTERN_DARKTRELLIS, // thick diagonal crosshatch
|
||||
'thinhorzstripe' => Fill::FILL_PATTERN_LIGHTHORIZONTAL,
|
||||
'thinvertstripe' => Fill::FILL_PATTERN_LIGHTVERTICAL,
|
||||
'thinreversediagstripe' => Fill::FILL_PATTERN_LIGHTUP,
|
||||
'thindiagstripe' => Fill::FILL_PATTERN_LIGHTDOWN,
|
||||
'thinhorzcross' => Fill::FILL_PATTERN_LIGHTGRID, // thin horizontal crosshatch
|
||||
'thindiagcross' => Fill::FILL_PATTERN_LIGHTTRELLIS, // thin diagonal crosshatch
|
||||
],
|
||||
];
|
||||
|
||||
public static function xmlMappings(): array
|
||||
{
|
||||
return self::$mappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the current IReader read the file?
|
||||
*
|
||||
|
@ -70,13 +118,10 @@ class Xml extends BaseReader
|
|||
];
|
||||
|
||||
// Open file
|
||||
$this->openFile($pFilename);
|
||||
$fileHandle = $this->fileHandle;
|
||||
$data = file_get_contents($pFilename);
|
||||
|
||||
// Read sample data (first 2 KB will do)
|
||||
$data = fread($fileHandle, 2048);
|
||||
fclose($fileHandle);
|
||||
$data = str_replace("'", '"', $data); // fix headers with single quote
|
||||
// Why?
|
||||
//$data = str_replace("'", '"', $data); // fix headers with single quote
|
||||
|
||||
$valid = true;
|
||||
foreach ($signature as $match) {
|
||||
|
@ -89,9 +134,14 @@ class Xml extends BaseReader
|
|||
}
|
||||
|
||||
// Retrieve charset encoding
|
||||
if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/um', $data, $matches)) {
|
||||
$this->charSet = strtoupper($matches[1]);
|
||||
if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $data, $matches)) {
|
||||
$charSet = strtoupper($matches[1]);
|
||||
if (1 == preg_match('/^ISO-8859-\d[\dL]?$/i', $charSet)) {
|
||||
$data = StringHelper::convertEncoding($data, 'UTF-8', $charSet);
|
||||
$data = preg_replace('/(<?xml.*encoding=[\'"]).*?([\'"].*?>)/um', '$1' . 'UTF-8' . '$2', $data, 1);
|
||||
}
|
||||
}
|
||||
$this->fileContents = $data;
|
||||
|
||||
return $valid;
|
||||
}
|
||||
|
@ -107,13 +157,14 @@ class Xml extends BaseReader
|
|||
{
|
||||
try {
|
||||
$xml = simplexml_load_string(
|
||||
$this->securityScanner->scan(file_get_contents($pFilename)),
|
||||
$this->securityScanner->scan($this->fileContents ?: file_get_contents($pFilename)),
|
||||
'SimpleXMLElement',
|
||||
Settings::getLibXmlLoaderOptions()
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
throw new Exception('Cannot load invalid XML file: ' . $pFilename, 0, $e);
|
||||
}
|
||||
$this->fileContents = '';
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
@ -141,7 +192,7 @@ class Xml extends BaseReader
|
|||
$xml_ss = $xml->children($namespaces['ss']);
|
||||
foreach ($xml_ss->Worksheet as $worksheet) {
|
||||
$worksheet_ss = $worksheet->attributes($namespaces['ss']);
|
||||
$worksheetNames[] = self::convertStringEncoding((string) $worksheet_ss['Name'], $this->charSet);
|
||||
$worksheetNames[] = (string) $worksheet_ss['Name'];
|
||||
}
|
||||
|
||||
return $worksheetNames;
|
||||
|
@ -157,6 +208,9 @@ class Xml extends BaseReader
|
|||
public function listWorksheetInfo($pFilename)
|
||||
{
|
||||
File::assertFile($pFilename);
|
||||
if (!$this->canRead($pFilename)) {
|
||||
throw new Exception($pFilename . ' is an Invalid Spreadsheet file.');
|
||||
}
|
||||
|
||||
$worksheetInfo = [];
|
||||
|
||||
|
@ -176,10 +230,9 @@ class Xml extends BaseReader
|
|||
$tmpInfo['totalRows'] = 0;
|
||||
$tmpInfo['totalColumns'] = 0;
|
||||
|
||||
$tmpInfo['worksheetName'] = "Worksheet_{$worksheetID}";
|
||||
if (isset($worksheet_ss['Name'])) {
|
||||
$tmpInfo['worksheetName'] = (string) $worksheet_ss['Name'];
|
||||
} else {
|
||||
$tmpInfo['worksheetName'] = "Worksheet_{$worksheetID}";
|
||||
}
|
||||
|
||||
if (isset($worksheet->Table->Row)) {
|
||||
|
@ -235,53 +288,23 @@ class Xml extends BaseReader
|
|||
|
||||
private static function identifyFixedStyleValue($styleList, &$styleAttributeValue)
|
||||
{
|
||||
$returnValue = false;
|
||||
$styleAttributeValue = strtolower($styleAttributeValue);
|
||||
foreach ($styleList as $style) {
|
||||
if ($styleAttributeValue == strtolower($style)) {
|
||||
$styleAttributeValue = $style;
|
||||
$returnValue = true;
|
||||
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* pixel units to excel width units(units of 1/256th of a character width).
|
||||
*
|
||||
* @param float $pxs
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
protected static function pixel2WidthUnits($pxs)
|
||||
{
|
||||
$UNIT_OFFSET_MAP = [0, 36, 73, 109, 146, 182, 219];
|
||||
|
||||
$widthUnits = 256 * ($pxs / 7);
|
||||
$widthUnits += $UNIT_OFFSET_MAP[($pxs % 7)];
|
||||
|
||||
return $widthUnits;
|
||||
}
|
||||
|
||||
/**
|
||||
* excel width units(units of 1/256th of a character width) to pixel units.
|
||||
*
|
||||
* @param float $widthUnits
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
protected static function widthUnits2Pixel($widthUnits)
|
||||
{
|
||||
$pixels = ($widthUnits / 256) * 7;
|
||||
$offsetWidthUnits = $widthUnits % 256;
|
||||
|
||||
return $pixels + round($offsetWidthUnits / (256 / 7));
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
protected static function hex2str($hex)
|
||||
{
|
||||
return chr(hexdec($hex[1]));
|
||||
return mb_chr((int) hexdec($hex[1]), 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -305,51 +328,52 @@ class Xml extends BaseReader
|
|||
$docProps = $spreadsheet->getProperties();
|
||||
if (isset($xml->DocumentProperties[0])) {
|
||||
foreach ($xml->DocumentProperties[0] as $propertyName => $propertyValue) {
|
||||
$stringValue = (string) $propertyValue;
|
||||
switch ($propertyName) {
|
||||
case 'Title':
|
||||
$docProps->setTitle(self::convertStringEncoding($propertyValue, $this->charSet));
|
||||
$docProps->setTitle($stringValue);
|
||||
|
||||
break;
|
||||
case 'Subject':
|
||||
$docProps->setSubject(self::convertStringEncoding($propertyValue, $this->charSet));
|
||||
$docProps->setSubject($stringValue);
|
||||
|
||||
break;
|
||||
case 'Author':
|
||||
$docProps->setCreator(self::convertStringEncoding($propertyValue, $this->charSet));
|
||||
$docProps->setCreator($stringValue);
|
||||
|
||||
break;
|
||||
case 'Created':
|
||||
$creationDate = strtotime($propertyValue);
|
||||
$creationDate = strtotime($stringValue);
|
||||
$docProps->setCreated($creationDate);
|
||||
|
||||
break;
|
||||
case 'LastAuthor':
|
||||
$docProps->setLastModifiedBy(self::convertStringEncoding($propertyValue, $this->charSet));
|
||||
$docProps->setLastModifiedBy($stringValue);
|
||||
|
||||
break;
|
||||
case 'LastSaved':
|
||||
$lastSaveDate = strtotime($propertyValue);
|
||||
$lastSaveDate = strtotime($stringValue);
|
||||
$docProps->setModified($lastSaveDate);
|
||||
|
||||
break;
|
||||
case 'Company':
|
||||
$docProps->setCompany(self::convertStringEncoding($propertyValue, $this->charSet));
|
||||
$docProps->setCompany($stringValue);
|
||||
|
||||
break;
|
||||
case 'Category':
|
||||
$docProps->setCategory(self::convertStringEncoding($propertyValue, $this->charSet));
|
||||
$docProps->setCategory($stringValue);
|
||||
|
||||
break;
|
||||
case 'Manager':
|
||||
$docProps->setManager(self::convertStringEncoding($propertyValue, $this->charSet));
|
||||
$docProps->setManager($stringValue);
|
||||
|
||||
break;
|
||||
case 'Keywords':
|
||||
$docProps->setKeywords(self::convertStringEncoding($propertyValue, $this->charSet));
|
||||
$docProps->setKeywords($stringValue);
|
||||
|
||||
break;
|
||||
case 'Description':
|
||||
$docProps->setDescription(self::convertStringEncoding($propertyValue, $this->charSet));
|
||||
$docProps->setDescription($stringValue);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -358,7 +382,7 @@ class Xml extends BaseReader
|
|||
if (isset($xml->CustomDocumentProperties)) {
|
||||
foreach ($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) {
|
||||
$propertyAttributes = $propertyValue->attributes($namespaces['dt']);
|
||||
$propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/', ['self', 'hex2str'], $propertyName);
|
||||
$propertyName = preg_replace_callback('/_x([0-9a-f]{4})_/i', ['self', 'hex2str'], $propertyName);
|
||||
$propertyType = Properties::PROPERTY_TYPE_UNKNOWN;
|
||||
switch ((string) $propertyAttributes) {
|
||||
case 'string':
|
||||
|
@ -399,8 +423,10 @@ class Xml extends BaseReader
|
|||
foreach ($xml_ss->Worksheet as $worksheet) {
|
||||
$worksheet_ss = $worksheet->attributes($namespaces['ss']);
|
||||
|
||||
if ((isset($this->loadSheetsOnly)) && (isset($worksheet_ss['Name'])) &&
|
||||
(!in_array($worksheet_ss['Name'], $this->loadSheetsOnly))) {
|
||||
if (
|
||||
(isset($this->loadSheetsOnly)) && (isset($worksheet_ss['Name'])) &&
|
||||
(!in_array($worksheet_ss['Name'], $this->loadSheetsOnly))
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -408,13 +434,27 @@ class Xml extends BaseReader
|
|||
$spreadsheet->createSheet();
|
||||
$spreadsheet->setActiveSheetIndex($worksheetID);
|
||||
if (isset($worksheet_ss['Name'])) {
|
||||
$worksheetName = self::convertStringEncoding((string) $worksheet_ss['Name'], $this->charSet);
|
||||
$worksheetName = (string) $worksheet_ss['Name'];
|
||||
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in
|
||||
// formula cells... during the load, all formulae should be correct, and we're simply bringing
|
||||
// the worksheet name in line with the formula, not the reverse
|
||||
$spreadsheet->getActiveSheet()->setTitle($worksheetName, false, false);
|
||||
}
|
||||
|
||||
// locally scoped defined names
|
||||
if (isset($worksheet->Names[0])) {
|
||||
foreach ($worksheet->Names[0] as $definedName) {
|
||||
$definedName_ss = $definedName->attributes($namespaces['ss']);
|
||||
$name = (string) $definedName_ss['Name'];
|
||||
$definedValue = (string) $definedName_ss['RefersTo'];
|
||||
$convertedValue = AddressHelper::convertFormulaToA1($definedValue);
|
||||
if ($convertedValue[0] === '=') {
|
||||
$convertedValue = substr($convertedValue, 1);
|
||||
}
|
||||
$spreadsheet->addDefinedName(DefinedName::createInstance($name, $spreadsheet->getActiveSheet(), $convertedValue, true));
|
||||
}
|
||||
}
|
||||
|
||||
$columnID = 'A';
|
||||
if (isset($worksheet->Table->Column)) {
|
||||
foreach ($worksheet->Table->Column as $columnData) {
|
||||
|
@ -457,7 +497,7 @@ class Xml extends BaseReader
|
|||
}
|
||||
|
||||
if (isset($cell_ss['HRef'])) {
|
||||
$spreadsheet->getActiveSheet()->getCell($cellRange)->getHyperlink()->setUrl($cell_ss['HRef']);
|
||||
$spreadsheet->getActiveSheet()->getCell($cellRange)->getHyperlink()->setUrl((string) $cell_ss['HRef']);
|
||||
}
|
||||
|
||||
if ((isset($cell_ss['MergeAcross'])) || (isset($cell_ss['MergeDown']))) {
|
||||
|
@ -474,14 +514,15 @@ class Xml extends BaseReader
|
|||
$spreadsheet->getActiveSheet()->mergeCells($cellRange);
|
||||
}
|
||||
|
||||
$cellIsSet = $hasCalculatedValue = false;
|
||||
$hasCalculatedValue = false;
|
||||
$cellDataFormula = '';
|
||||
if (isset($cell_ss['Formula'])) {
|
||||
$cellDataFormula = $cell_ss['Formula'];
|
||||
$hasCalculatedValue = true;
|
||||
}
|
||||
if (isset($cell->Data)) {
|
||||
$cellValue = $cellData = $cell->Data;
|
||||
$cellData = $cell->Data;
|
||||
$cellValue = (string) $cellData;
|
||||
$type = DataType::TYPE_NULL;
|
||||
$cellData_ss = $cellData->attributes($namespaces['ss']);
|
||||
if (isset($cellData_ss['Type'])) {
|
||||
|
@ -497,7 +538,6 @@ class Xml extends BaseReader
|
|||
const TYPE_ERROR = 'e';
|
||||
*/
|
||||
case 'String':
|
||||
$cellValue = self::convertStringEncoding($cellValue, $this->charSet);
|
||||
$type = DataType::TYPE_STRING;
|
||||
|
||||
break;
|
||||
|
@ -516,11 +556,12 @@ class Xml extends BaseReader
|
|||
break;
|
||||
case 'DateTime':
|
||||
$type = DataType::TYPE_NUMERIC;
|
||||
$cellValue = Date::PHPToExcel(strtotime($cellValue));
|
||||
$cellValue = Date::PHPToExcel(strtotime($cellValue . ' UTC'));
|
||||
|
||||
break;
|
||||
case 'Error':
|
||||
$type = DataType::TYPE_ERROR;
|
||||
$hasCalculatedValue = false;
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -529,65 +570,14 @@ class Xml extends BaseReader
|
|||
if ($hasCalculatedValue) {
|
||||
$type = DataType::TYPE_FORMULA;
|
||||
$columnNumber = Coordinate::columnIndexFromString($columnID);
|
||||
if (substr($cellDataFormula, 0, 3) == 'of:') {
|
||||
$cellDataFormula = substr($cellDataFormula, 3);
|
||||
$temp = explode('"', $cellDataFormula);
|
||||
$key = false;
|
||||
foreach ($temp as &$value) {
|
||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||
if ($key = !$key) {
|
||||
$value = str_replace(['[.', '.', ']'], '', $value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Convert R1C1 style references to A1 style references (but only when not quoted)
|
||||
$temp = explode('"', $cellDataFormula);
|
||||
$key = false;
|
||||
foreach ($temp as &$value) {
|
||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||
if ($key = !$key) {
|
||||
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences, PREG_SET_ORDER + PREG_OFFSET_CAPTURE);
|
||||
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
|
||||
// through the formula from left to right. Reversing means that we work right to left.through
|
||||
// the formula
|
||||
$cellReferences = array_reverse($cellReferences);
|
||||
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
|
||||
// then modify the formula to use that new reference
|
||||
foreach ($cellReferences as $cellReference) {
|
||||
$rowReference = $cellReference[2][0];
|
||||
// Empty R reference is the current row
|
||||
if ($rowReference == '') {
|
||||
$rowReference = $rowID;
|
||||
}
|
||||
// Bracketed R references are relative to the current row
|
||||
if ($rowReference[0] == '[') {
|
||||
$rowReference = $rowID + trim($rowReference, '[]');
|
||||
}
|
||||
$columnReference = $cellReference[4][0];
|
||||
// Empty C reference is the current column
|
||||
if ($columnReference == '') {
|
||||
$columnReference = $columnNumber;
|
||||
}
|
||||
// Bracketed C references are relative to the current column
|
||||
if ($columnReference[0] == '[') {
|
||||
$columnReference = $columnNumber + trim($columnReference, '[]');
|
||||
}
|
||||
$A1CellReference = Coordinate::stringFromColumnIndex($columnReference) . $rowReference;
|
||||
$value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
// Then rebuild the formula string
|
||||
$cellDataFormula = implode('"', $temp);
|
||||
$cellDataFormula = AddressHelper::convertFormulaToA1($cellDataFormula, $rowID, $columnNumber);
|
||||
}
|
||||
|
||||
$spreadsheet->getActiveSheet()->getCell($columnID . $rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $cellValue), $type);
|
||||
if ($hasCalculatedValue) {
|
||||
$spreadsheet->getActiveSheet()->getCell($columnID . $rowID)->setCalculatedValue($cellValue);
|
||||
}
|
||||
$cellIsSet = $rowHasData = true;
|
||||
$rowHasData = true;
|
||||
}
|
||||
|
||||
if (isset($cell->Comment)) {
|
||||
|
@ -598,15 +588,15 @@ class Xml extends BaseReader
|
|||
}
|
||||
$node = $cell->Comment->Data->asXML();
|
||||
$annotation = strip_tags($node);
|
||||
$spreadsheet->getActiveSheet()->getComment($columnID . $rowID)->setAuthor(self::convertStringEncoding($author, $this->charSet))->setText($this->parseRichText($annotation));
|
||||
$spreadsheet->getActiveSheet()->getComment($columnID . $rowID)->setAuthor($author)->setText($this->parseRichText($annotation));
|
||||
}
|
||||
|
||||
if (($cellIsSet) && (isset($cell_ss['StyleID']))) {
|
||||
if (isset($cell_ss['StyleID'])) {
|
||||
$style = (string) $cell_ss['StyleID'];
|
||||
if ((isset($this->styles[$style])) && (!empty($this->styles[$style]))) {
|
||||
if (!$spreadsheet->getActiveSheet()->cellExists($columnID . $rowID)) {
|
||||
$spreadsheet->getActiveSheet()->getCell($columnID . $rowID)->setValue(null);
|
||||
}
|
||||
//if (!$spreadsheet->getActiveSheet()->cellExists($columnID . $rowID)) {
|
||||
// $spreadsheet->getActiveSheet()->getCell($columnID . $rowID)->setValue(null);
|
||||
//}
|
||||
$spreadsheet->getActiveSheet()->getStyle($cellRange)->applyFromArray($this->styles[$style]);
|
||||
}
|
||||
}
|
||||
|
@ -626,28 +616,39 @@ class Xml extends BaseReader
|
|||
|
||||
++$rowID;
|
||||
}
|
||||
|
||||
$xmlX = $worksheet->children($namespaces['x']);
|
||||
if (isset($xmlX->WorksheetOptions)) {
|
||||
(new PageSettings($xmlX, $namespaces))->loadPageSettings($spreadsheet);
|
||||
}
|
||||
}
|
||||
++$worksheetID;
|
||||
}
|
||||
|
||||
// Globally scoped defined names
|
||||
$activeWorksheet = $spreadsheet->setActiveSheetIndex(0);
|
||||
if (isset($xml->Names[0])) {
|
||||
foreach ($xml->Names[0] as $definedName) {
|
||||
$definedName_ss = $definedName->attributes($namespaces['ss']);
|
||||
$name = (string) $definedName_ss['Name'];
|
||||
$definedValue = (string) $definedName_ss['RefersTo'];
|
||||
$convertedValue = AddressHelper::convertFormulaToA1($definedValue);
|
||||
if ($convertedValue[0] === '=') {
|
||||
$convertedValue = substr($convertedValue, 1);
|
||||
}
|
||||
$spreadsheet->addDefinedName(DefinedName::createInstance($name, $activeWorksheet, $convertedValue));
|
||||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
return $spreadsheet;
|
||||
}
|
||||
|
||||
protected static function convertStringEncoding($string, $charset)
|
||||
{
|
||||
if ($charset != 'UTF-8') {
|
||||
return StringHelper::convertEncoding($string, 'UTF-8', $charset);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
protected function parseRichText($is)
|
||||
{
|
||||
$value = new RichText();
|
||||
|
||||
$value->createText(self::convertStringEncoding($is, $this->charSet));
|
||||
$value->createText($is);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
@ -728,29 +729,41 @@ class Xml extends BaseReader
|
|||
case 'WrapText':
|
||||
$this->styles[$styleID]['alignment']['wrapText'] = true;
|
||||
|
||||
break;
|
||||
case 'Rotate':
|
||||
$this->styles[$styleID]['alignment']['textRotation'] = $styleAttributeValue;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static $borderPositions = ['top', 'left', 'bottom', 'right'];
|
||||
|
||||
/**
|
||||
* @param $styleID
|
||||
*/
|
||||
private function parseStyleBorders($styleID, SimpleXMLElement $styleData, array $namespaces): void
|
||||
{
|
||||
$diagonalDirection = '';
|
||||
$borderPosition = '';
|
||||
foreach ($styleData->Border as $borderStyle) {
|
||||
$borderAttributes = $borderStyle->attributes($namespaces['ss']);
|
||||
$thisBorder = [];
|
||||
$style = (string) $borderAttributes->Weight;
|
||||
$style .= strtolower((string) $borderAttributes->LineStyle);
|
||||
$thisBorder['borderStyle'] = self::$mappings['borderStyle'][$style] ?? Border::BORDER_NONE;
|
||||
foreach ($borderAttributes as $borderStyleKey => $borderStyleValue) {
|
||||
switch ($borderStyleKey) {
|
||||
case 'LineStyle':
|
||||
$thisBorder['borderStyle'] = Border::BORDER_MEDIUM;
|
||||
|
||||
break;
|
||||
case 'Weight':
|
||||
break;
|
||||
case 'Position':
|
||||
$borderPosition = strtolower($borderStyleValue);
|
||||
$borderStyleValue = strtolower((string) $borderStyleValue);
|
||||
if (in_array($borderStyleValue, self::$borderPositions)) {
|
||||
$borderPosition = $borderStyleValue;
|
||||
} elseif ($borderStyleValue == 'diagonalleft') {
|
||||
$diagonalDirection = $diagonalDirection ? Borders::DIAGONAL_BOTH : Borders::DIAGONAL_DOWN;
|
||||
} elseif ($borderStyleValue == 'diagonalright') {
|
||||
$diagonalDirection = $diagonalDirection ? Borders::DIAGONAL_BOTH : Borders::DIAGONAL_UP;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'Color':
|
||||
|
@ -760,20 +773,16 @@ class Xml extends BaseReader
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!empty($thisBorder)) {
|
||||
if (($borderPosition == 'left') || ($borderPosition == 'right') || ($borderPosition == 'top') || ($borderPosition == 'bottom')) {
|
||||
if ($borderPosition) {
|
||||
$this->styles[$styleID]['borders'][$borderPosition] = $thisBorder;
|
||||
}
|
||||
} elseif ($diagonalDirection) {
|
||||
$this->styles[$styleID]['borders']['diagonalDirection'] = $diagonalDirection;
|
||||
$this->styles[$styleID]['borders']['diagonal'] = $thisBorder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $styleID
|
||||
*/
|
||||
private function parseStyleFont($styleID, SimpleXMLElement $styleAttributes): void
|
||||
{
|
||||
$underlineStyles = [
|
||||
private static $underlineStyles = [
|
||||
Font::UNDERLINE_NONE,
|
||||
Font::UNDERLINE_DOUBLE,
|
||||
Font::UNDERLINE_DOUBLEACCOUNTING,
|
||||
|
@ -781,6 +790,28 @@ class Xml extends BaseReader
|
|||
Font::UNDERLINE_SINGLEACCOUNTING,
|
||||
];
|
||||
|
||||
private function parseStyleFontUnderline(string $styleID, string $styleAttributeValue): void
|
||||
{
|
||||
if (self::identifyFixedStyleValue(self::$underlineStyles, $styleAttributeValue)) {
|
||||
$this->styles[$styleID]['font']['underline'] = $styleAttributeValue;
|
||||
}
|
||||
}
|
||||
|
||||
private function parseStyleFontVerticalAlign(string $styleID, string $styleAttributeValue): void
|
||||
{
|
||||
if ($styleAttributeValue == 'Superscript') {
|
||||
$this->styles[$styleID]['font']['superscript'] = true;
|
||||
}
|
||||
if ($styleAttributeValue == 'Subscript') {
|
||||
$this->styles[$styleID]['font']['subscript'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $styleID
|
||||
*/
|
||||
private function parseStyleFont(string $styleID, SimpleXMLElement $styleAttributes): void
|
||||
{
|
||||
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
|
||||
$styleAttributeValue = (string) $styleAttributeValue;
|
||||
switch ($styleAttributeKey) {
|
||||
|
@ -805,9 +836,11 @@ class Xml extends BaseReader
|
|||
|
||||
break;
|
||||
case 'Underline':
|
||||
if (self::identifyFixedStyleValue($underlineStyles, $styleAttributeValue)) {
|
||||
$this->styles[$styleID]['font']['underline'] = $styleAttributeValue;
|
||||
}
|
||||
$this->parseStyleFontUnderline($styleID, $styleAttributeValue);
|
||||
|
||||
break;
|
||||
case 'VerticalAlign':
|
||||
$this->parseStyleFontVerticalAlign($styleID, $styleAttributeValue);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -822,11 +855,17 @@ class Xml extends BaseReader
|
|||
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
|
||||
switch ($styleAttributeKey) {
|
||||
case 'Color':
|
||||
$this->styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue, 1);
|
||||
$this->styles[$styleID]['fill']['endColor']['rgb'] = substr($styleAttributeValue, 1);
|
||||
$this->styles[$styleID]['fill']['startColor']['rgb'] = substr($styleAttributeValue, 1);
|
||||
|
||||
break;
|
||||
case 'PatternColor':
|
||||
$this->styles[$styleID]['fill']['startColor']['rgb'] = substr($styleAttributeValue, 1);
|
||||
|
||||
break;
|
||||
case 'Pattern':
|
||||
$this->styles[$styleID]['fill']['fillType'] = strtolower($styleAttributeValue);
|
||||
$lcStyleAttributeValue = strtolower((string) $styleAttributeValue);
|
||||
$this->styles[$styleID]['fill']['fillType'] = self::$mappings['fillType'][$lcStyleAttributeValue] ?? Fill::FILL_NONE;
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Reader\Xml;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
|
||||
use SimpleXMLElement;
|
||||
use stdClass;
|
||||
|
||||
class PageSettings
|
||||
{
|
||||
/**
|
||||
* @var stdClass
|
||||
*/
|
||||
private $printSettings;
|
||||
|
||||
public function __construct(SimpleXMLElement $xmlX, array $namespaces)
|
||||
{
|
||||
$printSettings = $this->pageSetup($xmlX, $namespaces, $this->getPrintDefaults());
|
||||
$this->printSettings = $this->printSetup($xmlX, $printSettings);
|
||||
}
|
||||
|
||||
public function loadPageSettings(Spreadsheet $spreadsheet): void
|
||||
{
|
||||
$spreadsheet->getActiveSheet()->getPageSetup()
|
||||
->setPaperSize($this->printSettings->paperSize)
|
||||
->setOrientation($this->printSettings->orientation)
|
||||
->setScale($this->printSettings->scale)
|
||||
->setVerticalCentered($this->printSettings->verticalCentered)
|
||||
->setHorizontalCentered($this->printSettings->horizontalCentered)
|
||||
->setPageOrder($this->printSettings->printOrder);
|
||||
$spreadsheet->getActiveSheet()->getPageMargins()
|
||||
->setTop($this->printSettings->topMargin)
|
||||
->setHeader($this->printSettings->headerMargin)
|
||||
->setLeft($this->printSettings->leftMargin)
|
||||
->setRight($this->printSettings->rightMargin)
|
||||
->setBottom($this->printSettings->bottomMargin)
|
||||
->setFooter($this->printSettings->footerMargin);
|
||||
}
|
||||
|
||||
private function getPrintDefaults(): stdClass
|
||||
{
|
||||
return (object) [
|
||||
'paperSize' => 9,
|
||||
'orientation' => PageSetup::ORIENTATION_DEFAULT,
|
||||
'scale' => 100,
|
||||
'horizontalCentered' => false,
|
||||
'verticalCentered' => false,
|
||||
'printOrder' => PageSetup::PAGEORDER_DOWN_THEN_OVER,
|
||||
'topMargin' => 0.75,
|
||||
'headerMargin' => 0.3,
|
||||
'leftMargin' => 0.7,
|
||||
'rightMargin' => 0.7,
|
||||
'bottomMargin' => 0.75,
|
||||
'footerMargin' => 0.3,
|
||||
];
|
||||
}
|
||||
|
||||
private function pageSetup(SimpleXMLElement $xmlX, array $namespaces, stdClass $printDefaults): stdClass
|
||||
{
|
||||
if (isset($xmlX->WorksheetOptions->PageSetup)) {
|
||||
foreach ($xmlX->WorksheetOptions->PageSetup as $pageSetupData) {
|
||||
foreach ($pageSetupData as $pageSetupKey => $pageSetupValue) {
|
||||
$pageSetupAttributes = $pageSetupValue->attributes($namespaces['x']);
|
||||
switch ($pageSetupKey) {
|
||||
case 'Layout':
|
||||
$this->setLayout($printDefaults, $pageSetupAttributes);
|
||||
|
||||
break;
|
||||
case 'Header':
|
||||
$printDefaults->headerMargin = (float) $pageSetupAttributes->Margin ?: 1.0;
|
||||
|
||||
break;
|
||||
case 'Footer':
|
||||
$printDefaults->footerMargin = (float) $pageSetupAttributes->Margin ?: 1.0;
|
||||
|
||||
break;
|
||||
case 'PageMargins':
|
||||
$this->setMargins($printDefaults, $pageSetupAttributes);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $printDefaults;
|
||||
}
|
||||
|
||||
private function printSetup(SimpleXMLElement $xmlX, stdClass $printDefaults): stdClass
|
||||
{
|
||||
if (isset($xmlX->WorksheetOptions->Print)) {
|
||||
foreach ($xmlX->WorksheetOptions->Print as $printData) {
|
||||
foreach ($printData as $printKey => $printValue) {
|
||||
switch ($printKey) {
|
||||
case 'LeftToRight':
|
||||
$printDefaults->printOrder = PageSetup::PAGEORDER_OVER_THEN_DOWN;
|
||||
|
||||
break;
|
||||
case 'PaperSizeIndex':
|
||||
$printDefaults->paperSize = (int) $printValue ?: 9;
|
||||
|
||||
break;
|
||||
case 'Scale':
|
||||
$printDefaults->scale = (int) $printValue ?: 100;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $printDefaults;
|
||||
}
|
||||
|
||||
private function setLayout(stdClass $printDefaults, SimpleXMLElement $pageSetupAttributes): void
|
||||
{
|
||||
$printDefaults->orientation = (string) strtolower($pageSetupAttributes->Orientation) ?: PageSetup::ORIENTATION_PORTRAIT;
|
||||
$printDefaults->horizontalCentered = (bool) $pageSetupAttributes->CenterHorizontal ?: false;
|
||||
$printDefaults->verticalCentered = (bool) $pageSetupAttributes->CenterVertical ?: false;
|
||||
}
|
||||
|
||||
private function setMargins(stdClass $printDefaults, SimpleXMLElement $pageSetupAttributes): void
|
||||
{
|
||||
$printDefaults->leftMargin = (float) $pageSetupAttributes->Left ?: 1.0;
|
||||
$printDefaults->rightMargin = (float) $pageSetupAttributes->Right ?: 1.0;
|
||||
$printDefaults->topMargin = (float) $pageSetupAttributes->Top ?: 1.0;
|
||||
$printDefaults->bottomMargin = (float) $pageSetupAttributes->Bottom ?: 1.0;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
@ -68,7 +69,7 @@ class ReferenceHelper
|
|||
*/
|
||||
public static function columnReverseSort($a, $b)
|
||||
{
|
||||
return 1 - strcasecmp(strlen($a) . $a, strlen($b) . $b);
|
||||
return -strcasecmp(strlen($a) . $a, strlen($b) . $b);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,7 +108,7 @@ class ReferenceHelper
|
|||
[$bc, $br] = sscanf($b, '%[A-Z]%d');
|
||||
|
||||
if ($ar === $br) {
|
||||
return 1 - strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
|
||||
return -strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
|
||||
}
|
||||
|
||||
return ($ar < $br) ? 1 : -1;
|
||||
|
@ -129,13 +130,17 @@ class ReferenceHelper
|
|||
[$cellColumn, $cellRow] = Coordinate::coordinateFromString($cellAddress);
|
||||
$cellColumnIndex = Coordinate::columnIndexFromString($cellColumn);
|
||||
// Is cell within the range of rows/columns if we're deleting
|
||||
if ($pNumRows < 0 &&
|
||||
if (
|
||||
$pNumRows < 0 &&
|
||||
($cellRow >= ($beforeRow + $pNumRows)) &&
|
||||
($cellRow < $beforeRow)) {
|
||||
($cellRow < $beforeRow)
|
||||
) {
|
||||
return true;
|
||||
} elseif ($pNumCols < 0 &&
|
||||
} elseif (
|
||||
$pNumCols < 0 &&
|
||||
($cellColumnIndex >= ($beforeColumnIndex + $pNumCols)) &&
|
||||
($cellColumnIndex < $beforeColumnIndex)) {
|
||||
($cellColumnIndex < $beforeColumnIndex)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -600,11 +605,11 @@ class ReferenceHelper
|
|||
}
|
||||
}
|
||||
|
||||
// Update workbook: named ranges
|
||||
if (count($pSheet->getParent()->getNamedRanges()) > 0) {
|
||||
foreach ($pSheet->getParent()->getNamedRanges() as $namedRange) {
|
||||
if ($namedRange->getWorksheet()->getHashCode() == $pSheet->getHashCode()) {
|
||||
$namedRange->setRange($this->updateCellReference($namedRange->getRange(), $pBefore, $pNumCols, $pNumRows));
|
||||
// Update workbook: define names
|
||||
if (count($pSheet->getParent()->getDefinedNames()) > 0) {
|
||||
foreach ($pSheet->getParent()->getDefinedNames() as $definedName) {
|
||||
if ($definedName->getWorksheet()->getHashCode() === $pSheet->getHashCode()) {
|
||||
$definedName->setValue($this->updateCellReference($definedName->getValue(), $pBefore, $pNumCols, $pNumRows));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -754,6 +759,141 @@ class ReferenceHelper
|
|||
return implode('"', $formulaBlocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all cell references within a formula, irrespective of worksheet.
|
||||
*/
|
||||
public function updateFormulaReferencesAnyWorksheet(string $formula = '', int $insertColumns = 0, int $insertRows = 0): string
|
||||
{
|
||||
$formula = $this->updateCellReferencesAllWorksheets($formula, $insertColumns, $insertRows);
|
||||
|
||||
if ($insertColumns !== 0) {
|
||||
$formula = $this->updateColumnRangesAllWorksheets($formula, $insertColumns);
|
||||
}
|
||||
|
||||
if ($insertRows !== 0) {
|
||||
$formula = $this->updateRowRangesAllWorksheets($formula, $insertRows);
|
||||
}
|
||||
|
||||
return $formula;
|
||||
}
|
||||
|
||||
private function updateCellReferencesAllWorksheets(string $formula, int $insertColumns, int $insertRows): string
|
||||
{
|
||||
$splitCount = preg_match_all(
|
||||
'/' . Calculation::CALCULATION_REGEXP_CELLREF_RELATIVE . '/mui',
|
||||
$formula,
|
||||
$splitRanges,
|
||||
PREG_OFFSET_CAPTURE
|
||||
);
|
||||
|
||||
$columnLengths = array_map('strlen', array_column($splitRanges[6], 0));
|
||||
$rowLengths = array_map('strlen', array_column($splitRanges[7], 0));
|
||||
$columnOffsets = array_column($splitRanges[6], 1);
|
||||
$rowOffsets = array_column($splitRanges[7], 1);
|
||||
|
||||
$columns = $splitRanges[6];
|
||||
$rows = $splitRanges[7];
|
||||
|
||||
while ($splitCount > 0) {
|
||||
--$splitCount;
|
||||
$columnLength = $columnLengths[$splitCount];
|
||||
$rowLength = $rowLengths[$splitCount];
|
||||
$columnOffset = $columnOffsets[$splitCount];
|
||||
$rowOffset = $rowOffsets[$splitCount];
|
||||
$column = $columns[$splitCount][0];
|
||||
$row = $rows[$splitCount][0];
|
||||
|
||||
if (!empty($column) && $column[0] !== '$') {
|
||||
$column = Coordinate::stringFromColumnIndex(Coordinate::columnIndexFromString($column) + $insertColumns);
|
||||
$formula = substr($formula, 0, $columnOffset) . $column . substr($formula, $columnOffset + $columnLength);
|
||||
}
|
||||
if (!empty($row) && $row[0] !== '$') {
|
||||
$row += $insertRows;
|
||||
$formula = substr($formula, 0, $rowOffset) . $row . substr($formula, $rowOffset + $rowLength);
|
||||
}
|
||||
}
|
||||
|
||||
return $formula;
|
||||
}
|
||||
|
||||
private function updateColumnRangesAllWorksheets(string $formula, int $insertColumns): string
|
||||
{
|
||||
$splitCount = preg_match_all(
|
||||
'/' . Calculation::CALCULATION_REGEXP_COLUMNRANGE_RELATIVE . '/mui',
|
||||
$formula,
|
||||
$splitRanges,
|
||||
PREG_OFFSET_CAPTURE
|
||||
);
|
||||
|
||||
$fromColumnLengths = array_map('strlen', array_column($splitRanges[1], 0));
|
||||
$fromColumnOffsets = array_column($splitRanges[1], 1);
|
||||
$toColumnLengths = array_map('strlen', array_column($splitRanges[2], 0));
|
||||
$toColumnOffsets = array_column($splitRanges[2], 1);
|
||||
|
||||
$fromColumns = $splitRanges[1];
|
||||
$toColumns = $splitRanges[2];
|
||||
|
||||
while ($splitCount > 0) {
|
||||
--$splitCount;
|
||||
$fromColumnLength = $fromColumnLengths[$splitCount];
|
||||
$toColumnLength = $toColumnLengths[$splitCount];
|
||||
$fromColumnOffset = $fromColumnOffsets[$splitCount];
|
||||
$toColumnOffset = $toColumnOffsets[$splitCount];
|
||||
$fromColumn = $fromColumns[$splitCount][0];
|
||||
$toColumn = $toColumns[$splitCount][0];
|
||||
|
||||
if (!empty($fromColumn) && $fromColumn[0] !== '$') {
|
||||
$fromColumn = Coordinate::stringFromColumnIndex(Coordinate::columnIndexFromString($fromColumn) + $insertColumns);
|
||||
$formula = substr($formula, 0, $fromColumnOffset) . $fromColumn . substr($formula, $fromColumnOffset + $fromColumnLength);
|
||||
}
|
||||
if (!empty($toColumn) && $toColumn[0] !== '$') {
|
||||
$toColumn = Coordinate::stringFromColumnIndex(Coordinate::columnIndexFromString($toColumn) + $insertColumns);
|
||||
$formula = substr($formula, 0, $toColumnOffset) . $toColumn . substr($formula, $toColumnOffset + $toColumnLength);
|
||||
}
|
||||
}
|
||||
|
||||
return $formula;
|
||||
}
|
||||
|
||||
private function updateRowRangesAllWorksheets(string $formula, int $insertRows): string
|
||||
{
|
||||
$splitCount = preg_match_all(
|
||||
'/' . Calculation::CALCULATION_REGEXP_ROWRANGE_RELATIVE . '/mui',
|
||||
$formula,
|
||||
$splitRanges,
|
||||
PREG_OFFSET_CAPTURE
|
||||
);
|
||||
|
||||
$fromRowLengths = array_map('strlen', array_column($splitRanges[1], 0));
|
||||
$fromRowOffsets = array_column($splitRanges[1], 1);
|
||||
$toRowLengths = array_map('strlen', array_column($splitRanges[2], 0));
|
||||
$toRowOffsets = array_column($splitRanges[2], 1);
|
||||
|
||||
$fromRows = $splitRanges[1];
|
||||
$toRows = $splitRanges[2];
|
||||
|
||||
while ($splitCount > 0) {
|
||||
--$splitCount;
|
||||
$fromRowLength = $fromRowLengths[$splitCount];
|
||||
$toRowLength = $toRowLengths[$splitCount];
|
||||
$fromRowOffset = $fromRowOffsets[$splitCount];
|
||||
$toRowOffset = $toRowOffsets[$splitCount];
|
||||
$fromRow = $fromRows[$splitCount][0];
|
||||
$toRow = $toRows[$splitCount][0];
|
||||
|
||||
if (!empty($fromRow) && $fromRow[0] !== '$') {
|
||||
$fromRow += $insertRows;
|
||||
$formula = substr($formula, 0, $fromRowOffset) . $fromRow . substr($formula, $fromRowOffset + $fromRowLength);
|
||||
}
|
||||
if (!empty($toRow) && $toRow[0] !== '$') {
|
||||
$toRow += $insertRows;
|
||||
$formula = substr($formula, 0, $toRowOffset) . $toRow . substr($formula, $toRowOffset + $toRowLength);
|
||||
}
|
||||
}
|
||||
|
||||
return $formula;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update cell reference.
|
||||
*
|
||||
|
|
|
@ -5,6 +5,8 @@ namespace PhpOffice\PhpSpreadsheet;
|
|||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Chart\Renderer\IRenderer;
|
||||
use PhpOffice\PhpSpreadsheet\Collection\Memory;
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
use Psr\Http\Message\RequestFactoryInterface;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
class Settings
|
||||
|
@ -42,6 +44,18 @@ class Settings
|
|||
*/
|
||||
private static $cache;
|
||||
|
||||
/**
|
||||
* The HTTP client implementation to be used for network request.
|
||||
*
|
||||
* @var null|ClientInterface
|
||||
*/
|
||||
private static $httpClient;
|
||||
|
||||
/**
|
||||
* @var null|RequestFactoryInterface
|
||||
*/
|
||||
private static $requestFactory;
|
||||
|
||||
/**
|
||||
* Set the locale code to use for formula translations and any special formatting.
|
||||
*
|
||||
|
@ -156,4 +170,49 @@ class Settings
|
|||
|
||||
return self::$cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the HTTP client implementation to be used for network request.
|
||||
*/
|
||||
public static function setHttpClient(ClientInterface $httpClient, RequestFactoryInterface $requestFactory): void
|
||||
{
|
||||
self::$httpClient = $httpClient;
|
||||
self::$requestFactory = $requestFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the HTTP client configuration.
|
||||
*/
|
||||
public static function unsetHttpClient(): void
|
||||
{
|
||||
self::$httpClient = null;
|
||||
self::$requestFactory = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP client implementation to be used for network request.
|
||||
*/
|
||||
public static function getHttpClient(): ClientInterface
|
||||
{
|
||||
self::assertHttpClient();
|
||||
|
||||
return self::$httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP request factory.
|
||||
*/
|
||||
public static function getRequestFactory(): RequestFactoryInterface
|
||||
{
|
||||
self::assertHttpClient();
|
||||
|
||||
return self::$requestFactory;
|
||||
}
|
||||
|
||||
private static function assertHttpClient(): void
|
||||
{
|
||||
if (!self::$httpClient || !self::$requestFactory) {
|
||||
throw new Exception('HTTP client must be configured via Settings::setHttpClient() to be able to use WEBSERVICE function.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
|
|||
|
||||
class CodePage
|
||||
{
|
||||
public const DEFAULT_CODE_PAGE = 'CP1252';
|
||||
|
||||
private static $pageArray = [
|
||||
0 => 'CP1252', // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program
|
||||
367 => 'ASCII', // ASCII
|
||||
|
@ -65,6 +67,11 @@ class CodePage
|
|||
65001 => 'UTF-8', // Unicode (UTF-8)
|
||||
];
|
||||
|
||||
public static function validate(string $codePage): bool
|
||||
{
|
||||
return in_array($codePage, self::$pageArray, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Microsoft Code Page Identifier to Code Page Name which iconv
|
||||
* and mbstring understands.
|
||||
|
|
|
@ -71,8 +71,10 @@ class Date
|
|||
*/
|
||||
public static function setExcelCalendar($baseDate)
|
||||
{
|
||||
if (($baseDate == self::CALENDAR_WINDOWS_1900) ||
|
||||
($baseDate == self::CALENDAR_MAC_1904)) {
|
||||
if (
|
||||
($baseDate == self::CALENDAR_WINDOWS_1900) ||
|
||||
($baseDate == self::CALENDAR_MAC_1904)
|
||||
) {
|
||||
self::$excelCalendar = $baseDate;
|
||||
|
||||
return true;
|
||||
|
@ -387,6 +389,11 @@ class Date
|
|||
if ((substr($pFormatCode, 0, 1) == '_') || (substr($pFormatCode, 0, 2) == '0 ')) {
|
||||
return false;
|
||||
}
|
||||
// Some "special formats" provided in German Excel versions were detected as date time value,
|
||||
// so filter them out here - "\C\H\-00000" (Switzerland) and "\D-00000" (Germany).
|
||||
if (\strpos($pFormatCode, '-00000') !== false) {
|
||||
return false;
|
||||
}
|
||||
// Try checking for any of the date formatting characters that don't appear within square braces
|
||||
if (preg_match('/(^|\])[^\[]*[' . self::$possibleDateFormatCharacters . ']/i', $pFormatCode)) {
|
||||
// We might also have a format mask containing quoted strings...
|
||||
|
@ -395,8 +402,10 @@ class Date
|
|||
$segMatcher = false;
|
||||
foreach (explode('"', $pFormatCode) as $subVal) {
|
||||
// Only test in alternate array entries (the non-quoted blocks)
|
||||
if (($segMatcher = !$segMatcher) &&
|
||||
(preg_match('/(^|\])[^\[]*[' . self::$possibleDateFormatCharacters . ']/i', $subVal))) {
|
||||
if (
|
||||
($segMatcher = !$segMatcher) &&
|
||||
(preg_match('/(^|\])[^\[]*[' . self::$possibleDateFormatCharacters . ']/i', $subVal))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -318,21 +318,25 @@ class Font
|
|||
// value 8.26 was found via interpolation by inspecting real Excel files with Calibri 11 font.
|
||||
$columnWidth = (int) (8.26 * StringHelper::countCharacters($columnText));
|
||||
$columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size
|
||||
|
||||
break;
|
||||
case 'Arial':
|
||||
// value 8 was set because of experience in different exports at Arial 10 font.
|
||||
$columnWidth = (int) (8 * StringHelper::countCharacters($columnText));
|
||||
$columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size
|
||||
|
||||
break;
|
||||
case 'Verdana':
|
||||
// value 8 was found via interpolation by inspecting real Excel files with Verdana 10 font.
|
||||
$columnWidth = (int) (8 * StringHelper::countCharacters($columnText));
|
||||
$columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size
|
||||
|
||||
break;
|
||||
default:
|
||||
// just assume Calibri
|
||||
$columnWidth = (int) (8.26 * StringHelper::countCharacters($columnText));
|
||||
$columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -553,8 +553,10 @@ class EigenvalueDecomposition
|
|||
if ($m == $l) {
|
||||
break;
|
||||
}
|
||||
if (abs($this->H[$m][$m - 1]) * (abs($q) + abs($r)) <
|
||||
$eps * (abs($p) * (abs($this->H[$m - 1][$m - 1]) + abs($z) + abs($this->H[$m + 1][$m + 1])))) {
|
||||
if (
|
||||
abs($this->H[$m][$m - 1]) * (abs($q) + abs($r)) <
|
||||
$eps * (abs($p) * (abs($this->H[$m - 1][$m - 1]) + abs($z) + abs($this->H[$m + 1][$m + 1])))
|
||||
) {
|
||||
break;
|
||||
}
|
||||
--$m;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Pythagorean Theorem:.
|
||||
*
|
||||
|
|
|
@ -131,55 +131,55 @@ class OLE
|
|||
throw new ReaderException('Only Little-Endian encoding is supported.');
|
||||
}
|
||||
// Size of blocks and short blocks in bytes
|
||||
$this->bigBlockSize = 2 ** self::_readInt2($fh);
|
||||
$this->smallBlockSize = 2 ** self::_readInt2($fh);
|
||||
$this->bigBlockSize = 2 ** self::readInt2($fh);
|
||||
$this->smallBlockSize = 2 ** self::readInt2($fh);
|
||||
|
||||
// Skip UID, revision number and version number
|
||||
fseek($fh, 44);
|
||||
// Number of blocks in Big Block Allocation Table
|
||||
$bbatBlockCount = self::_readInt4($fh);
|
||||
$bbatBlockCount = self::readInt4($fh);
|
||||
|
||||
// Root chain 1st block
|
||||
$directoryFirstBlockId = self::_readInt4($fh);
|
||||
$directoryFirstBlockId = self::readInt4($fh);
|
||||
|
||||
// Skip unused bytes
|
||||
fseek($fh, 56);
|
||||
// Streams shorter than this are stored using small blocks
|
||||
$this->bigBlockThreshold = self::_readInt4($fh);
|
||||
$this->bigBlockThreshold = self::readInt4($fh);
|
||||
// Block id of first sector in Short Block Allocation Table
|
||||
$sbatFirstBlockId = self::_readInt4($fh);
|
||||
$sbatFirstBlockId = self::readInt4($fh);
|
||||
// Number of blocks in Short Block Allocation Table
|
||||
$sbbatBlockCount = self::_readInt4($fh);
|
||||
$sbbatBlockCount = self::readInt4($fh);
|
||||
// Block id of first sector in Master Block Allocation Table
|
||||
$mbatFirstBlockId = self::_readInt4($fh);
|
||||
$mbatFirstBlockId = self::readInt4($fh);
|
||||
// Number of blocks in Master Block Allocation Table
|
||||
$mbbatBlockCount = self::_readInt4($fh);
|
||||
$mbbatBlockCount = self::readInt4($fh);
|
||||
$this->bbat = [];
|
||||
|
||||
// Remaining 4 * 109 bytes of current block is beginning of Master
|
||||
// Block Allocation Table
|
||||
$mbatBlocks = [];
|
||||
for ($i = 0; $i < 109; ++$i) {
|
||||
$mbatBlocks[] = self::_readInt4($fh);
|
||||
$mbatBlocks[] = self::readInt4($fh);
|
||||
}
|
||||
|
||||
// Read rest of Master Block Allocation Table (if any is left)
|
||||
$pos = $this->_getBlockOffset($mbatFirstBlockId);
|
||||
$pos = $this->getBlockOffset($mbatFirstBlockId);
|
||||
for ($i = 0; $i < $mbbatBlockCount; ++$i) {
|
||||
fseek($fh, $pos);
|
||||
for ($j = 0; $j < $this->bigBlockSize / 4 - 1; ++$j) {
|
||||
$mbatBlocks[] = self::_readInt4($fh);
|
||||
$mbatBlocks[] = self::readInt4($fh);
|
||||
}
|
||||
// Last block id in each block points to next block
|
||||
$pos = $this->_getBlockOffset(self::_readInt4($fh));
|
||||
$pos = $this->getBlockOffset(self::readInt4($fh));
|
||||
}
|
||||
|
||||
// Read Big Block Allocation Table according to chain specified by $mbatBlocks
|
||||
for ($i = 0; $i < $bbatBlockCount; ++$i) {
|
||||
$pos = $this->_getBlockOffset($mbatBlocks[$i]);
|
||||
$pos = $this->getBlockOffset($mbatBlocks[$i]);
|
||||
fseek($fh, $pos);
|
||||
for ($j = 0; $j < $this->bigBlockSize / 4; ++$j) {
|
||||
$this->bbat[] = self::_readInt4($fh);
|
||||
$this->bbat[] = self::readInt4($fh);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,11 +188,11 @@ class OLE
|
|||
$shortBlockCount = $sbbatBlockCount * $this->bigBlockSize / 4;
|
||||
$sbatFh = $this->getStream($sbatFirstBlockId);
|
||||
for ($blockId = 0; $blockId < $shortBlockCount; ++$blockId) {
|
||||
$this->sbat[$blockId] = self::_readInt4($sbatFh);
|
||||
$this->sbat[$blockId] = self::readInt4($sbatFh);
|
||||
}
|
||||
fclose($sbatFh);
|
||||
|
||||
$this->_readPpsWks($directoryFirstBlockId);
|
||||
$this->readPpsWks($directoryFirstBlockId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ class OLE
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function _getBlockOffset($blockId)
|
||||
public function getBlockOffset($blockId)
|
||||
{
|
||||
return 512 + $blockId * $this->bigBlockSize;
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ class OLE
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
private static function _readInt1($fh)
|
||||
private static function readInt1($fh)
|
||||
{
|
||||
[, $tmp] = unpack('c', fread($fh, 1));
|
||||
|
||||
|
@ -261,7 +261,7 @@ class OLE
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
private static function _readInt2($fh)
|
||||
private static function readInt2($fh)
|
||||
{
|
||||
[, $tmp] = unpack('v', fread($fh, 2));
|
||||
|
||||
|
@ -275,7 +275,7 @@ class OLE
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
private static function _readInt4($fh)
|
||||
private static function readInt4($fh)
|
||||
{
|
||||
[, $tmp] = unpack('V', fread($fh, 4));
|
||||
|
||||
|
@ -290,17 +290,17 @@ class OLE
|
|||
*
|
||||
* @return bool true on success, PEAR_Error on failure
|
||||
*/
|
||||
public function _readPpsWks($blockId)
|
||||
public function readPpsWks($blockId)
|
||||
{
|
||||
$fh = $this->getStream($blockId);
|
||||
for ($pos = 0; true; $pos += 128) {
|
||||
fseek($fh, $pos, SEEK_SET);
|
||||
$nameUtf16 = fread($fh, 64);
|
||||
$nameLength = self::_readInt2($fh);
|
||||
$nameLength = self::readInt2($fh);
|
||||
$nameUtf16 = substr($nameUtf16, 0, $nameLength - 2);
|
||||
// Simple conversion from UTF-16LE to ISO-8859-1
|
||||
$name = str_replace("\x00", '', $nameUtf16);
|
||||
$type = self::_readInt1($fh);
|
||||
$type = self::readInt1($fh);
|
||||
switch ($type) {
|
||||
case self::OLE_PPS_TYPE_ROOT:
|
||||
$pps = new OLE\PPS\Root(null, null, []);
|
||||
|
@ -321,19 +321,19 @@ class OLE
|
|||
fseek($fh, 1, SEEK_CUR);
|
||||
$pps->Type = $type;
|
||||
$pps->Name = $name;
|
||||
$pps->PrevPps = self::_readInt4($fh);
|
||||
$pps->NextPps = self::_readInt4($fh);
|
||||
$pps->DirPps = self::_readInt4($fh);
|
||||
$pps->PrevPps = self::readInt4($fh);
|
||||
$pps->NextPps = self::readInt4($fh);
|
||||
$pps->DirPps = self::readInt4($fh);
|
||||
fseek($fh, 20, SEEK_CUR);
|
||||
$pps->Time1st = self::OLE2LocalDate(fread($fh, 8));
|
||||
$pps->Time2nd = self::OLE2LocalDate(fread($fh, 8));
|
||||
$pps->startBlock = self::_readInt4($fh);
|
||||
$pps->Size = self::_readInt4($fh);
|
||||
$pps->startBlock = self::readInt4($fh);
|
||||
$pps->Size = self::readInt4($fh);
|
||||
$pps->No = count($this->_list);
|
||||
$this->_list[] = $pps;
|
||||
|
||||
// check if the PPS tree (starting from root) is complete
|
||||
if (isset($this->root) && $this->_ppsTreeComplete($this->root->No)) {
|
||||
if (isset($this->root) && $this->ppsTreeComplete($this->root->No)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -367,16 +367,16 @@ class OLE
|
|||
*
|
||||
* @return bool Whether the PPS tree for the given PPS is complete
|
||||
*/
|
||||
public function _ppsTreeComplete($index)
|
||||
private function ppsTreeComplete($index)
|
||||
{
|
||||
return isset($this->_list[$index]) &&
|
||||
($pps = $this->_list[$index]) &&
|
||||
($pps->PrevPps == -1 ||
|
||||
$this->_ppsTreeComplete($pps->PrevPps)) &&
|
||||
$this->ppsTreeComplete($pps->PrevPps)) &&
|
||||
($pps->NextPps == -1 ||
|
||||
$this->_ppsTreeComplete($pps->NextPps)) &&
|
||||
$this->ppsTreeComplete($pps->NextPps)) &&
|
||||
($pps->DirPps == -1 ||
|
||||
$this->_ppsTreeComplete($pps->DirPps));
|
||||
$this->ppsTreeComplete($pps->DirPps));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -505,7 +505,7 @@ class OLE
|
|||
// days from 1-1-1601 until the beggining of UNIX era
|
||||
$days = 134774;
|
||||
// calculate seconds
|
||||
$big_date = $days * 24 * 3600 + gmmktime(date('H', $date), date('i', $date), date('s', $date), date('m', $date), date('d', $date), date('Y', $date));
|
||||
$big_date = $days * 24 * 3600 + mktime((int) date('H', $date), (int) date('i', $date), (int) date('s', $date), (int) date('m', $date), (int) date('d', $date), (int) date('Y', $date));
|
||||
// multiply just to make MS happy
|
||||
$big_date *= 10000000;
|
||||
|
||||
|
@ -558,10 +558,9 @@ class OLE
|
|||
// translate to seconds since 1970:
|
||||
$unixTimestamp = floor(65536.0 * 65536.0 * $timestampHigh + $timestampLow - $days * 24 * 3600 + 0.5);
|
||||
|
||||
if ((int) $unixTimestamp == $unixTimestamp) {
|
||||
return (int) $unixTimestamp;
|
||||
}
|
||||
$iTimestamp = (int) $unixTimestamp;
|
||||
|
||||
return $unixTimestamp >= 0.0 ? PHP_INT_MAX : PHP_INT_MIN;
|
||||
// Overflow conditions can't happen on 64-bit system
|
||||
return ($iTimestamp == $unixTimestamp) ? $iTimestamp : ($unixTimestamp >= 0.0 ? PHP_INT_MAX : PHP_INT_MIN);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ class ChainedBlockStream
|
|||
$this->data = '';
|
||||
if (isset($this->params['size']) && $this->params['size'] < $this->ole->bigBlockThreshold && $blockId != $this->ole->root->startBlock) {
|
||||
// Block id refers to small blocks
|
||||
$rootPos = $this->ole->_getBlockOffset($this->ole->root->startBlock);
|
||||
$rootPos = $this->ole->getBlockOffset($this->ole->root->startBlock);
|
||||
while ($blockId != -2) {
|
||||
$pos = $rootPos + $blockId * $this->ole->bigBlockSize;
|
||||
$blockId = $this->ole->sbat[$blockId];
|
||||
|
@ -81,7 +81,7 @@ class ChainedBlockStream
|
|||
} else {
|
||||
// Block id refers to big blocks
|
||||
while ($blockId != -2) {
|
||||
$pos = $this->ole->_getBlockOffset($blockId);
|
||||
$pos = $this->ole->getBlockOffset($blockId);
|
||||
fseek($this->ole->_file_handle, $pos);
|
||||
$this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
|
||||
$blockId = $this->ole->bbat[$blockId];
|
||||
|
|
|
@ -172,7 +172,7 @@ class PPS
|
|||
*
|
||||
* @return string The binary string
|
||||
*/
|
||||
public function _getPpsWk()
|
||||
public function getPpsWk()
|
||||
{
|
||||
$ret = str_pad($this->Name, 64, "\x00");
|
||||
|
||||
|
@ -192,6 +192,7 @@ class PPS
|
|||
. pack('V', isset($this->startBlock) ? $this->startBlock : 0) // 120
|
||||
. pack('V', $this->Size) // 124
|
||||
. pack('V', 0); // 128
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
@ -206,7 +207,7 @@ class PPS
|
|||
*
|
||||
* @return int The index for this PPS
|
||||
*/
|
||||
public static function _savePpsSetPnt(&$raList, $to_save, $depth = 0)
|
||||
public static function savePpsSetPnt(&$raList, $to_save, $depth = 0)
|
||||
{
|
||||
if (!is_array($to_save) || (empty($to_save))) {
|
||||
return 0xFFFFFFFF;
|
||||
|
@ -217,7 +218,7 @@ class PPS
|
|||
$raList[$cnt]->No = $cnt;
|
||||
$raList[$cnt]->PrevPps = 0xFFFFFFFF;
|
||||
$raList[$cnt]->NextPps = 0xFFFFFFFF;
|
||||
$raList[$cnt]->DirPps = self::_savePpsSetPnt($raList, @$raList[$cnt]->children, $depth++);
|
||||
$raList[$cnt]->DirPps = self::savePpsSetPnt($raList, @$raList[$cnt]->children, $depth++);
|
||||
} else {
|
||||
$iPos = floor(count($to_save) / 2);
|
||||
$aPrev = array_slice($to_save, 0, $iPos);
|
||||
|
@ -226,9 +227,9 @@ class PPS
|
|||
// If the first entry, it's the root... Don't clone it!
|
||||
$raList[$cnt] = ($depth == 0) ? $to_save[$iPos] : clone $to_save[$iPos];
|
||||
$raList[$cnt]->No = $cnt;
|
||||
$raList[$cnt]->PrevPps = self::_savePpsSetPnt($raList, $aPrev, $depth++);
|
||||
$raList[$cnt]->NextPps = self::_savePpsSetPnt($raList, $aNext, $depth++);
|
||||
$raList[$cnt]->DirPps = self::_savePpsSetPnt($raList, @$raList[$cnt]->children, $depth++);
|
||||
$raList[$cnt]->PrevPps = self::savePpsSetPnt($raList, $aPrev, $depth++);
|
||||
$raList[$cnt]->NextPps = self::savePpsSetPnt($raList, $aNext, $depth++);
|
||||
$raList[$cnt]->DirPps = self::savePpsSetPnt($raList, @$raList[$cnt]->children, $depth++);
|
||||
}
|
||||
|
||||
return $cnt;
|
||||
|
|
|
@ -80,21 +80,21 @@ class Root extends PPS
|
|||
|
||||
// Make an array of PPS's (for Save)
|
||||
$aList = [];
|
||||
PPS::_savePpsSetPnt($aList, [$this]);
|
||||
PPS::savePpsSetPnt($aList, [$this]);
|
||||
// calculate values for header
|
||||
[$iSBDcnt, $iBBcnt, $iPPScnt] = $this->_calcSize($aList); //, $rhInfo);
|
||||
[$iSBDcnt, $iBBcnt, $iPPScnt] = $this->calcSize($aList); //, $rhInfo);
|
||||
// Save Header
|
||||
$this->_saveHeader($iSBDcnt, $iBBcnt, $iPPScnt);
|
||||
$this->saveHeader($iSBDcnt, $iBBcnt, $iPPScnt);
|
||||
|
||||
// Make Small Data string (write SBD)
|
||||
$this->_data = $this->_makeSmallData($aList);
|
||||
$this->_data = $this->makeSmallData($aList);
|
||||
|
||||
// Write BB
|
||||
$this->_saveBigData($iSBDcnt, $aList);
|
||||
$this->saveBigData($iSBDcnt, $aList);
|
||||
// Write PPS
|
||||
$this->_savePps($aList);
|
||||
$this->savePps($aList);
|
||||
// Write Big Block Depot and BDList and Adding Header informations
|
||||
$this->_saveBbd($iSBDcnt, $iBBcnt, $iPPScnt);
|
||||
$this->saveBbd($iSBDcnt, $iBBcnt, $iPPScnt);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ class Root extends PPS
|
|||
*
|
||||
* @return float[] The array of numbers
|
||||
*/
|
||||
public function _calcSize(&$raList)
|
||||
private function calcSize(&$raList)
|
||||
{
|
||||
// Calculate Basic Setting
|
||||
[$iSBDcnt, $iBBcnt, $iPPScnt] = [0, 0, 0];
|
||||
|
@ -160,7 +160,7 @@ class Root extends PPS
|
|||
* @param int $iBBcnt
|
||||
* @param int $iPPScnt
|
||||
*/
|
||||
public function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt): void
|
||||
private function saveHeader($iSBDcnt, $iBBcnt, $iPPScnt): void
|
||||
{
|
||||
$FILE = $this->fileHandle;
|
||||
|
||||
|
@ -239,7 +239,7 @@ class Root extends PPS
|
|||
* @param int $iStBlk
|
||||
* @param array &$raList Reference to array of PPS's
|
||||
*/
|
||||
public function _saveBigData($iStBlk, &$raList): void
|
||||
private function saveBigData($iStBlk, &$raList): void
|
||||
{
|
||||
$FILE = $this->fileHandle;
|
||||
|
||||
|
@ -271,7 +271,7 @@ class Root extends PPS
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function _makeSmallData(&$raList)
|
||||
private function makeSmallData(&$raList)
|
||||
{
|
||||
$sRes = '';
|
||||
$FILE = $this->fileHandle;
|
||||
|
@ -321,12 +321,12 @@ class Root extends PPS
|
|||
*
|
||||
* @param array $raList Reference to an array with all PPS's
|
||||
*/
|
||||
public function _savePps(&$raList): void
|
||||
private function savePps(&$raList): void
|
||||
{
|
||||
// Save each PPS WK
|
||||
$iC = count($raList);
|
||||
for ($i = 0; $i < $iC; ++$i) {
|
||||
fwrite($this->fileHandle, $raList[$i]->_getPpsWk());
|
||||
fwrite($this->fileHandle, $raList[$i]->getPpsWk());
|
||||
}
|
||||
// Adjust for Block
|
||||
$iCnt = count($raList);
|
||||
|
@ -343,7 +343,7 @@ class Root extends PPS
|
|||
* @param int $iBsize
|
||||
* @param int $iPpsCnt
|
||||
*/
|
||||
public function _saveBbd($iSbdSize, $iBsize, $iPpsCnt): void
|
||||
private function saveBbd($iSbdSize, $iBsize, $iPpsCnt): void
|
||||
{
|
||||
$FILE = $this->fileHandle;
|
||||
// Calculate Basic Setting
|
||||
|
|
|
@ -180,7 +180,7 @@ class OLERead
|
|||
|
||||
// read the directory stream
|
||||
$block = $this->rootStartBlock;
|
||||
$this->entry = $this->_readData($block);
|
||||
$this->entry = $this->readData($block);
|
||||
|
||||
$this->readPropertySets();
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ class OLERead
|
|||
$streamData = '';
|
||||
|
||||
if ($this->props[$stream]['size'] < self::SMALL_BLOCK_THRESHOLD) {
|
||||
$rootdata = $this->_readData($this->props[$this->rootentry]['startBlock']);
|
||||
$rootdata = $this->readData($this->props[$this->rootentry]['startBlock']);
|
||||
|
||||
$block = $this->props[$stream]['startBlock'];
|
||||
|
||||
|
@ -241,7 +241,7 @@ class OLERead
|
|||
*
|
||||
* @return string Data for standard stream
|
||||
*/
|
||||
private function _readData($bl)
|
||||
private function readData($bl)
|
||||
{
|
||||
$block = $bl;
|
||||
$data = '';
|
||||
|
|
|
@ -2,8 +2,41 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Shared;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Protection;
|
||||
|
||||
class PasswordHasher
|
||||
{
|
||||
/**
|
||||
* Get algorithm name for PHP.
|
||||
*/
|
||||
private static function getAlgorithm(string $algorithmName): string
|
||||
{
|
||||
if (!$algorithmName) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Mapping between algorithm name in Excel and algorithm name in PHP
|
||||
$mapping = [
|
||||
Protection::ALGORITHM_MD2 => 'md2',
|
||||
Protection::ALGORITHM_MD4 => 'md4',
|
||||
Protection::ALGORITHM_MD5 => 'md5',
|
||||
Protection::ALGORITHM_SHA_1 => 'sha1',
|
||||
Protection::ALGORITHM_SHA_256 => 'sha256',
|
||||
Protection::ALGORITHM_SHA_384 => 'sha384',
|
||||
Protection::ALGORITHM_SHA_512 => 'sha512',
|
||||
Protection::ALGORITHM_RIPEMD_128 => 'ripemd128',
|
||||
Protection::ALGORITHM_RIPEMD_160 => 'ripemd160',
|
||||
Protection::ALGORITHM_WHIRLPOOL => 'whirlpool',
|
||||
];
|
||||
|
||||
if (array_key_exists($algorithmName, $mapping)) {
|
||||
return $mapping[$algorithmName];
|
||||
}
|
||||
|
||||
throw new Exception('Unsupported password algorithm: ' . $algorithmName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a password hash from a given string.
|
||||
*
|
||||
|
@ -12,10 +45,8 @@ class PasswordHasher
|
|||
* Spreadsheet_Excel_Writer by Xavier Noguer <xnoguer@rezebra.com>.
|
||||
*
|
||||
* @param string $pPassword Password to hash
|
||||
*
|
||||
* @return string Hashed password
|
||||
*/
|
||||
public static function hashPassword($pPassword)
|
||||
private static function defaultHashPassword(string $pPassword): string
|
||||
{
|
||||
$password = 0x0000;
|
||||
$charPos = 1; // char position
|
||||
|
@ -34,4 +65,36 @@ class PasswordHasher
|
|||
|
||||
return strtoupper(dechex($password));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a password hash from a given string by a specific algorithm.
|
||||
*
|
||||
* 2.4.2.4 ISO Write Protection Method
|
||||
*
|
||||
* @see https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-offcrypto/1357ea58-646e-4483-92ef-95d718079d6f
|
||||
*
|
||||
* @param string $password Password to hash
|
||||
* @param string $algorithm Hash algorithm used to compute the password hash value
|
||||
* @param string $salt Pseudorandom string
|
||||
* @param int $spinCount Number of times to iterate on a hash of a password
|
||||
*
|
||||
* @return string Hashed password
|
||||
*/
|
||||
public static function hashPassword(string $password, string $algorithm = '', string $salt = '', int $spinCount = 10000): string
|
||||
{
|
||||
$phpAlgorithm = self::getAlgorithm($algorithm);
|
||||
if (!$phpAlgorithm) {
|
||||
return self::defaultHashPassword($password);
|
||||
}
|
||||
|
||||
$saltValue = base64_decode($salt);
|
||||
$encodedPassword = mb_convert_encoding($password, 'UCS-2LE', 'UTF-8');
|
||||
|
||||
$hashValue = hash($phpAlgorithm, $saltValue . $encodedPassword, true);
|
||||
for ($i = 0; $i < $spinCount; ++$i) {
|
||||
$hashValue = hash($phpAlgorithm, $hashValue . pack('L', $i), true);
|
||||
}
|
||||
|
||||
return base64_encode($hashValue);
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue