Merge branch 'master' into Table-Reader-for-Xlsx
# Conflicts: # phpstan-baseline.neon # src/PhpSpreadsheet/Reader/Xlsx.php # src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php # src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
This commit is contained in:
commit
123952767c
|
|
@ -34,7 +34,7 @@ If this is an issue with reading a specific spreadsheet file, then it may be app
|
||||||
- [ ] Writer
|
- [ ] Writer
|
||||||
- [ ] Styles
|
- [ ] Styles
|
||||||
- [ ] Data Validations
|
- [ ] Data Validations
|
||||||
- [ ] Formula Calulations
|
- [ ] Formula Calculations
|
||||||
- [ ] Charts
|
- [ ] Charts
|
||||||
- [ ] AutoFilter
|
- [ ] AutoFilter
|
||||||
- [ ] Form Elements
|
- [ ] Form Elements
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,10 @@ jobs:
|
||||||
- '8.0'
|
- '8.0'
|
||||||
- '8.1'
|
- '8.1'
|
||||||
|
|
||||||
|
include:
|
||||||
|
- php-version: '8.2'
|
||||||
|
experimental: true
|
||||||
|
|
||||||
name: PHP ${{ matrix.php-version }}
|
name: PHP ${{ matrix.php-version }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -39,7 +43,7 @@ jobs:
|
||||||
|
|
||||||
- name: Delete composer lock file
|
- name: Delete composer lock file
|
||||||
id: composer-lock
|
id: composer-lock
|
||||||
if: ${{ matrix.php-version == '8.1' }}
|
if: ${{ matrix.php-version == '8.1' || matrix.php-version == '8.2' }}
|
||||||
run: |
|
run: |
|
||||||
rm composer.lock
|
rm composer.lock
|
||||||
echo "::set-output name=flags::--ignore-platform-reqs"
|
echo "::set-output name=flags::--ignore-platform-reqs"
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ $config
|
||||||
'function_declaration' => true,
|
'function_declaration' => true,
|
||||||
'function_to_constant' => true,
|
'function_to_constant' => true,
|
||||||
'function_typehint_space' => true,
|
'function_typehint_space' => true,
|
||||||
'general_phpdoc_annotation_remove' => ['annotations' => ['access', 'category', 'copyright', 'throws']],
|
'general_phpdoc_annotation_remove' => ['annotations' => ['access', 'category', 'copyright']],
|
||||||
'global_namespace_import' => true,
|
'global_namespace_import' => true,
|
||||||
'header_comment' => false, // We don't use common header in all our files
|
'header_comment' => false, // We don't use common header in all our files
|
||||||
'heredoc_indentation' => false, // Requires PHP >= 7.3
|
'heredoc_indentation' => false, // Requires PHP >= 7.3
|
||||||
|
|
|
||||||
148
CHANGELOG.md
148
CHANGELOG.md
|
|
@ -9,6 +9,139 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- Nothing
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Nothing
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
|
||||||
|
- Nothing
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- Nothing
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Xlsx Reader Accept Palette of Fewer than 64 Colors [Issue #3093](https://github.com/PHPOffice/PhpSpreadsheet/issues/3093) [PR #3096](https://github.com/PHPOffice/PhpSpreadsheet/pull/3096)
|
||||||
|
- Use Locale-Independent Float Conversion for Xlsx Writer Custom Property [Issue #3095](https://github.com/PHPOffice/PhpSpreadsheet/issues/3095) [PR #3099](https://github.com/PHPOffice/PhpSpreadsheet/pull/3099)
|
||||||
|
- Allow setting AutoFilter range on a single cell or row [Issue #3102](https://github.com/PHPOffice/PhpSpreadsheet/issues/3102) [PR #3111](https://github.com/PHPOffice/PhpSpreadsheet/pull/3111)
|
||||||
|
- Xlsx Reader External Data Validations Flag Missing [Issue #2677](https://github.com/PHPOffice/PhpSpreadsheet/issues/2677) [PR #3078](https://github.com/PHPOffice/PhpSpreadsheet/pull/3078)
|
||||||
|
- Reduces extra memory usage on `__destruct()` calls
|
||||||
|
|
||||||
|
|
||||||
|
## 1.25.2 - 2022-09-25
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Nothing
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Nothing
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
|
||||||
|
- Nothing
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- Nothing
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Composer dependency clash with ezyang/htmlpurifier
|
||||||
|
|
||||||
|
|
||||||
|
## 1.25.0 - 2022-09-25
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Implementation of the new `TEXTBEFORE()`, `TEXTAFTER()` and `TEXTSPLIT()` Excel Functions
|
||||||
|
- Implementation of the `ARRAYTOTEXT()` and `VALUETOTEXT()` Excel Functions
|
||||||
|
- Support for [mitoteam/jpgraph](https://packagist.org/packages/mitoteam/jpgraph) implementation of
|
||||||
|
JpGraph library to render charts added.
|
||||||
|
- Charts: Add Gradients, Transparency, Hidden Axes, Rounded Corners, Trendlines, Date Axes.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Allow variant behaviour when merging cells [Issue #3065](https://github.com/PHPOffice/PhpSpreadsheet/issues/3065)
|
||||||
|
- Merge methods now allow an additional `$behaviour` argument. Permitted values are:
|
||||||
|
- Worksheet::MERGE_CELL_CONTENT_EMPTY - Empty the content of the hidden cells (the default behaviour)
|
||||||
|
- Worksheet::MERGE_CELL_CONTENT_HIDE - Keep the content of the hidden cells
|
||||||
|
- Worksheet::MERGE_CELL_CONTENT_MERGE - Move the content of the hidden cells into the first cell
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
|
||||||
|
- Axis getLineProperty deprecated in favor of getLineColorProperty.
|
||||||
|
- Moved majorGridlines and minorGridlines from Chart to Axis. Setting either in Chart constructor or through Chart methods, or getting either using Chart methods is deprecated.
|
||||||
|
- Chart::EXCEL_COLOR_TYPE_* copied from Properties to ChartColor; use in Properties is deprecated.
|
||||||
|
- ChartColor::EXCEL_COLOR_TYPE_ARGB deprecated in favor of EXCEL_COLOR_TYPE_RGB ("A" component was never allowed).
|
||||||
|
- Misspelled Properties::LINE_STYLE_DASH_SQUERE_DOT deprecated in favor of LINE_STYLE_DASH_SQUARE_DOT.
|
||||||
|
- Clone not permitted for Spreadsheet. Spreadsheet->copy() can be used instead.
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- Nothing
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix update to defined names when inserting/deleting rows/columns [Issue #3076](https://github.com/PHPOffice/PhpSpreadsheet/issues/3076) [PR #3077](https://github.com/PHPOffice/PhpSpreadsheet/pull/3077)
|
||||||
|
- Fix DataValidation sqRef when inserting/deleting rows/columns [Issue #3056](https://github.com/PHPOffice/PhpSpreadsheet/issues/3056) [PR #3074](https://github.com/PHPOffice/PhpSpreadsheet/pull/3074)
|
||||||
|
- Named ranges not usable as anchors in OFFSET function [Issue #3013](https://github.com/PHPOffice/PhpSpreadsheet/issues/3013)
|
||||||
|
- Fully flatten an array [Issue #2955](https://github.com/PHPOffice/PhpSpreadsheet/issues/2955) [PR #2956](https://github.com/PHPOffice/PhpSpreadsheet/pull/2956)
|
||||||
|
- cellExists() and getCell() methods should support UTF-8 named cells [Issue #2987](https://github.com/PHPOffice/PhpSpreadsheet/issues/2987) [PR #2988](https://github.com/PHPOffice/PhpSpreadsheet/pull/2988)
|
||||||
|
- Spreadsheet copy fixed, clone disabled. [PR #2951](https://github.com/PHPOffice/PhpSpreadsheet/pull/2951)
|
||||||
|
- Fix PDF problems with text rotation and paper size. [Issue #1747](https://github.com/PHPOffice/PhpSpreadsheet/issues/1747) [Issue #1713](https://github.com/PHPOffice/PhpSpreadsheet/issues/1713) [PR #2960](https://github.com/PHPOffice/PhpSpreadsheet/pull/2960)
|
||||||
|
- Limited support for chart titles as formulas [Issue #2965](https://github.com/PHPOffice/PhpSpreadsheet/issues/2965) [Issue #749](https://github.com/PHPOffice/PhpSpreadsheet/issues/749) [PR #2971](https://github.com/PHPOffice/PhpSpreadsheet/pull/2971)
|
||||||
|
- Add Gradients, Transparency, and Hidden Axes to Chart [Issue #2257](https://github.com/PHPOffice/PhpSpreadsheet/issues/2257) [Issue #2229](https://github.com/PHPOffice/PhpSpreadsheet/issues/2929) [Issue #2935](https://github.com/PHPOffice/PhpSpreadsheet/issues/2935) [PR #2950](https://github.com/PHPOffice/PhpSpreadsheet/pull/2950)
|
||||||
|
- Chart Support for Rounded Corners and Trendlines [Issue #2968](https://github.com/PHPOffice/PhpSpreadsheet/issues/2968) [Issue #2815](https://github.com/PHPOffice/PhpSpreadsheet/issues/2815) [PR #2976](https://github.com/PHPOffice/PhpSpreadsheet/pull/2976)
|
||||||
|
- Add setName Method for Chart [Issue #2991](https://github.com/PHPOffice/PhpSpreadsheet/issues/2991) [PR #3001](https://github.com/PHPOffice/PhpSpreadsheet/pull/3001)
|
||||||
|
- Eliminate partial dependency on php-intl in StringHelper [Issue #2982](https://github.com/PHPOffice/PhpSpreadsheet/issues/2982) [PR #2994](https://github.com/PHPOffice/PhpSpreadsheet/pull/2994)
|
||||||
|
- Minor changes for Pdf [Issue #2999](https://github.com/PHPOffice/PhpSpreadsheet/issues/2999) [PR #3002](https://github.com/PHPOffice/PhpSpreadsheet/pull/3002) [PR #3006](https://github.com/PHPOffice/PhpSpreadsheet/pull/3006)
|
||||||
|
- Html/Pdf Do net set background color for cells using (default) nofill [PR #3016](https://github.com/PHPOffice/PhpSpreadsheet/pull/3016)
|
||||||
|
- Add support for Date Axis to Chart [Issue #2967](https://github.com/PHPOffice/PhpSpreadsheet/issues/2967) [PR #3018](https://github.com/PHPOffice/PhpSpreadsheet/pull/3018)
|
||||||
|
- Reconcile Differences Between Css and Excel for Cell Alignment [PR #3048](https://github.com/PHPOffice/PhpSpreadsheet/pull/3048)
|
||||||
|
- R1C1 Format Internationalization and Better Support for Relative Offsets [Issue #1704](https://github.com/PHPOffice/PhpSpreadsheet/issues/1704) [PR #3052](https://github.com/PHPOffice/PhpSpreadsheet/pull/3052)
|
||||||
|
- Minor Fix for Percentage Formatting [Issue #1929](https://github.com/PHPOffice/PhpSpreadsheet/issues/1929) [PR #3053](https://github.com/PHPOffice/PhpSpreadsheet/pull/3053)
|
||||||
|
|
||||||
|
## 1.24.1 - 2022-07-18
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Support for SimpleCache Interface versions 1.0, 2.0 and 3.0
|
||||||
|
- Add Chart Axis Option textRotation [Issue #2705](https://github.com/PHPOffice/PhpSpreadsheet/issues/2705) [PR #2940](https://github.com/PHPOffice/PhpSpreadsheet/pull/2940)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Nothing
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
|
||||||
|
- Nothing
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- Nothing
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix Encoding issue with Html reader (PHP 8.2 deprecation for mb_convert_encoding) [Issue #2942](https://github.com/PHPOffice/PhpSpreadsheet/issues/2942) [PR #2943](https://github.com/PHPOffice/PhpSpreadsheet/pull/2943)
|
||||||
|
- Additional Chart fixes
|
||||||
|
- Pie chart with part separated unwantedly [Issue #2506](https://github.com/PHPOffice/PhpSpreadsheet/issues/2506) [PR #2928](https://github.com/PHPOffice/PhpSpreadsheet/pull/2928)
|
||||||
|
- Chart styling is lost on simple load / save process [Issue #1797](https://github.com/PHPOffice/PhpSpreadsheet/issues/1797) [Issue #2077](https://github.com/PHPOffice/PhpSpreadsheet/issues/2077) [PR #2930](https://github.com/PHPOffice/PhpSpreadsheet/pull/2930)
|
||||||
|
- Can't create contour chart (surface 2d) [Issue #2931](https://github.com/PHPOffice/PhpSpreadsheet/issues/2931) [PR #2933](https://github.com/PHPOffice/PhpSpreadsheet/pull/2933)
|
||||||
|
- VLOOKUP Breaks When Array Contains Null Cells [Issue #2934](https://github.com/PHPOffice/PhpSpreadsheet/issues/2934) [PR #2939](https://github.com/PHPOffice/PhpSpreadsheet/pull/2939)
|
||||||
|
|
||||||
|
## 1.24.0 - 2022-07-09
|
||||||
|
|
||||||
|
Note that this will be the last 1.x branch release before the 2.x release. We will maintain both branches in parallel for a time; but users are requested to update to version 2.0 once that is fully available.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `removeComment()` method for Worksheet [PR #2875](https://github.com/PHPOffice/PhpSpreadsheet/pull/2875/files)
|
||||||
- Add point size option for scatter charts [Issue #2298](https://github.com/PHPOffice/PhpSpreadsheet/issues/2298) [PR #2801](https://github.com/PHPOffice/PhpSpreadsheet/pull/2801)
|
- Add point size option for scatter charts [Issue #2298](https://github.com/PHPOffice/PhpSpreadsheet/issues/2298) [PR #2801](https://github.com/PHPOffice/PhpSpreadsheet/pull/2801)
|
||||||
- Basic support for Xlsx reading/writing Chart Sheets [PR #2830](https://github.com/PHPOffice/PhpSpreadsheet/pull/2830)
|
- Basic support for Xlsx reading/writing Chart Sheets [PR #2830](https://github.com/PHPOffice/PhpSpreadsheet/pull/2830)
|
||||||
|
|
||||||
|
|
@ -18,14 +151,20 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
||||||
- Added Worksheet visibility in Ods Writer [PR #2850](https://github.com/PHPOffice/PhpSpreadsheet/pull/2850)
|
- Added Worksheet visibility in Ods Writer [PR #2850](https://github.com/PHPOffice/PhpSpreadsheet/pull/2850)
|
||||||
- Allow Csv Reader to treat string as contents of file [Issue #1285](https://github.com/PHPOffice/PhpSpreadsheet/issues/1285) [PR #2792](https://github.com/PHPOffice/PhpSpreadsheet/pull/2792)
|
- Allow Csv Reader to treat string as contents of file [Issue #1285](https://github.com/PHPOffice/PhpSpreadsheet/issues/1285) [PR #2792](https://github.com/PHPOffice/PhpSpreadsheet/pull/2792)
|
||||||
- Allow Csv Reader to store null string rather than leave cell empty [Issue #2840](https://github.com/PHPOffice/PhpSpreadsheet/issues/2840) [PR #2842](https://github.com/PHPOffice/PhpSpreadsheet/pull/2842)
|
- Allow Csv Reader to store null string rather than leave cell empty [Issue #2840](https://github.com/PHPOffice/PhpSpreadsheet/issues/2840) [PR #2842](https://github.com/PHPOffice/PhpSpreadsheet/pull/2842)
|
||||||
|
- Provide new Worksheet methods to identify if a row or column is "empty", making allowance for different definitions of "empty":
|
||||||
|
- Treat rows/columns containing no cell records as empty (default)
|
||||||
|
- Treat cells containing a null value as empty
|
||||||
|
- Treat cells containing an empty string as empty
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Better enforcement of value modification to match specified datatype when using setValueExplicit()
|
- Modify `rangeBoundaries()`, `rangeDimension()` and `getRangeBoundaries()` Coordinate methods to work with row/column ranges as well as with cell ranges and cells [PR #2926](https://github.com/PHPOffice/PhpSpreadsheet/pull/2926)
|
||||||
|
- Better enforcement of value modification to match specified datatype when using `setValueExplicit()`
|
||||||
- Relax validation of merge cells to allow merge for a single cell reference [Issue #2776](https://github.com/PHPOffice/PhpSpreadsheet/issues/2776)
|
- Relax validation of merge cells to allow merge for a single cell reference [Issue #2776](https://github.com/PHPOffice/PhpSpreadsheet/issues/2776)
|
||||||
- Memory and speed improvements, particularly for the Cell Collection, and the Writers.
|
- Memory and speed improvements, particularly for the Cell Collection, and the Writers.
|
||||||
|
|
||||||
See [the Discussion section on github](https://github.com/PHPOffice/PhpSpreadsheet/discussions/2821) for details of performance across versions
|
See [the Discussion section on github](https://github.com/PHPOffice/PhpSpreadsheet/discussions/2821) for details of performance across versions
|
||||||
|
- Improved performance for removing rows/columns from a worksheet
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
||||||
|
|
@ -43,7 +182,12 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
||||||
- Time interval formatting [Issue #2768](https://github.com/PHPOffice/PhpSpreadsheet/issues/2768) [PR #2772](https://github.com/PHPOffice/PhpSpreadsheet/pull/2772)
|
- Time interval formatting [Issue #2768](https://github.com/PHPOffice/PhpSpreadsheet/issues/2768) [PR #2772](https://github.com/PHPOffice/PhpSpreadsheet/pull/2772)
|
||||||
- Copy from Xls(x) to Html/Pdf loses drawings [PR #2788](https://github.com/PHPOffice/PhpSpreadsheet/pull/2788)
|
- Copy from Xls(x) to Html/Pdf loses drawings [PR #2788](https://github.com/PHPOffice/PhpSpreadsheet/pull/2788)
|
||||||
- Html Reader converting cell containing 0 to null string [Issue #2810](https://github.com/PHPOffice/PhpSpreadsheet/issues/2810) [PR #2813](https://github.com/PHPOffice/PhpSpreadsheet/pull/2813)
|
- Html Reader converting cell containing 0 to null string [Issue #2810](https://github.com/PHPOffice/PhpSpreadsheet/issues/2810) [PR #2813](https://github.com/PHPOffice/PhpSpreadsheet/pull/2813)
|
||||||
- Many fixes for Charts, especially, but not limited to, Scatter, Bubble, and Surface charts. [Issue #2762](https://github.com/PHPOffice/PhpSpreadsheet/issues/2762) [Issue #2299](https://github.com/PHPOffice/PhpSpreadsheet/issues/2299) [Issue #2700](https://github.com/PHPOffice/PhpSpreadsheet/issues/2700) [Issue #2817](https://github.com/PHPOffice/PhpSpreadsheet/issues/2817) [Issue #2763](https://github.com/PHPOffice/PhpSpreadsheet/issues/2763) [PR #2828](https://github.com/PHPOffice/PhpSpreadsheet/pull/2828) [PR #2841](https://github.com/PHPOffice/PhpSpreadsheet/pull/2841) [PR #2846](https://github.com/PHPOffice/PhpSpreadsheet/pull/2846) [PR #2852](https://github.com/PHPOffice/PhpSpreadsheet/pull/2852)
|
- Many fixes for Charts, especially, but not limited to, Scatter, Bubble, and Surface charts. [Issue #2762](https://github.com/PHPOffice/PhpSpreadsheet/issues/2762) [Issue #2299](https://github.com/PHPOffice/PhpSpreadsheet/issues/2299) [Issue #2700](https://github.com/PHPOffice/PhpSpreadsheet/issues/2700) [Issue #2817](https://github.com/PHPOffice/PhpSpreadsheet/issues/2817) [Issue #2763](https://github.com/PHPOffice/PhpSpreadsheet/issues/2763) [Issue #2219](https://github.com/PHPOffice/PhpSpreadsheet/issues/2219) [Issue #2863](https://github.com/PHPOffice/PhpSpreadsheet/issues/2863) [PR #2828](https://github.com/PHPOffice/PhpSpreadsheet/pull/2828) [PR #2841](https://github.com/PHPOffice/PhpSpreadsheet/pull/2841) [PR #2846](https://github.com/PHPOffice/PhpSpreadsheet/pull/2846) [PR #2852](https://github.com/PHPOffice/PhpSpreadsheet/pull/2852) [PR #2856](https://github.com/PHPOffice/PhpSpreadsheet/pull/2856) [PR #2865](https://github.com/PHPOffice/PhpSpreadsheet/pull/2865) [PR #2872](https://github.com/PHPOffice/PhpSpreadsheet/pull/2872) [PR #2879](https://github.com/PHPOffice/PhpSpreadsheet/pull/2879) [PR #2898](https://github.com/PHPOffice/PhpSpreadsheet/pull/2898) [PR #2906](https://github.com/PHPOffice/PhpSpreadsheet/pull/2906) [PR #2922](https://github.com/PHPOffice/PhpSpreadsheet/pull/2922) [PR #2923](https://github.com/PHPOffice/PhpSpreadsheet/pull/2923)
|
||||||
|
- Adjust both coordinates for two-cell anchors when rows/columns are added/deleted. [Issue #2908](https://github.com/PHPOffice/PhpSpreadsheet/issues/2908) [PR #2909](https://github.com/PHPOffice/PhpSpreadsheet/pull/2909)
|
||||||
|
- Keep calculated string results below 32K. [PR #2921](https://github.com/PHPOffice/PhpSpreadsheet/pull/2921)
|
||||||
|
- Filter out illegal Unicode char values FFFE/FFFF. [Issue #2897](https://github.com/PHPOffice/PhpSpreadsheet/issues/2897) [PR #2910](https://github.com/PHPOffice/PhpSpreadsheet/pull/2910)
|
||||||
|
- Better handling of REF errors and propagation of all errors in Calculation engine. [PR #2902](https://github.com/PHPOffice/PhpSpreadsheet/pull/2902)
|
||||||
|
- Calculating Engine regexp for Column/Row references when there are multiple quoted worksheet references in the formula [Issue #2874](https://github.com/PHPOffice/PhpSpreadsheet/issues/2874) [PR #2899](https://github.com/PHPOffice/PhpSpreadsheet/pull/2899)
|
||||||
|
|
||||||
## 1.23.0 - 2022-04-24
|
## 1.23.0 - 2022-04-24
|
||||||
|
|
||||||
|
|
|
||||||
38
README.md
38
README.md
|
|
@ -29,7 +29,7 @@ composer require phpoffice/phpspreadsheet
|
||||||
```
|
```
|
||||||
|
|
||||||
If you are building your installation on a development machine that is on a different PHP version to the server where it will be deployed, or if your PHP CLI version is not the same as your run-time such as `php-fpm` or Apache's `mod_php`, then you might want to add the following to your `composer.json` before installing:
|
If you are building your installation on a development machine that is on a different PHP version to the server where it will be deployed, or if your PHP CLI version is not the same as your run-time such as `php-fpm` or Apache's `mod_php`, then you might want to add the following to your `composer.json` before installing:
|
||||||
```json lines
|
```json
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"phpoffice/phpspreadsheet": "^1.23"
|
"phpoffice/phpspreadsheet": "^1.23"
|
||||||
|
|
@ -49,6 +49,42 @@ to ensure that the correct dependencies are retrieved to match your deployment e
|
||||||
|
|
||||||
See [CLI vs Application run-time](https://php.watch/articles/composer-platform-check) for more details.
|
See [CLI vs Application run-time](https://php.watch/articles/composer-platform-check) for more details.
|
||||||
|
|
||||||
|
### Additional Installation Options
|
||||||
|
|
||||||
|
If you want to write to PDF, or to include Charts when you write to HTML or PDF, then you will need to install additional libraries:
|
||||||
|
|
||||||
|
#### PDF
|
||||||
|
|
||||||
|
For PDF Generation, you can install any of the following, and then configure PhpSpreadsheet to indicate which library you are going to use:
|
||||||
|
- mpdf/mpdf
|
||||||
|
- dompdf/dompdf
|
||||||
|
- tecnickcom/tcpdf
|
||||||
|
|
||||||
|
and configure PhpSpreadsheet using:
|
||||||
|
|
||||||
|
```php
|
||||||
|
// Dompdf, Mpdf or Tcpdf (as appropriate)
|
||||||
|
$className = \PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf::class;
|
||||||
|
IOFactory::registerWriter('Pdf', $className);
|
||||||
|
```
|
||||||
|
or the appropriate PDF Writer wrapper for the library that you have chosen to install.
|
||||||
|
|
||||||
|
#### Chart Export
|
||||||
|
|
||||||
|
For Chart export, we support following packages, which you will also need to install yourself using `composer require`
|
||||||
|
- [jpgraph/jpgraph](https://packagist.org/packages/jpgraph/jpgraph) (this package was abandoned at version 4.0.
|
||||||
|
You can manually download the latest version that supports PHP 8 and above from [jpgraph.net](https://jpgraph.net/))
|
||||||
|
- [mitoteam/jpgraph](https://packagist.org/packages/mitoteam/jpgraph) (fork with php 8.1 support)
|
||||||
|
|
||||||
|
and then configure PhpSpreadsheet using:
|
||||||
|
```php
|
||||||
|
Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph::class); // to use jpgraph/jpgraph
|
||||||
|
//or
|
||||||
|
Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\MtJpGraphRenderer::class); // to use mitoteam/jpgraph
|
||||||
|
```
|
||||||
|
|
||||||
|
One or the other of these libraries is necessary if you want to generate HTML or PDF files that include charts.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Read more about it, including install instructions, in the [official documentation](https://phpspreadsheet.readthedocs.io). Or check out the [API documentation](https://phpoffice.github.io/PhpSpreadsheet).
|
Read more about it, including install instructions, in the [official documentation](https://phpspreadsheet.readthedocs.io). Or check out the [API documentation](https://phpoffice.github.io/PhpSpreadsheet).
|
||||||
|
|
|
||||||
|
|
@ -69,32 +69,33 @@
|
||||||
"ext-xmlwriter": "*",
|
"ext-xmlwriter": "*",
|
||||||
"ext-zip": "*",
|
"ext-zip": "*",
|
||||||
"ext-zlib": "*",
|
"ext-zlib": "*",
|
||||||
"ezyang/htmlpurifier": "^4.13",
|
"ezyang/htmlpurifier": "^4.15",
|
||||||
"maennchen/zipstream-php": "^2.1",
|
"maennchen/zipstream-php": "^2.1",
|
||||||
"markbaker/complex": "^3.0",
|
"markbaker/complex": "^3.0",
|
||||||
"markbaker/matrix": "^3.0",
|
"markbaker/matrix": "^3.0",
|
||||||
"psr/http-client": "^1.0",
|
"psr/http-client": "^1.0",
|
||||||
"psr/http-factory": "^1.0",
|
"psr/http-factory": "^1.0",
|
||||||
"psr/simple-cache": "^1.0 || ^2.0"
|
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
|
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
|
||||||
"dompdf/dompdf": "^1.0",
|
"dompdf/dompdf": "^1.0 || ^2.0",
|
||||||
"friendsofphp/php-cs-fixer": "^3.2",
|
"friendsofphp/php-cs-fixer": "^3.2",
|
||||||
"jpgraph/jpgraph": "^4.0",
|
"mitoteam/jpgraph": "^10.2.4",
|
||||||
"mpdf/mpdf": "8.1.1",
|
"mpdf/mpdf": "^8.1.1",
|
||||||
"phpcompatibility/php-compatibility": "^9.3",
|
"phpcompatibility/php-compatibility": "^9.3",
|
||||||
"phpstan/phpstan": "^1.1",
|
"phpstan/phpstan": "^1.1",
|
||||||
"phpstan/phpstan-phpunit": "^1.0",
|
"phpstan/phpstan-phpunit": "^1.0",
|
||||||
"phpunit/phpunit": "^8.5 || ^9.0",
|
"phpunit/phpunit": "^8.5 || ^9.0",
|
||||||
"squizlabs/php_codesniffer": "^3.6",
|
"squizlabs/php_codesniffer": "^3.7",
|
||||||
"tecnickcom/tcpdf": "^6.4"
|
"tecnickcom/tcpdf": "^6.5"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
|
"ext-intl": "PHP Internationalization Functions",
|
||||||
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
|
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
|
||||||
"dompdf/dompdf": "Option for rendering PDF with PDF Writer (doesn't yet support PHP8)",
|
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
|
||||||
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer (doesn't yet support PHP8)",
|
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer",
|
||||||
"jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers"
|
"mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -53,7 +53,7 @@ composer require phpoffice/phpspreadsheet --prefer-source
|
||||||
```
|
```
|
||||||
|
|
||||||
If you are building your installation on a development machine that is on a different PHP version to the server where it will be deployed, or if your PHP CLI version is not the same as your run-time such as `php-fpm` or Apache's `mod_php`, then you might want to add the following to your `composer.json` before installing:
|
If you are building your installation on a development machine that is on a different PHP version to the server where it will be deployed, or if your PHP CLI version is not the same as your run-time such as `php-fpm` or Apache's `mod_php`, then you might want to add the following to your `composer.json` before installing:
|
||||||
```json lines
|
```json
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"phpoffice/phpspreadsheet": "^1.23"
|
"phpoffice/phpspreadsheet": "^1.23"
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,13 @@ with PhpSpreadsheet, it evaluates to the value "64":
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
When writing a formula to a cell, formulae should always be set as they would appear in an English version of Microsoft Office Excel, and PhpSpreadsheet handles all formulae internally in this format. This means that the following rules hold:
|
||||||
|
|
||||||
|
- Decimal separator is `.` (period)
|
||||||
|
- Function argument separator is `,` (comma)
|
||||||
|
- Matrix row separator is `;` (semicolon)
|
||||||
|
- English function names must be used
|
||||||
|
|
||||||
Another nice feature of PhpSpreadsheet's formula parser, is that it can
|
Another nice feature of PhpSpreadsheet's formula parser, is that it can
|
||||||
automatically adjust a formula when inserting/removing rows/columns.
|
automatically adjust a formula when inserting/removing rows/columns.
|
||||||
Here's an example:
|
Here's an example:
|
||||||
|
|
@ -43,6 +50,11 @@ inserted 2 new rows), changed to "SUM(E4:E11)". Also, the inserted cells
|
||||||
duplicate style information of the previous cell, just like Excel's
|
duplicate style information of the previous cell, just like Excel's
|
||||||
behaviour. Note that you can both insert rows and columns.
|
behaviour. Note that you can both insert rows and columns.
|
||||||
|
|
||||||
|
If you want to "anchor" a specific cell for a formula, then you prefix the column and/or the row with a `$` symbol, exactly as you would in MS Excel itself.
|
||||||
|
So if a formula contains "SUM(E$4:E9)", and you insert 2 new rows after row 1, the formula will be adjusted to read "SUM(E$4:E11)", with the `$` fixing row 4 as the start of the range.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Calculation Cache
|
## Calculation Cache
|
||||||
|
|
||||||
Once the Calculation engine has evaluated the formula in a cell, the result
|
Once the Calculation engine has evaluated the formula in a cell, the result
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
|
|
@ -282,6 +282,7 @@ versions of Microsoft Excel.
|
||||||
**Excel 2003 XML limitations** Please note that Excel 2003 XML format
|
**Excel 2003 XML limitations** Please note that Excel 2003 XML format
|
||||||
has some limits regarding to styling cells and handling large
|
has some limits regarding to styling cells and handling large
|
||||||
spreadsheets via PHP.
|
spreadsheets via PHP.
|
||||||
|
Also, only files using charset UTF-8 are supported.
|
||||||
|
|
||||||
### \PhpOffice\PhpSpreadsheet\Reader\Xml
|
### \PhpOffice\PhpSpreadsheet\Reader\Xml
|
||||||
|
|
||||||
|
|
@ -701,6 +702,7 @@ extension.
|
||||||
|
|
||||||
**HTML limitations** Please note that HTML file format has some limits
|
**HTML limitations** Please note that HTML file format has some limits
|
||||||
regarding to styling cells, number formatting, ...
|
regarding to styling cells, number formatting, ...
|
||||||
|
Also, only files using charset UTF-8 are supported.
|
||||||
|
|
||||||
### \PhpOffice\PhpSpreadsheet\Reader\Html
|
### \PhpOffice\PhpSpreadsheet\Reader\Html
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1161,7 +1161,7 @@ A column's width can be set using the following code:
|
||||||
$spreadsheet->getActiveSheet()->getColumnDimension('D')->setWidth(12);
|
$spreadsheet->getActiveSheet()->getColumnDimension('D')->setWidth(12);
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want to set a column width using a different unit of measure,
|
If you want to set a column width using a different UoM (Unit of Measure),
|
||||||
then you can do so by telling PhpSpreadsheet what UoM the width value
|
then you can do so by telling PhpSpreadsheet what UoM the width value
|
||||||
that you are setting is measured in.
|
that you are setting is measured in.
|
||||||
Valid units are `pt` (points), `px` (pixels), `pc` (pica), `in` (inches),
|
Valid units are `pt` (points), `px` (pixels), `pc` (pica), `in` (inches),
|
||||||
|
|
@ -1258,7 +1258,7 @@ Excel measures row height in points, where 1 pt is 1/72 of an inch (or
|
||||||
about 0.35mm). The default value is 12.75 pts; and the permitted range
|
about 0.35mm). The default value is 12.75 pts; and the permitted range
|
||||||
of values is between 0 and 409 pts, where 0 pts is a hidden row.
|
of values is between 0 and 409 pts, where 0 pts is a hidden row.
|
||||||
|
|
||||||
If you want to set a row height using a different unit of measure,
|
If you want to set a row height using a different UoM (Unit of Measure),
|
||||||
then you can do so by telling PhpSpreadsheet what UoM the height value
|
then you can do so by telling PhpSpreadsheet what UoM the height value
|
||||||
that you are setting is measured in.
|
that you are setting is measured in.
|
||||||
Valid units are `pt` (points), `px` (pixels), `pc` (pica), `in` (inches),
|
Valid units are `pt` (points), `px` (pixels), `pc` (pica), `in` (inches),
|
||||||
|
|
@ -1332,23 +1332,73 @@ rows (default), or above. The following code adds the summary above:
|
||||||
$spreadsheet->getActiveSheet()->setShowSummaryBelow(false);
|
$spreadsheet->getActiveSheet()->setShowSummaryBelow(false);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Merge/unmerge cells
|
## Merge/Unmerge cells
|
||||||
|
|
||||||
If you have a big piece of data you want to display in a worksheet, you
|
If you have a big piece of data you want to display in a worksheet, or a
|
||||||
can merge two or more cells together, to become one cell. This can be
|
heading that needs to span multiple sub-heading columns, you can merge
|
||||||
done using the following code:
|
two or more cells together, to become one cell. This can be done using
|
||||||
|
the following code:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$spreadsheet->getActiveSheet()->mergeCells('A18:E22');
|
$spreadsheet->getActiveSheet()->mergeCells('A18:E22');
|
||||||
```
|
```
|
||||||
|
|
||||||
Removing a merge can be done using the unmergeCells method:
|
Removing a merge can be done using the `unmergeCells()` method:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$spreadsheet->getActiveSheet()->unmergeCells('A18:E22');
|
$spreadsheet->getActiveSheet()->unmergeCells('A18:E22');
|
||||||
```
|
```
|
||||||
|
|
||||||
## Inserting rows/columns
|
MS Excel itself doesn't yet offer the functionality to simply hide the merged cells, or to merge the content of cells into a single cell, but it is available in Open/Libre Office.
|
||||||
|
|
||||||
|
### Merge with MERGE_CELL_CONTENT_EMPTY
|
||||||
|
|
||||||
|
The default behaviour is to empty all cells except for the top-left corner cell in the merge range; and this is also the default behaviour for the `mergeCells()` method in PhpSpreadsheet.
|
||||||
|
When this behaviour is applied, those cell values will be set to null; and if they are subsequently Unmerged, they will be empty cells.
|
||||||
|
|
||||||
|
Passing an extra flag value to the `mergeCells()` method in PhpSpreadsheet can change this behaviour.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Possible flag values are:
|
||||||
|
- Worksheet::MERGE_CELL_CONTENT_EMPTY (the default)
|
||||||
|
- Worksheet::MERGE_CELL_CONTENT_HIDE
|
||||||
|
- Worksheet::MERGE_CELL_CONTENT_MERGE
|
||||||
|
|
||||||
|
### Merge with MERGE_CELL_CONTENT_HIDE
|
||||||
|
|
||||||
|
The first alternative, available only in OpenOffice, is to hide those cells, but to leave their content intact.
|
||||||
|
When a file saved as `Xlsx` in those applications is opened in MS Excel, and those cells are unmerged, the original content will still be present.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$spreadsheet->getActiveSheet()->mergeCells('A1:C3', Worksheet::MERGE_CELL_CONTENT_HIDE);
|
||||||
|
```
|
||||||
|
|
||||||
|
Will replicate that behaviour.
|
||||||
|
|
||||||
|
### Merge with MERGE_CELL_CONTENT_MERGE
|
||||||
|
|
||||||
|
The second alternative, available in both OpenOffice and LibreOffice is to merge the content of every cell in the merge range into the top-left cell, while setting those hidden cells to empty.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$spreadsheet->getActiveSheet()->mergeCells('A1:C3', Worksheet::MERGE_CELL_CONTENT_MERGE);
|
||||||
|
```
|
||||||
|
|
||||||
|
Particularly when the merged cells contain formulae, the logic for this merge seems strange:
|
||||||
|
walking through the merge range, each cell is calculated in turn, and appended to the "master" cell, then it is emptied, so any subsequent calculations that reference the cell see an empty cell, not the pre-merge value.
|
||||||
|
For example, suppose our spreadsheet contains
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
where `B2` is the formula `=5-B1` and `C2` is the formula `=A2/B2`,
|
||||||
|
and we want to merge cells `A2` to `C2` with all the cell values merged.
|
||||||
|
The result is:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The cell value `12` from cell `A2` is fixed; the value from `B2` is the result of the formula `=5-B1` (`4`, which is appended to our merged value), and cell `B2` is then emptied, so when we evaluate cell `C2` with the formula `=A2/B2` it gives us `12 / 0` which results in a `#DIV/0!` error (so the error `#DIV/0!` is appended to our merged value rather than the original calculation result of `3`).
|
||||||
|
|
||||||
|
## Inserting or Removing rows/columns
|
||||||
|
|
||||||
You can insert/remove rows/columns at a specific position. The following
|
You can insert/remove rows/columns at a specific position. The following
|
||||||
code inserts 2 new rows, right before row 7:
|
code inserts 2 new rows, right before row 7:
|
||||||
|
|
@ -1356,6 +1406,23 @@ code inserts 2 new rows, right before row 7:
|
||||||
```php
|
```php
|
||||||
$spreadsheet->getActiveSheet()->insertNewRowBefore(7, 2);
|
$spreadsheet->getActiveSheet()->insertNewRowBefore(7, 2);
|
||||||
```
|
```
|
||||||
|
while
|
||||||
|
```php
|
||||||
|
$spreadsheet->getActiveSheet()->removeRow(7, 2);
|
||||||
|
```
|
||||||
|
will remove 2 rows starting at row number 7 (ie. rows 7 and 8).
|
||||||
|
|
||||||
|
Equivalent methods exist for inserting/removing columns:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$spreadsheet->getActiveSheet()->removeColumn('C', 2);
|
||||||
|
```
|
||||||
|
|
||||||
|
All subsequent rows (or columns) will be moved to allow the insertion (or removal) with all formulae referencing thise cells adjusted accordingly.
|
||||||
|
|
||||||
|
Note that this is a fairly intensive process, particularly with large worksheets, and especially if you are inserting/removing rows/columns from near beginning of the worksheet.
|
||||||
|
|
||||||
|
If you need to insert/remove several consecutive rows/columns, always use the second argument rather than making multiple calls to insert/remove a single row/column if possible.
|
||||||
|
|
||||||
## Add a drawing to a worksheet
|
## Add a drawing to a worksheet
|
||||||
|
|
||||||
|
|
@ -1653,7 +1720,7 @@ $spreadsheet->getActiveSheet()->getDefaultColumnDimension()->setWidth(12);
|
||||||
Excel measures column width in its own proprietary units, based on the number
|
Excel measures column width in its own proprietary units, based on the number
|
||||||
of characters that will be displayed in the default font.
|
of characters that will be displayed in the default font.
|
||||||
|
|
||||||
If you want to set the default column width using a different unit of measure,
|
If you want to set the default column width using a different UoM (Unit of Measure),
|
||||||
then you can do so by telling PhpSpreadsheet what UoM the width value
|
then you can do so by telling PhpSpreadsheet what UoM the width value
|
||||||
that you are setting is measured in.
|
that you are setting is measured in.
|
||||||
Valid units are `pt` (points), `px` (pixels), `pc` (pica), `in` (inches),
|
Valid units are `pt` (points), `px` (pixels), `pc` (pica), `in` (inches),
|
||||||
|
|
@ -1676,7 +1743,7 @@ Excel measures row height in points, where 1 pt is 1/72 of an inch (or
|
||||||
about 0.35mm). The default value is 12.75 pts; and the permitted range
|
about 0.35mm). The default value is 12.75 pts; and the permitted range
|
||||||
of values is between 0 and 409 pts, where 0 pts is a hidden row.
|
of values is between 0 and 409 pts, where 0 pts is a hidden row.
|
||||||
|
|
||||||
If you want to set a row height using a different unit of measure,
|
If you want to set a row height using a different UoM (Unit of Measure),
|
||||||
then you can do so by telling PhpSpreadsheet what UoM the height value
|
then you can do so by telling PhpSpreadsheet what UoM the height value
|
||||||
that you are setting is measured in.
|
that you are setting is measured in.
|
||||||
Valid units are `pt` (points), `px` (pixels), `pc` (pica), `in` (inches),
|
Valid units are `pt` (points), `px` (pixels), `pc` (pica), `in` (inches),
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class DocumentGenerator
|
||||||
private static function tableRow(array $lengths, ?array $values = null): string
|
private static function tableRow(array $lengths, ?array $values = null): string
|
||||||
{
|
{
|
||||||
$result = '';
|
$result = '';
|
||||||
foreach (array_map(null, $lengths, $values ?? []) as $i => [$length, $value]) {
|
foreach (array_map(/** @scrutinizer ignore-type */ null, $lengths, $values ?? []) as $i => [$length, $value]) {
|
||||||
$pad = $value === null ? '-' : ' ';
|
$pad = $value === null ? '-' : ' ';
|
||||||
if ($i > 0) {
|
if ($i > 0) {
|
||||||
$result .= '|' . $pad;
|
$result .= '|' . $pad;
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ class LocaleGenerator
|
||||||
$translationValue = $translationCell->getValue();
|
$translationValue = $translationCell->getValue();
|
||||||
if ($this->isFunctionCategoryEntry($translationCell)) {
|
if ($this->isFunctionCategoryEntry($translationCell)) {
|
||||||
$this->writeFileSectionHeader($functionFile, "{$translationValue} ({$functionName})");
|
$this->writeFileSectionHeader($functionFile, "{$translationValue} ({$functionName})");
|
||||||
} elseif (!array_key_exists($functionName, $this->phpSpreadsheetFunctions)) {
|
} elseif (!array_key_exists($functionName, $this->phpSpreadsheetFunctions) && substr($functionName, 0, 1) !== '*') {
|
||||||
$this->log("Function {$functionName} is not defined in PhpSpreadsheet");
|
$this->log("Function {$functionName} is not defined in PhpSpreadsheet");
|
||||||
} elseif (!empty($translationValue)) {
|
} elseif (!empty($translationValue)) {
|
||||||
$functionTranslation = "{$functionName} = {$translationValue}" . self::EOL;
|
$functionTranslation = "{$functionName} = {$translationValue}" . self::EOL;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -9,23 +9,15 @@ parameters:
|
||||||
paths:
|
paths:
|
||||||
- src/
|
- src/
|
||||||
- tests/
|
- tests/
|
||||||
|
excludePaths:
|
||||||
|
- src/PhpSpreadsheet/Chart/Renderer/JpGraph.php
|
||||||
|
- src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php
|
||||||
parallel:
|
parallel:
|
||||||
processTimeout: 300.0
|
processTimeout: 300.0
|
||||||
checkMissingIterableValueType: false
|
checkMissingIterableValueType: false
|
||||||
ignoreErrors:
|
ignoreErrors:
|
||||||
- '~^Parameter \#1 \$im(age)? of function (imagedestroy|imageistruecolor|imagealphablending|imagesavealpha|imagecolortransparent|imagecolorsforindex|imagesavealpha|imagesx|imagesy) expects (GdImage|resource), GdImage\|resource given\.$~'
|
- '~^Parameter \#1 \$im(age)? of function (imagedestroy|imageistruecolor|imagealphablending|imagesavealpha|imagecolortransparent|imagecolorsforindex|imagesavealpha|imagesx|imagesy|imagepng) expects (GdImage|resource), GdImage\|resource given\.$~'
|
||||||
- '~^Parameter \#2 \$src_im(age)? of function imagecopy expects (GdImage|resource), GdImage\|resource given\.$~'
|
- '~^Parameter \#2 \$src_im(age)? of function imagecopy expects (GdImage|resource), GdImage\|resource given\.$~'
|
||||||
# Accept a bit anything for assert methods
|
# Accept a bit anything for assert methods
|
||||||
- '~^Parameter \#2 .* of static method PHPUnit\\Framework\\Assert\:\:assert\w+\(\) expects .*, .* given\.$~'
|
- '~^Parameter \#2 .* of static method PHPUnit\\Framework\\Assert\:\:assert\w+\(\) expects .*, .* given\.$~'
|
||||||
- '~^Method PhpOffice\\PhpSpreadsheetTests\\.*\:\:test.*\(\) has parameter \$args with no type specified\.$~'
|
- '~^Method PhpOffice\\PhpSpreadsheetTests\\.*\:\:test.*\(\) has parameter \$args with no type specified\.$~'
|
||||||
|
|
||||||
# Ignore all JpGraph issues
|
|
||||||
- '~^Constant (MARK_CIRCLE|MARK_CROSS|MARK_DIAMOND|MARK_DTRIANGLE|MARK_FILLEDCIRCLE|MARK_SQUARE|MARK_STAR|MARK_UTRIANGLE|MARK_X|SIDE_RIGHT) not found\.$~'
|
|
||||||
- '~^Instantiated class (AccBarPlot|AccLinePlot|BarPlot|ContourPlot|Graph|GroupBarPlot|GroupBarPlot|LinePlot|LinePlot|PieGraph|PiePlot|PiePlot3D|PiePlotC|RadarGraph|RadarPlot|ScatterPlot|Spline|StockPlot) not found\.$~'
|
|
||||||
- '~^Call to method .*\(\) on an unknown class (AccBarPlot|AccLinePlot|BarPlot|ContourPlot|Graph|GroupBarPlot|GroupBarPlot|LinePlot|LinePlot|PieGraph|PiePlot|PiePlot3D|PiePlotC|RadarGraph|RadarPlot|ScatterPlot|Spline|StockPlot)\.$~'
|
|
||||||
- '~^Access to property .* on an unknown class (AccBarPlot|AccLinePlot|BarPlot|ContourPlot|Graph|GroupBarPlot|GroupBarPlot|LinePlot|LinePlot|PieGraph|PiePlot|PiePlot3D|PiePlotC|RadarGraph|RadarPlot|ScatterPlot|Spline|StockPlot)\.$~'
|
|
||||||
|
|
||||||
# Some issues in Xls/Parser between 1.6.3 and 1.7.7
|
|
||||||
-
|
|
||||||
message: "#^Offset '(left|right|value)' does not exist on (non-empty-array\\|string|array\\|null)\\.$#"
|
|
||||||
path: src/PhpSpreadsheet/Writer/Xls/Parser.php
|
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,10 @@ $spreadsheet = $reader->load(__DIR__ . '/../templates/26template.xlsx');
|
||||||
// at this point, we could do some manipulations with the template, but we skip this step
|
// at this point, we could do some manipulations with the template, but we skip this step
|
||||||
$helper->write($spreadsheet, __FILE__, ['Xlsx', 'Xls', 'Html']);
|
$helper->write($spreadsheet, __FILE__, ['Xlsx', 'Xls', 'Html']);
|
||||||
|
|
||||||
if (\PHP_VERSION_ID < 80000) {
|
|
||||||
// Export to PDF (.pdf)
|
// Export to PDF (.pdf)
|
||||||
$helper->log('Write to PDF format');
|
$helper->log('Write to PDF format');
|
||||||
IOFactory::registerWriter('Pdf', \PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf::class);
|
IOFactory::registerWriter('Pdf', \PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf::class);
|
||||||
$helper->write($spreadsheet, __FILE__, ['Pdf']);
|
$helper->write($spreadsheet, __FILE__, ['Pdf']);
|
||||||
}
|
|
||||||
|
|
||||||
// Remove first two rows with field headers before exporting to CSV
|
// Remove first two rows with field headers before exporting to CSV
|
||||||
$helper->log('Removing first two heading rows for CSV export');
|
$helper->log('Removing first two heading rows for CSV export');
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||||
|
|
||||||
|
require __DIR__ . '/../Header.php';
|
||||||
|
|
||||||
|
$helper->log('Create new Spreadsheet object');
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$spreadsheet->getProperties()->setTitle('Alignment');
|
||||||
|
$sheet = $spreadsheet->getActiveSheet();
|
||||||
|
$hi = 'Hi There';
|
||||||
|
$ju = 'This is a longer than normal sentence';
|
||||||
|
$sheet->fromArray([
|
||||||
|
['', 'default', 'bottom', 'top', 'center', 'justify', 'distributed'],
|
||||||
|
['default', $hi, $hi, $hi, $hi, $hi, $hi],
|
||||||
|
['left', $hi, $hi, $hi, $hi, $hi, $hi],
|
||||||
|
['right', $hi, $hi, $hi, $hi, $hi, $hi],
|
||||||
|
['center', $hi, $hi, $hi, $hi, $hi, $hi],
|
||||||
|
['justify', $ju, $ju, $ju, $ju, $ju, $ju],
|
||||||
|
['distributed', $ju, $ju, $ju, $ju, $ju, $ju],
|
||||||
|
]);
|
||||||
|
$sheet->getColumnDimension('B')->setWidth(20);
|
||||||
|
$sheet->getColumnDimension('C')->setWidth(20);
|
||||||
|
$sheet->getColumnDimension('D')->setWidth(20);
|
||||||
|
$sheet->getColumnDimension('E')->setWidth(20);
|
||||||
|
$sheet->getColumnDimension('F')->setWidth(20);
|
||||||
|
$sheet->getColumnDimension('G')->setWidth(20);
|
||||||
|
$sheet->getRowDimension(2)->setRowHeight(30);
|
||||||
|
$sheet->getRowDimension(3)->setRowHeight(30);
|
||||||
|
$sheet->getRowDimension(4)->setRowHeight(30);
|
||||||
|
$sheet->getRowDimension(5)->setRowHeight(30);
|
||||||
|
$sheet->getRowDimension(6)->setRowHeight(40);
|
||||||
|
$sheet->getRowDimension(7)->setRowHeight(40);
|
||||||
|
$minRow = 2;
|
||||||
|
$maxRow = 7;
|
||||||
|
$minCol = 'B';
|
||||||
|
$maxCol = 'g';
|
||||||
|
$sheet->getStyle("C$minRow:C$maxRow")
|
||||||
|
->getAlignment()
|
||||||
|
->setVertical(Alignment::VERTICAL_BOTTOM);
|
||||||
|
$sheet->getStyle("D$minRow:D$maxRow")
|
||||||
|
->getAlignment()
|
||||||
|
->setVertical(Alignment::VERTICAL_TOP);
|
||||||
|
$sheet->getStyle("E$minRow:E$maxRow")
|
||||||
|
->getAlignment()
|
||||||
|
->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
$sheet->getStyle("F$minRow:F$maxRow")
|
||||||
|
->getAlignment()
|
||||||
|
->setVertical(Alignment::VERTICAL_JUSTIFY);
|
||||||
|
$sheet->getStyle("G$minRow:G$maxRow")
|
||||||
|
->getAlignment()
|
||||||
|
->setVertical(Alignment::VERTICAL_DISTRIBUTED);
|
||||||
|
$sheet->getStyle("{$minCol}3:{$maxCol}3")
|
||||||
|
->getAlignment()
|
||||||
|
->setHorizontal(Alignment::HORIZONTAL_LEFT);
|
||||||
|
$sheet->getStyle("{$minCol}4:{$maxCol}4")
|
||||||
|
->getAlignment()
|
||||||
|
->setHorizontal(Alignment::HORIZONTAL_RIGHT);
|
||||||
|
$sheet->getStyle("{$minCol}5:{$maxCol}5")
|
||||||
|
->getAlignment()
|
||||||
|
->setHorizontal(Alignment::HORIZONTAL_CENTER);
|
||||||
|
$sheet->getStyle("{$minCol}6:{$maxCol}6")
|
||||||
|
->getAlignment()
|
||||||
|
->setHorizontal(Alignment::HORIZONTAL_JUSTIFY);
|
||||||
|
$sheet->getStyle("{$minCol}7:{$maxCol}7")
|
||||||
|
->getAlignment()
|
||||||
|
->setHorizontal(Alignment::HORIZONTAL_DISTRIBUTED);
|
||||||
|
|
||||||
|
$sheet->getCell('A9')->setValue('Center Continuous A9-C9');
|
||||||
|
$sheet->getStyle('A9:C9')
|
||||||
|
->getAlignment()
|
||||||
|
->setHorizontal(Alignment::HORIZONTAL_CENTER_CONTINUOUS);
|
||||||
|
$sheet->getCell('A10')->setValue('Fill');
|
||||||
|
$sheet->getStyle('A10')
|
||||||
|
->getAlignment()
|
||||||
|
->setHorizontal(Alignment::HORIZONTAL_FILL);
|
||||||
|
$sheet->setSelectedCells('A1');
|
||||||
|
|
||||||
|
$helper->write($spreadsheet, __FILE__, ['Xlsx', 'Html', 'Xls']);
|
||||||
|
|
@ -4,7 +4,11 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
require __DIR__ . '/../../Header.php';
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
$helper->log('Returns the average of selected database entries.');
|
$category = 'Database';
|
||||||
|
$functionName = 'DAVERAGE';
|
||||||
|
$description = 'Returns the average of selected database entries that match criteria';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Create new PhpSpreadsheet object
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
|
|
@ -36,21 +40,19 @@ $worksheet->setCellValue('B13', '=DAVERAGE(A4:E10,3,A1:A3)');
|
||||||
$helper->log('Database');
|
$helper->log('Database');
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
var_dump($databaseData);
|
$helper->displayGrid($databaseData);
|
||||||
|
|
||||||
// Test the formulae
|
// Test the formulae
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:B2', null, true, true, true);
|
$criteriaData = $worksheet->rangeToArray('A1:B2', null, true, true, true);
|
||||||
var_dump($criteriaData);
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A12')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B12', 'A12');
|
||||||
$helper->log('DAVERAGE() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
|
|
||||||
|
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
var_dump($criteriaData);
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A13')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B13', 'A13');
|
||||||
$helper->log('DAVERAGE() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,12 @@
|
||||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
require __DIR__ . '/../../Header.php';
|
require __DIR__ . '/../../Header.php';
|
||||||
$helper->log('Counts the cells that contain numbers in a database.');
|
|
||||||
|
$category = 'Database';
|
||||||
|
$functionName = 'DCOUNT';
|
||||||
|
$description = 'Counts the cells that contain numbers in a set of database records that match criteria';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Create new PhpSpreadsheet object
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
|
|
@ -14,9 +19,9 @@ $database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
||||||
['Apple', 18, 20, 14, 105.00],
|
['Apple', 18, 20, 14, 105.00],
|
||||||
['Pear', 12, 12, 10, 96.00],
|
['Pear', 12, 12, 10, 96.00],
|
||||||
['Cherry', 13, 14, 9, 105.00],
|
['Cherry', 13, 14, 9, 105.00],
|
||||||
['Apple', 14, 15, 10, 75.00],
|
['Apple', 14, 'N/A', 10, 75.00],
|
||||||
['Pear', 9, 8, 8, 76.80],
|
['Pear', 9, 8, 8, 77.00],
|
||||||
['Apple', 8, 9, 6, 45.00],
|
['Apple', 12, 11, 6, 45.00],
|
||||||
];
|
];
|
||||||
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
||||||
['="=Apple"', '>10', null, null, null, '<16'],
|
['="=Apple"', '>10', null, null, null, '<16'],
|
||||||
|
|
@ -26,30 +31,28 @@ $criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
||||||
$worksheet->fromArray($criteria, null, 'A1');
|
$worksheet->fromArray($criteria, null, 'A1');
|
||||||
$worksheet->fromArray($database, null, 'A4');
|
$worksheet->fromArray($database, null, 'A4');
|
||||||
|
|
||||||
$worksheet->setCellValue('A12', 'The Number of Apple trees over 10\' in height');
|
$worksheet->setCellValue('A12', 'The Number of Apple trees between 10\' and 16\' in height whose age is known');
|
||||||
$worksheet->setCellValue('B12', '=DCOUNT(A4:E10,"Yield",A1:B2)');
|
$worksheet->setCellValue('B12', '=DCOUNT(A4:E10,"Age",A1:F2)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A13', 'The Number of Apple and Pear trees in the orchard');
|
$worksheet->setCellValue('A13', 'The Number of Apple and Pear trees in the orchard with a numeric value in column 3 ("Age")');
|
||||||
$worksheet->setCellValue('B13', '=DCOUNT(A4:E10,3,A1:A3)');
|
$worksheet->setCellValue('B13', '=DCOUNT(A4:E10,3,A1:A3)');
|
||||||
|
|
||||||
$helper->log('Database');
|
$helper->log('Database');
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
var_dump($databaseData);
|
$helper->displayGrid($databaseData);
|
||||||
|
|
||||||
// Test the formulae
|
// Test the formulae
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:B2', null, true, true, true);
|
$criteriaData = $worksheet->rangeToArray('A1:F2', null, true, true, true);
|
||||||
var_dump($criteriaData);
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A12')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B12', 'A12');
|
||||||
$helper->log('DCOUNT() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
|
|
||||||
|
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
var_dump($criteriaData);
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A13')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B13', 'A13');
|
||||||
$helper->log('DCOUNT() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Database';
|
||||||
|
$functionName = 'DCOUNTA';
|
||||||
|
$description = 'Counts the cells in a set of database records that match criteria';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
||||||
|
['Apple', 18, 20, 14, 105.00],
|
||||||
|
['Pear', 12, 12, 10, 96.00],
|
||||||
|
['Cherry', 13, 14, 9, 105.00],
|
||||||
|
['Apple', 14, 'N/A', 10, 75.00],
|
||||||
|
['Pear', 9, 8, 8, 77.00],
|
||||||
|
['Apple', 12, 11, 6, 45.00],
|
||||||
|
];
|
||||||
|
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
||||||
|
['="=Apple"', '>10', null, null, null, '<16'],
|
||||||
|
['="=Pear"', null, null, null, null, null],
|
||||||
|
];
|
||||||
|
|
||||||
|
$worksheet->fromArray($criteria, null, 'A1');
|
||||||
|
$worksheet->fromArray($database, null, 'A4');
|
||||||
|
|
||||||
|
$worksheet->setCellValue('A12', 'The Number of Apple trees between 10\' and 16\' in height');
|
||||||
|
$worksheet->setCellValue('B12', '=DCOUNTA(A4:E10,"Age",A1:F2)');
|
||||||
|
|
||||||
|
$worksheet->setCellValue('A13', 'The Number of Apple and Pear trees in the orchard');
|
||||||
|
$worksheet->setCellValue('B13', '=DCOUNTA(A4:E10,3,A1:A3)');
|
||||||
|
|
||||||
|
$helper->log('Database');
|
||||||
|
|
||||||
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
|
$helper->displayGrid($databaseData);
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
$helper->log('Criteria');
|
||||||
|
|
||||||
|
$criteriaData = $worksheet->rangeToArray('A1:F2', null, true, true, true);
|
||||||
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
|
$helper->logCalculationResult($worksheet, $functionName, 'B12', 'A12');
|
||||||
|
|
||||||
|
$helper->log('Criteria');
|
||||||
|
|
||||||
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
|
$helper->logCalculationResult($worksheet, $functionName, 'B13', 'A13');
|
||||||
|
|
@ -4,7 +4,11 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
require __DIR__ . '/../../Header.php';
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
$helper->log('Extracts a single value from a column of a list or database that matches conditions that you specify.');
|
$category = 'Database';
|
||||||
|
$functionName = 'DGET';
|
||||||
|
$description = 'Extracts a single value from a column of a list or database that matches criteria that you specify';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Create new PhpSpreadsheet object
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
|
|
@ -21,7 +25,7 @@ $database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
||||||
];
|
];
|
||||||
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
||||||
['="=Apple"', '>10', null, null, null, '<16'],
|
['="=Apple"', '>10', null, null, null, '<16'],
|
||||||
['="=Pear"', null, null, null, null, null],
|
['="=Pear"', '>12', null, null, null, null],
|
||||||
];
|
];
|
||||||
|
|
||||||
$worksheet->fromArray($criteria, null, 'A1');
|
$worksheet->fromArray($criteria, null, 'A1');
|
||||||
|
|
@ -30,23 +34,25 @@ $worksheet->fromArray($database, null, 'A4');
|
||||||
$worksheet->setCellValue('A12', 'The height of the Apple tree between 10\' and 16\' tall');
|
$worksheet->setCellValue('A12', 'The height of the Apple tree between 10\' and 16\' tall');
|
||||||
$worksheet->setCellValue('B12', '=DGET(A4:E10,"Height",A1:F2)');
|
$worksheet->setCellValue('B12', '=DGET(A4:E10,"Height",A1:F2)');
|
||||||
|
|
||||||
|
$worksheet->setCellValue('A13', 'The height of the Apple tree (will return an Excel error, because there is more than one apple tree)');
|
||||||
|
$worksheet->setCellValue('B13', '=DGET(A4:E10,"Height",A1:A2)');
|
||||||
|
|
||||||
$helper->log('Database');
|
$helper->log('Database');
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
var_dump($databaseData);
|
$helper->displayGrid($databaseData);
|
||||||
|
|
||||||
// Test the formulae
|
// Test the formulae
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$helper->log('ALL');
|
$criteriaData = $worksheet->rangeToArray('A1:F2', null, true, true, true);
|
||||||
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A12')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B12', 'A12');
|
||||||
$helper->log('DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
|
|
||||||
|
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
||||||
var_dump($criteriaData);
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A13')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B13', 'A13');
|
||||||
$helper->log('DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,11 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
require __DIR__ . '/../../Header.php';
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
$helper->log('Returns the maximum value from selected database entries.');
|
$category = 'Database';
|
||||||
|
$functionName = 'DMAX';
|
||||||
|
$description = 'Returns the maximum value from selected database entries';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Create new PhpSpreadsheet object
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
|
|
@ -36,20 +40,18 @@ $worksheet->setCellValue('B13', '=DMAX(A4:E10,3,A1:A2)');
|
||||||
$helper->log('Database');
|
$helper->log('Database');
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
var_dump($databaseData);
|
$helper->displayGrid($databaseData);
|
||||||
|
|
||||||
// Test the formulae
|
// Test the formulae
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$helper->log('ALL');
|
$helper->log('ALL');
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A12')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B12', 'A12');
|
||||||
$helper->log('DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
|
|
||||||
|
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
||||||
var_dump($criteriaData);
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A13')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B13', 'A13');
|
||||||
$helper->log('DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,11 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
require __DIR__ . '/../../Header.php';
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
$helper->log('Returns the minimum value from selected database entries.');
|
$category = 'Database';
|
||||||
|
$functionName = 'DMIN';
|
||||||
|
$description = 'Returns the minimum value from selected database entries';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Create new PhpSpreadsheet object
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
|
|
@ -36,20 +40,18 @@ $worksheet->setCellValue('B13', '=DMIN(A4:E10,3,A1:A2)');
|
||||||
$helper->log('Database');
|
$helper->log('Database');
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
var_dump($databaseData);
|
$helper->displayGrid($databaseData);
|
||||||
|
|
||||||
// Test the formulae
|
// Test the formulae
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$helper->log('ALL');
|
$helper->log('ALL');
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A12')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B12', 'A12');
|
||||||
$helper->log('DMIN() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
|
|
||||||
|
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
||||||
var_dump($criteriaData);
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A13')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B13', 'A13');
|
||||||
$helper->log('DMIN() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,11 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
require __DIR__ . '/../../Header.php';
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
$helper->log('Multiplies the values in a column of a list or database that match conditions that you specify.');
|
$category = 'Database';
|
||||||
|
$functionName = 'DPRODUCT';
|
||||||
|
$description = 'Multiplies the values in a column of a list or database that match conditions that you specify';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Create new PhpSpreadsheet object
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
|
|
@ -16,7 +20,7 @@ $database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
||||||
['Pear', 12, 12, 10, 96.00],
|
['Pear', 12, 12, 10, 96.00],
|
||||||
['Cherry', 13, 14, 9, 105.00],
|
['Cherry', 13, 14, 9, 105.00],
|
||||||
['Apple', 14, 15, 10, 75.00],
|
['Apple', 14, 15, 10, 75.00],
|
||||||
['Pear', 9, 8, 8, 76.80],
|
['Pear', 9, 8, 8, 77.00],
|
||||||
['Apple', 8, 9, 6, 45.00],
|
['Apple', 8, 9, 6, 45.00],
|
||||||
];
|
];
|
||||||
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
||||||
|
|
@ -30,23 +34,25 @@ $worksheet->fromArray($database, null, 'A4');
|
||||||
$worksheet->setCellValue('A12', 'The product of the yields of all Apple trees over 10\' in the orchard');
|
$worksheet->setCellValue('A12', 'The product of the yields of all Apple trees over 10\' in the orchard');
|
||||||
$worksheet->setCellValue('B12', '=DPRODUCT(A4:E10,"Yield",A1:B2)');
|
$worksheet->setCellValue('B12', '=DPRODUCT(A4:E10,"Yield",A1:B2)');
|
||||||
|
|
||||||
|
$worksheet->setCellValue('A13', 'The product of the yields of all Apple trees in the orchard');
|
||||||
|
$worksheet->setCellValue('B13', '=DPRODUCT(A4:E10,"Yield",A1:A2)');
|
||||||
|
|
||||||
$helper->log('Database');
|
$helper->log('Database');
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
var_dump($databaseData);
|
$helper->displayGrid($databaseData);
|
||||||
|
|
||||||
// Test the formulae
|
// Test the formulae
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$helper->log('ALL');
|
$criteriaData = $worksheet->rangeToArray('A1:B2', null, true, true, true);
|
||||||
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A12')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B12', 'A12');
|
||||||
$helper->log('DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
|
|
||||||
|
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
||||||
var_dump($criteriaData);
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A13')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B13', 'A13');
|
||||||
$helper->log('DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,11 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
require __DIR__ . '/../../Header.php';
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
$helper->log('Estimates the standard deviation based on a sample of selected database entries.');
|
$category = 'Database';
|
||||||
|
$functionName = 'DSTDEV';
|
||||||
|
$description = 'Estimates the standard deviation based on a sample of selected database entries';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Create new PhpSpreadsheet object
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
|
|
@ -36,21 +40,19 @@ $worksheet->setCellValue('B13', '=DSTDEV(A4:E10,2,A1:A3)');
|
||||||
$helper->log('Database');
|
$helper->log('Database');
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
var_dump($databaseData);
|
$helper->displayGrid($databaseData);
|
||||||
|
|
||||||
// Test the formulae
|
// Test the formulae
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
var_dump($criteriaData);
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A12')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B12', 'A12');
|
||||||
$helper->log('DSTDEV() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
|
|
||||||
|
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
var_dump($criteriaData);
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A13')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B13', 'A13');
|
||||||
$helper->log('DSTDEV() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,12 @@
|
||||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
require __DIR__ . '/../../Header.php';
|
require __DIR__ . '/../../Header.php';
|
||||||
$helper->log('Calculates the standard deviation based on the entire population of selected database entries.');
|
|
||||||
|
$category = 'Database';
|
||||||
|
$functionName = 'DSTDEVP';
|
||||||
|
$description = 'Calculates the standard deviation based on the entire population of selected database entries';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Create new PhpSpreadsheet object
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
|
|
@ -35,21 +40,19 @@ $worksheet->setCellValue('B13', '=DSTDEVP(A4:E10,2,A1:A3)');
|
||||||
$helper->log('Database');
|
$helper->log('Database');
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
var_dump($databaseData);
|
$helper->displayGrid($databaseData);
|
||||||
|
|
||||||
// Test the formulae
|
// Test the formulae
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
var_dump($criteriaData);
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A12')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B12', 'A12');
|
||||||
$helper->log('DSTDEVP() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
|
|
||||||
|
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
var_dump($criteriaData);
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A13')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B13', 'A13');
|
||||||
$helper->log('DSTDEVP() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Database';
|
||||||
|
$functionName = 'DSUM';
|
||||||
|
$description = 'Returns the sum of selected database entries';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
||||||
|
['Apple', 18, 20, 14, 105.00],
|
||||||
|
['Pear', 12, 12, 10, 96.00],
|
||||||
|
['Cherry', 13, 14, 9, 105.00],
|
||||||
|
['Apple', 14, 15, 10, 75.00],
|
||||||
|
['Pear', 9, 8, 8, 76.80],
|
||||||
|
['Apple', 8, 9, 6, 45.00],
|
||||||
|
];
|
||||||
|
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
||||||
|
['="=Apple"', '>10', null, null, null, '<16'],
|
||||||
|
['="=Pear"', null, null, null, null, null],
|
||||||
|
];
|
||||||
|
|
||||||
|
$worksheet->fromArray($criteria, null, 'A1');
|
||||||
|
$worksheet->fromArray($database, null, 'A4');
|
||||||
|
|
||||||
|
$worksheet->setCellValue('A12', 'The total profit from apple trees');
|
||||||
|
$worksheet->setCellValue('B12', '=DSUM(A4:E10,"Profit",A1:A2)');
|
||||||
|
|
||||||
|
$worksheet->setCellValue('A13', 'Total profit from apple trees with a height between 10 and 16 feet, and all pear trees');
|
||||||
|
$worksheet->setCellValue('B13', '=DSUM(A4:E10,"Profit",A1:F3)');
|
||||||
|
|
||||||
|
$helper->log('Database');
|
||||||
|
|
||||||
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
|
$helper->displayGrid($databaseData);
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
$helper->log('Criteria');
|
||||||
|
|
||||||
|
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
||||||
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
|
$helper->logCalculationResult($worksheet, $functionName, 'B12', 'A12');
|
||||||
|
|
||||||
|
$helper->log('Criteria');
|
||||||
|
|
||||||
|
$criteriaData = $worksheet->rangeToArray('A1:F3', null, true, true, true);
|
||||||
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
|
$helper->logCalculationResult($worksheet, $functionName, 'B13', 'A13');
|
||||||
|
|
@ -3,7 +3,12 @@
|
||||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
require __DIR__ . '/../../Header.php';
|
require __DIR__ . '/../../Header.php';
|
||||||
$helper->log('Estimates variance based on a sample from selected database entries.');
|
|
||||||
|
$category = 'Database';
|
||||||
|
$functionName = 'DVAR';
|
||||||
|
$description = 'Estimates variance based on a sample from selected database entries';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Create new PhpSpreadsheet object
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
|
|
@ -35,21 +40,19 @@ $worksheet->setCellValue('B13', '=DVAR(A4:E10,2,A1:A3)');
|
||||||
$helper->log('Database');
|
$helper->log('Database');
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
var_dump($databaseData);
|
$helper->displayGrid($databaseData);
|
||||||
|
|
||||||
// Test the formulae
|
// Test the formulae
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
var_dump($criteriaData);
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A12')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B12', 'A12');
|
||||||
$helper->log('DVAR() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
|
|
||||||
|
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
var_dump($criteriaData);
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A13')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B13', 'A13');
|
||||||
$helper->log('DVAR() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,11 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
require __DIR__ . '/../../Header.php';
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
$helper->log('Calculates variance based on the entire population of selected database entries,');
|
$category = 'Database';
|
||||||
|
$functionName = 'DVARP';
|
||||||
|
$description = 'Calculates variance based on the entire population of selected database entries';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Create new PhpSpreadsheet object
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
|
|
@ -36,21 +40,19 @@ $worksheet->setCellValue('B13', '=DVARP(A4:E10,2,A1:A3)');
|
||||||
$helper->log('Database');
|
$helper->log('Database');
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
var_dump($databaseData);
|
$helper->displayGrid($databaseData);
|
||||||
|
|
||||||
// Test the formulae
|
// Test the formulae
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
var_dump($criteriaData);
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A12')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B12', 'A12');
|
||||||
$helper->log('DVARP() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
|
|
||||||
|
|
||||||
$helper->log('Criteria');
|
$helper->log('Criteria');
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
var_dump($criteriaData);
|
$helper->displayGrid($criteriaData);
|
||||||
|
|
||||||
$helper->log($worksheet->getCell('A13')->getValue());
|
$helper->logCalculationResult($worksheet, $functionName, 'B13', 'A13');
|
||||||
$helper->log('DVARP() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,11 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
require __DIR__ . '/../../Header.php';
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
$helper->log('Returns the serial number of a particular date.');
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'DATE';
|
||||||
|
$description = 'Returns the Excel serial number of a particular date';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Create new PhpSpreadsheet object
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
|
|
@ -27,15 +31,15 @@ for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
}
|
}
|
||||||
$worksheet->getStyle('E1:E' . $testDateCount)
|
$worksheet->getStyle('E1:E' . $testDateCount)
|
||||||
->getNumberFormat()
|
->getNumberFormat()
|
||||||
->setFormatCode('yyyy-mmm-dd');
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
// Test the formulae
|
// Test the formulae
|
||||||
for ($row = 1; $row <= $testDateCount; ++$row) {
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
$helper->log('Year: ' . $worksheet->getCell('A' . $row)->getFormattedValue());
|
$helper->log("(A{$row}) Year: " . $worksheet->getCell('A' . $row)->getFormattedValue());
|
||||||
$helper->log('Month: ' . $worksheet->getCell('B' . $row)->getFormattedValue());
|
$helper->log("(B{$row}) Month: " . $worksheet->getCell('B' . $row)->getFormattedValue());
|
||||||
$helper->log('Day: ' . $worksheet->getCell('C' . $row)->getFormattedValue());
|
$helper->log("(C{$row}) Day: " . $worksheet->getCell('C' . $row)->getFormattedValue());
|
||||||
$helper->log('Formula: ' . $worksheet->getCell('D' . $row)->getValue());
|
$helper->log('Formula: ' . $worksheet->getCell('D' . $row)->getValue());
|
||||||
$helper->log('Excel DateStamp: ' . $worksheet->getCell('D' . $row)->getFormattedValue());
|
$helper->log('Excel DateStamp: ' . $worksheet->getCell('D' . $row)->getCalculatedValue());
|
||||||
$helper->log('Formatted DateStamp: ' . $worksheet->getCell('E' . $row)->getFormattedValue());
|
$helper->log('Formatted DateStamp: ' . $worksheet->getCell('E' . $row)->getFormattedValue());
|
||||||
$helper->log('');
|
$helper->log('');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'DATEDIF';
|
||||||
|
$description = 'Calculates the number of days, months, or years between two dates';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testDates = [
|
||||||
|
[1900, 1, 1],
|
||||||
|
[1904, 1, 1],
|
||||||
|
[1936, 3, 17],
|
||||||
|
[1960, 12, 19],
|
||||||
|
[1999, 12, 31],
|
||||||
|
[2000, 1, 1],
|
||||||
|
[2019, 2, 14],
|
||||||
|
[2020, 7, 4],
|
||||||
|
[2020, 2, 29],
|
||||||
|
];
|
||||||
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testDates, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=DATE(A' . $row . ',B' . $row . ',C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
||||||
|
$worksheet->setCellValue('F' . $row, '=TODAY()');
|
||||||
|
$worksheet->setCellValue('G' . $row, '=DATEDIF(D' . $row . ', F' . $row . ', "Y")');
|
||||||
|
$worksheet->setCellValue('H' . $row, '=DATEDIF(D' . $row . ', F' . $row . ', "M")');
|
||||||
|
$worksheet->setCellValue('I' . $row, '=DATEDIF(D' . $row . ', F' . $row . ', "D")');
|
||||||
|
$worksheet->setCellValue('J' . $row, '=DATEDIF(D' . $row . ', F' . $row . ', "MD")');
|
||||||
|
$worksheet->setCellValue('K' . $row, '=DATEDIF(D' . $row . ', F' . $row . ', "YM")');
|
||||||
|
$worksheet->setCellValue('L' . $row, '=DATEDIF(D' . $row . ', F' . $row . ', "YD")');
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('E1:F' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Between: %s and %s',
|
||||||
|
$worksheet->getCell('E' . $row)->getFormattedValue(),
|
||||||
|
$worksheet->getCell('F' . $row)->getFormattedValue()
|
||||||
|
));
|
||||||
|
$helper->log('In years ("Y"): ' . $worksheet->getCell('G' . $row)->getCalculatedValue());
|
||||||
|
$helper->log('In months ("M"): ' . $worksheet->getCell('H' . $row)->getCalculatedValue());
|
||||||
|
$helper->log('In days ("D"): ' . $worksheet->getCell('I' . $row)->getCalculatedValue());
|
||||||
|
$helper->log('In days ignoring months and years ("MD"): ' . $worksheet->getCell('J' . $row)->getCalculatedValue());
|
||||||
|
$helper->log('In months ignoring days and years ("YM"): ' . $worksheet->getCell('K' . $row)->getCalculatedValue());
|
||||||
|
$helper->log('In days ignoring years ("YD"): ' . $worksheet->getCell('L' . $row)->getCalculatedValue());
|
||||||
|
}
|
||||||
|
|
@ -4,7 +4,11 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
require __DIR__ . '/../../Header.php';
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
$helper->log('Converts a date in the form of text to a serial number.');
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'DATEVALUE';
|
||||||
|
$description = 'Converts a date in the form of text to an Excel serial number';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Create new PhpSpreadsheet object
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
|
|
@ -13,8 +17,8 @@ $worksheet = $spreadsheet->getActiveSheet();
|
||||||
// Add some data
|
// Add some data
|
||||||
$testDates = ['26 March 2012', '29 Feb 2012', 'April 1, 2012', '25/12/2012',
|
$testDates = ['26 March 2012', '29 Feb 2012', 'April 1, 2012', '25/12/2012',
|
||||||
'2012-Oct-31', '5th November', 'January 1st', 'April 2012',
|
'2012-Oct-31', '5th November', 'January 1st', 'April 2012',
|
||||||
'17-03', '03-2012', '29 Feb 2011', '03-05-07',
|
'17-03', '03-17', '03-2012', '29 Feb 2011', '03-05-07',
|
||||||
'03-MAY-07', '03-13-07',
|
'03-MAY-07', '03-13-07', '13-03-07', '03/13/07', '13/03/07',
|
||||||
];
|
];
|
||||||
$testDateCount = count($testDates);
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
|
|
@ -26,14 +30,14 @@ for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
|
||||||
$worksheet->getStyle('C1:C' . $testDateCount)
|
$worksheet->getStyle('C1:C' . $testDateCount)
|
||||||
->getNumberFormat()
|
->getNumberFormat()
|
||||||
->setFormatCode('yyyy-mmm-dd');
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
// Test the formulae
|
// Test the formulae
|
||||||
$helper->log('<strong>Warning: </strong>The PhpSpreadsheet DATEVALUE() function accepts a wider range of date formats than MS Excel DATEFORMAT() function.');
|
$helper->log('<strong>Warning: </strong>The PhpSpreadsheet DATEVALUE() function accepts a wider range of date formats than MS Excel DATEFORMAT() function.');
|
||||||
for ($row = 1; $row <= $testDateCount; ++$row) {
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
$helper->log('Date String: ' . $worksheet->getCell('A' . $row)->getFormattedValue());
|
$helper->log("(A{$row}) Date String: " . $worksheet->getCell('A' . $row)->getFormattedValue());
|
||||||
$helper->log('Formula: ' . $worksheet->getCell('B' . $row)->getValue());
|
$helper->log('Formula: ' . $worksheet->getCell('B' . $row)->getValue());
|
||||||
$helper->log('Excel DateStamp: ' . $worksheet->getCell('B' . $row)->getFormattedValue());
|
$helper->log('Excel DateStamp: ' . $worksheet->getCell('B' . $row)->getCalculatedValue());
|
||||||
$helper->log('Formatted DateStamp' . $worksheet->getCell('C' . $row)->getFormattedValue());
|
$helper->log('Formatted DateStamp: ' . $worksheet->getCell('C' . $row)->getFormattedValue());
|
||||||
$helper->log('');
|
$helper->log('');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'DAY';
|
||||||
|
$description = 'Returns the day of a date, an integer ranging from 1 to 31';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testDates = [
|
||||||
|
[1900, 1, 1],
|
||||||
|
[1904, 2, 14],
|
||||||
|
[1936, 3, 17],
|
||||||
|
[1964, 4, 29],
|
||||||
|
[1999, 5, 18],
|
||||||
|
[2000, 6, 21],
|
||||||
|
[2019, 7, 4],
|
||||||
|
[2020, 8, 31],
|
||||||
|
[1956, 9, 10],
|
||||||
|
[2010, 10, 10],
|
||||||
|
[1982, 11, 30],
|
||||||
|
[1960, 12, 19],
|
||||||
|
['=YEAR(TODAY())', '=MONTH(TODAY())', '=DAY(TODAY())'],
|
||||||
|
];
|
||||||
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testDates, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=DATE(A' . $row . ',B' . $row . ',C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
||||||
|
$worksheet->setCellValue('F' . $row, '=DAY(D' . $row . ')');
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('E1:E' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$helper->log(sprintf('(E%d): %s', $row, $worksheet->getCell('E' . $row)->getFormattedValue()));
|
||||||
|
$helper->log('Day is: ' . $worksheet->getCell('F' . $row)->getCalculatedValue());
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'DAYS';
|
||||||
|
$description = 'Returns the number of days between two dates';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testDates = [
|
||||||
|
[1900, 1, 1],
|
||||||
|
[1904, 1, 1],
|
||||||
|
[1936, 3, 17],
|
||||||
|
[1960, 12, 19],
|
||||||
|
[1999, 12, 31],
|
||||||
|
[2000, 1, 1],
|
||||||
|
[2019, 2, 14],
|
||||||
|
[2020, 7, 4],
|
||||||
|
[2020, 2, 29],
|
||||||
|
[2029, 12, 31],
|
||||||
|
[2525, 1, 1],
|
||||||
|
];
|
||||||
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testDates, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=DATE(A' . $row . ',B' . $row . ',C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
||||||
|
$worksheet->setCellValue('F' . $row, '=TODAY()');
|
||||||
|
$worksheet->setCellValue('G' . $row, '=DAYS(D' . $row . ', F' . $row . ')');
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('E1:F' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Between: %s and %s',
|
||||||
|
$worksheet->getCell('E' . $row)->getFormattedValue(),
|
||||||
|
$worksheet->getCell('F' . $row)->getFormattedValue()
|
||||||
|
));
|
||||||
|
$helper->log('Days: ' . $worksheet->getCell('G' . $row)->getCalculatedValue());
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'DAYS360';
|
||||||
|
$description = 'Returns the number of days between two dates based on a 360-day year';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testDates = [
|
||||||
|
[1900, 1, 1],
|
||||||
|
[1904, 1, 1],
|
||||||
|
[1936, 3, 17],
|
||||||
|
[1960, 12, 19],
|
||||||
|
[1999, 12, 31],
|
||||||
|
[2000, 1, 1],
|
||||||
|
[2019, 2, 14],
|
||||||
|
[2020, 7, 4],
|
||||||
|
[2029, 12, 31],
|
||||||
|
[2525, 1, 1],
|
||||||
|
];
|
||||||
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testDates, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=DATE(A' . $row . ',B' . $row . ',C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
||||||
|
$worksheet->setCellValue('F' . $row, '=DATE(2022,12,31)');
|
||||||
|
$worksheet->setCellValue('G' . $row, '=DAYS360(D' . $row . ', F' . $row . ', FALSE)');
|
||||||
|
$worksheet->setCellValue('H' . $row, '=DAYS360(D' . $row . ', F' . $row . ', TRUE)');
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('E1:F' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Between: %s and %s',
|
||||||
|
$worksheet->getCell('E' . $row)->getFormattedValue(),
|
||||||
|
$worksheet->getCell('F' . $row)->getFormattedValue()
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Days: %d (US) %d (European)',
|
||||||
|
$worksheet->getCell('G' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('H' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'EDATE';
|
||||||
|
$description = 'Returns the serial number that represents the date that is the indicated number of months before or after a specified date';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
$months = range(-12, 12);
|
||||||
|
$testDateCount = count($months);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('A' . $row, '=DATE(2020,12,31)');
|
||||||
|
$worksheet->setCellValue('B' . $row, '=A' . $row);
|
||||||
|
$worksheet->setCellValue('C' . $row, $months[$row - 1]);
|
||||||
|
$worksheet->setCellValue('D' . $row, '=EDATE(B' . $row . ', C' . $row . ')');
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('B1:B' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
$worksheet->getStyle('D1:D' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'%s and %d months is %d (%s)',
|
||||||
|
$worksheet->getCell('B' . $row)->getFormattedValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getFormattedValue(),
|
||||||
|
$worksheet->getCell('D' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('D' . $row)->getFormattedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'EOMONTH';
|
||||||
|
$description = 'Returns the serial number for the last day of the month that is the indicated number of months before or after start_date';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
$months = range(-12, 12);
|
||||||
|
$testDateCount = count($months);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('A' . $row, '=DATE(2020,1,1)');
|
||||||
|
$worksheet->setCellValue('B' . $row, '=A' . $row);
|
||||||
|
$worksheet->setCellValue('C' . $row, $months[$row - 1]);
|
||||||
|
$worksheet->setCellValue('D' . $row, '=EOMONTH(B' . $row . ', C' . $row . ')');
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('B1:B' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
$worksheet->getStyle('D1:D' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'%s and %d months is %d (%s)',
|
||||||
|
$worksheet->getCell('B' . $row)->getFormattedValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getFormattedValue(),
|
||||||
|
$worksheet->getCell('D' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('D' . $row)->getFormattedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'HOUR';
|
||||||
|
$description = 'Returns the hour of a time value. The hour is given as an integer, ranging from 0 (12:00 AM) to 23 (11:00 PM)';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testTimes = [
|
||||||
|
[0, 6, 0],
|
||||||
|
[1, 12, 15],
|
||||||
|
[3, 30, 12],
|
||||||
|
[5, 17, 31],
|
||||||
|
[8, 15, 45],
|
||||||
|
[12, 45, 11],
|
||||||
|
[14, 0, 30],
|
||||||
|
[17, 55, 50],
|
||||||
|
[19, 21, 8],
|
||||||
|
[21, 10, 10],
|
||||||
|
[23, 59, 59],
|
||||||
|
];
|
||||||
|
$testTimeCount = count($testTimes);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testTimes, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testTimeCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=TIME(A' . $row . ',B' . $row . ',C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
||||||
|
$worksheet->setCellValue('F' . $row, '=HOUR(D' . $row . ')');
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('E1:E' . $testTimeCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('hh:mm:ss');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testTimeCount; ++$row) {
|
||||||
|
$helper->log(sprintf('(E%d): %s', $row, $worksheet->getCell('E' . $row)->getFormattedValue()));
|
||||||
|
$helper->log('Hour is: ' . $worksheet->getCell('F' . $row)->getCalculatedValue());
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'ISOWEEKNUM';
|
||||||
|
$description = 'Returns number of the ISO week number of the year for a given date. (ISO-8601)';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testDates = [
|
||||||
|
[1900, 1, 1],
|
||||||
|
[1904, 2, 14],
|
||||||
|
[1936, 3, 17],
|
||||||
|
[1964, 4, 29],
|
||||||
|
[1999, 5, 18],
|
||||||
|
[2000, 6, 21],
|
||||||
|
[2019, 7, 4],
|
||||||
|
[2020, 8, 31],
|
||||||
|
[1956, 9, 10],
|
||||||
|
[2010, 10, 10],
|
||||||
|
[1982, 11, 30],
|
||||||
|
[1960, 12, 19],
|
||||||
|
['=YEAR(TODAY())', '=MONTH(TODAY())', '=DAY(TODAY())'],
|
||||||
|
];
|
||||||
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testDates, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=DATE(A' . $row . ',B' . $row . ',C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
||||||
|
$worksheet->setCellValue('F' . $row, '=ISOWEEKNUM(D' . $row . ')');
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('E1:E' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$helper->log(sprintf('(E%d): %s', $row, $worksheet->getCell('E' . $row)->getFormattedValue()));
|
||||||
|
$helper->log('ISO Week number is: ' . $worksheet->getCell('F' . $row)->getCalculatedValue());
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'MINUTE';
|
||||||
|
$description = 'Returns the minute of a time value. The minute is given as an integer, ranging from 0 to 59';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testTimes = [
|
||||||
|
[0, 6, 0],
|
||||||
|
[1, 12, 15],
|
||||||
|
[3, 30, 12],
|
||||||
|
[5, 17, 31],
|
||||||
|
[8, 15, 45],
|
||||||
|
[12, 45, 11],
|
||||||
|
[14, 0, 30],
|
||||||
|
[17, 55, 50],
|
||||||
|
[19, 21, 8],
|
||||||
|
[21, 10, 10],
|
||||||
|
[23, 59, 59],
|
||||||
|
];
|
||||||
|
$testTimeCount = count($testTimes);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testTimes, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testTimeCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=TIME(A' . $row . ',B' . $row . ',C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
||||||
|
$worksheet->setCellValue('F' . $row, '=MINUTE(D' . $row . ')');
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('E1:E' . $testTimeCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('hh:mm:ss');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testTimeCount; ++$row) {
|
||||||
|
$helper->log(sprintf('(E%d): %s', $row, $worksheet->getCell('E' . $row)->getFormattedValue()));
|
||||||
|
$helper->log('Minute is: ' . $worksheet->getCell('F' . $row)->getCalculatedValue());
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'MONTH';
|
||||||
|
$description = 'Returns the month of a date, an integer ranging from 1 to 12';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testDates = [
|
||||||
|
[1900, 1, 1],
|
||||||
|
[1904, 2, 14],
|
||||||
|
[1936, 3, 17],
|
||||||
|
[1964, 4, 29],
|
||||||
|
[1999, 5, 18],
|
||||||
|
[2000, 6, 21],
|
||||||
|
[2019, 7, 4],
|
||||||
|
[2020, 8, 31],
|
||||||
|
[1956, 9, 10],
|
||||||
|
[2010, 10, 10],
|
||||||
|
[1982, 11, 30],
|
||||||
|
[1960, 12, 19],
|
||||||
|
['=YEAR(TODAY())', '=MONTH(TODAY())', '=DAY(TODAY())'],
|
||||||
|
];
|
||||||
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testDates, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=DATE(A' . $row . ',B' . $row . ',C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
||||||
|
$worksheet->setCellValue('F' . $row, '=MONTH(D' . $row . ')');
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('E1:E' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$helper->log(sprintf('(E%d): %s', $row, $worksheet->getCell('E' . $row)->getFormattedValue()));
|
||||||
|
$helper->log('Month is: ' . $worksheet->getCell('F' . $row)->getCalculatedValue());
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'NETWORKDAYS';
|
||||||
|
$description = 'Returns the number of whole working days between start_date and end_date. Working days exclude weekends and any dates identified in holidays';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$publicHolidays = [
|
||||||
|
[2022, 1, 3, '=DATE(G1, H1, I1)', 'New Year'],
|
||||||
|
[2022, 4, 15, '=DATE(G2, H2, I2)', 'Good Friday'],
|
||||||
|
[2022, 4, 18, '=DATE(G3, H3, I3)', 'Easter Monday'],
|
||||||
|
[2022, 5, 2, '=DATE(G4, H4, I4)', 'Early May Bank Holiday'],
|
||||||
|
[2022, 6, 2, '=DATE(G5, H5, I5)', 'Spring Bank Holiday'],
|
||||||
|
[2022, 6, 3, '=DATE(G6, H6, I6)', 'Platinum Jubilee Bank Holiday'],
|
||||||
|
[2022, 8, 29, '=DATE(G7, H7, I7)', 'Summer Bank Holiday'],
|
||||||
|
[2022, 12, 26, '=DATE(G8, H8, I8)', 'Boxing Day'],
|
||||||
|
[2022, 12, 27, '=DATE(G9, H9, I9)', 'Christmas Day'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$holidayCount = count($publicHolidays);
|
||||||
|
$worksheet->fromArray($publicHolidays, null, 'G1', true);
|
||||||
|
|
||||||
|
$worksheet->getStyle('J1:J' . $holidayCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
$worksheet->setCellValue('A1', '=DATE(2022,1,1)');
|
||||||
|
|
||||||
|
for ($numberOfMonths = 0; $numberOfMonths < 12; ++$numberOfMonths) {
|
||||||
|
$worksheet->setCellValue('B' . ($numberOfMonths + 1), '=EOMONTH(A1, ' . $numberOfMonths . ')');
|
||||||
|
$worksheet->setCellValue('C' . ($numberOfMonths + 1), '=NETWORKDAYS(A1, B' . ($numberOfMonths + 1) . ')');
|
||||||
|
$worksheet->setCellValue('D' . ($numberOfMonths + 1), '=NETWORKDAYS(A1, B' . ($numberOfMonths + 1) . ', J1:J' . $holidayCount . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$worksheet->getStyle('A1')
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
$worksheet->getStyle('B1:B12')
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
$helper->log('UK Public Holidays');
|
||||||
|
$holidayData = $worksheet->rangeToArray('J1:K' . $holidayCount, null, true, true, true);
|
||||||
|
$helper->displayGrid($holidayData);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= 12; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Between %s and %s is %d working days; %d with public holidays',
|
||||||
|
$worksheet->getCell('A1')->getFormattedValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getFormattedValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('D' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'NOW';
|
||||||
|
$description = 'Returns the serial number of the current date and time';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
$worksheet->setCellValue('A1', '=NOW()');
|
||||||
|
$worksheet->getStyle('A1')
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd hh:mm:ss');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Today is %f (%s)',
|
||||||
|
$worksheet->getCell('A1')->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('A1')->getFormattedValue()
|
||||||
|
));
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'SECOND';
|
||||||
|
$description = 'Returns the second of a time value. The second is given as an integer, ranging from 0 to 59';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testTimes = [
|
||||||
|
[0, 6, 0],
|
||||||
|
[1, 12, 15],
|
||||||
|
[3, 30, 12],
|
||||||
|
[5, 17, 31],
|
||||||
|
[8, 15, 45],
|
||||||
|
[12, 45, 11],
|
||||||
|
[14, 0, 30],
|
||||||
|
[17, 55, 50],
|
||||||
|
[19, 21, 8],
|
||||||
|
[21, 10, 10],
|
||||||
|
[23, 59, 59],
|
||||||
|
];
|
||||||
|
$testTimeCount = count($testTimes);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testTimes, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testTimeCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=TIME(A' . $row . ',B' . $row . ',C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
||||||
|
$worksheet->setCellValue('F' . $row, '=SECOND(D' . $row . ')');
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('E1:E' . $testTimeCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('hh:mm:ss');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testTimeCount; ++$row) {
|
||||||
|
$helper->log(sprintf('(E%d): %s', $row, $worksheet->getCell('E' . $row)->getFormattedValue()));
|
||||||
|
$helper->log('Second is: ' . $worksheet->getCell('F' . $row)->getCalculatedValue());
|
||||||
|
}
|
||||||
|
|
@ -4,7 +4,11 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
require __DIR__ . '/../../Header.php';
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
$helper->log('Returns the serial number of a particular time.');
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'TIME';
|
||||||
|
$description = 'Returns the Excel serial number of a particular time';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Create new PhpSpreadsheet object
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
|
|
@ -29,11 +33,11 @@ $worksheet->getStyle('E1:E' . $testDateCount)
|
||||||
|
|
||||||
// Test the formulae
|
// Test the formulae
|
||||||
for ($row = 1; $row <= $testDateCount; ++$row) {
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
$helper->log('Hour: ' . $worksheet->getCell('A' . $row)->getFormattedValue());
|
$helper->log("(A{$row}) Hour: " . $worksheet->getCell('A' . $row)->getFormattedValue());
|
||||||
$helper->log('Minute: ' . $worksheet->getCell('B' . $row)->getFormattedValue());
|
$helper->log("(B{$row}) Minute: " . $worksheet->getCell('B' . $row)->getFormattedValue());
|
||||||
$helper->log('Second: ' . $worksheet->getCell('C' . $row)->getFormattedValue());
|
$helper->log("(C{$row}) Second: " . $worksheet->getCell('C' . $row)->getFormattedValue());
|
||||||
$helper->log('Formula: ' . $worksheet->getCell('D' . $row)->getValue());
|
$helper->log('Formula: ' . $worksheet->getCell('D' . $row)->getValue());
|
||||||
$helper->log('Excel TimeStamp: ' . $worksheet->getCell('D' . $row)->getFormattedValue());
|
$helper->log('Excel TimeStamp: ' . $worksheet->getCell('D' . $row)->getCalculatedValue());
|
||||||
$helper->log('Formatted TimeStamp: ' . $worksheet->getCell('E' . $row)->getFormattedValue());
|
$helper->log('Formatted TimeStamp: ' . $worksheet->getCell('E' . $row)->getFormattedValue());
|
||||||
$helper->log('');
|
$helper->log('');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,11 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
require __DIR__ . '/../../Header.php';
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
$helper->log('Converts a time in the form of text to a serial number.');
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'DATEVALUE';
|
||||||
|
$description = 'Converts a time in the form of text to an Excel serial number';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Create new PhpSpreadsheet object
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
|
|
@ -27,7 +31,7 @@ $worksheet->getStyle('C1:C' . $testDateCount)
|
||||||
|
|
||||||
// Test the formulae
|
// Test the formulae
|
||||||
for ($row = 1; $row <= $testDateCount; ++$row) {
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
$helper->log('Time String: ' . $worksheet->getCell('A' . $row)->getFormattedValue());
|
$helper->log("(A{$row}) Time String: " . $worksheet->getCell('A' . $row)->getFormattedValue());
|
||||||
$helper->log('Formula: ' . $worksheet->getCell('B' . $row)->getValue());
|
$helper->log('Formula: ' . $worksheet->getCell('B' . $row)->getValue());
|
||||||
$helper->log('Excel TimeStamp: ' . $worksheet->getCell('B' . $row)->getFormattedValue());
|
$helper->log('Excel TimeStamp: ' . $worksheet->getCell('B' . $row)->getFormattedValue());
|
||||||
$helper->log('Formatted TimeStamp: ' . $worksheet->getCell('C' . $row)->getFormattedValue());
|
$helper->log('Formatted TimeStamp: ' . $worksheet->getCell('C' . $row)->getFormattedValue());
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'TODAY';
|
||||||
|
$description = 'Returns the serial number of the current date';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
$worksheet->setCellValue('A1', '=TODAY()');
|
||||||
|
$worksheet->getStyle('A1')
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Today is %d (%s)',
|
||||||
|
$worksheet->getCell('A1')->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('A1')->getFormattedValue()
|
||||||
|
));
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'WEEKDAY';
|
||||||
|
$description = 'Returns the day of the week corresponding to a date';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testDates = [
|
||||||
|
[1900, 1, 1],
|
||||||
|
[1904, 2, 14],
|
||||||
|
[1936, 3, 17],
|
||||||
|
[1964, 4, 29],
|
||||||
|
[1999, 5, 18],
|
||||||
|
[2000, 6, 21],
|
||||||
|
[2019, 7, 4],
|
||||||
|
[2020, 8, 31],
|
||||||
|
[1956, 9, 10],
|
||||||
|
[2010, 10, 10],
|
||||||
|
[1982, 11, 30],
|
||||||
|
[1960, 12, 19],
|
||||||
|
['=YEAR(TODAY())', '=MONTH(TODAY())', '=DAY(TODAY())'],
|
||||||
|
];
|
||||||
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testDates, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=DATE(A' . $row . ',B' . $row . ',C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
||||||
|
$worksheet->setCellValue('F' . $row, '=WEEKDAY(D' . $row . ')');
|
||||||
|
$worksheet->setCellValue('G' . $row, '=WEEKDAY(D' . $row . ', 2)');
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('E1:E' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$helper->log(sprintf('(E%d): %s', $row, $worksheet->getCell('E' . $row)->getFormattedValue()));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Weekday is: %d (1-7 = Sun-Sat)',
|
||||||
|
$worksheet->getCell('F' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Weekday is: %d (1-7 = Mon-Sun)',
|
||||||
|
$worksheet->getCell('G' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'WEEKNUM';
|
||||||
|
$description = 'Returns the week number of a specific date';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testDates = [
|
||||||
|
[1900, 1, 1],
|
||||||
|
[1904, 2, 14],
|
||||||
|
[1936, 3, 17],
|
||||||
|
[1964, 4, 29],
|
||||||
|
[1999, 5, 18],
|
||||||
|
[2000, 6, 21],
|
||||||
|
[2019, 7, 4],
|
||||||
|
[2020, 8, 31],
|
||||||
|
[1956, 9, 10],
|
||||||
|
[2010, 10, 10],
|
||||||
|
[1982, 11, 30],
|
||||||
|
[1960, 12, 19],
|
||||||
|
['=YEAR(TODAY())', '=MONTH(TODAY())', '=DAY(TODAY())'],
|
||||||
|
];
|
||||||
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testDates, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=DATE(A' . $row . ',B' . $row . ',C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
||||||
|
$worksheet->setCellValue('F' . $row, '=WEEKNUM(D' . $row . ')');
|
||||||
|
$worksheet->setCellValue('G' . $row, '=WEEKNUM(D' . $row . ', 21)');
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('E1:E' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$helper->log(sprintf('(E%d): %s', $row, $worksheet->getCell('E' . $row)->getFormattedValue()));
|
||||||
|
$helper->log('System 1 Week number is: ' . $worksheet->getCell('F' . $row)->getCalculatedValue());
|
||||||
|
$helper->log('System 2 (ISO-8601) Week number is: ' . $worksheet->getCell('G' . $row)->getCalculatedValue());
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'WORKDAY';
|
||||||
|
$description = 'Returns a number that represents a date that is the indicated number of working days before or after a starting date. Working days exclude weekends and any dates identified as holidays';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$publicHolidays = [
|
||||||
|
[2022, 1, 3, '=DATE(G1, H1, I1)', 'New Year'],
|
||||||
|
[2022, 4, 15, '=DATE(G2, H2, I2)', 'Good Friday'],
|
||||||
|
[2022, 4, 18, '=DATE(G3, H3, I3)', 'Easter Monday'],
|
||||||
|
[2022, 5, 2, '=DATE(G4, H4, I4)', 'Early May Bank Holiday'],
|
||||||
|
[2022, 6, 2, '=DATE(G5, H5, I5)', 'Spring Bank Holiday'],
|
||||||
|
[2022, 6, 3, '=DATE(G6, H6, I6)', 'Platinum Jubilee Bank Holiday'],
|
||||||
|
[2022, 8, 29, '=DATE(G7, H7, I7)', 'Summer Bank Holiday'],
|
||||||
|
[2022, 12, 26, '=DATE(G8, H8, I8)', 'Boxing Day'],
|
||||||
|
[2022, 12, 27, '=DATE(G9, H9, I9)', 'Christmas Day'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$holidayCount = count($publicHolidays);
|
||||||
|
$worksheet->fromArray($publicHolidays, null, 'G1', true);
|
||||||
|
|
||||||
|
$worksheet->getStyle('J1:J' . $holidayCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
$worksheet->setCellValue('A1', '=DATE(2022,1,1)');
|
||||||
|
|
||||||
|
$workdayStep = 10;
|
||||||
|
for ($days = $workdayStep; $days <= 366; $days += $workdayStep) {
|
||||||
|
$worksheet->setCellValue('B' . ((int) $days / $workdayStep + 1), $days);
|
||||||
|
$worksheet->setCellValue('C' . ((int) $days / $workdayStep + 1), '=WORKDAY(A1, B' . ((int) $days / $workdayStep + 1) . ')');
|
||||||
|
$worksheet->setCellValue('D' . ((int) $days / $workdayStep + 1), '=WORKDAY(A1, B' . ((int) $days / $workdayStep + 1) . ', J1:J' . $holidayCount . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$worksheet->getStyle('A1')
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
$worksheet->getStyle('C1:D50')
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
$helper->log('UK Public Holidays');
|
||||||
|
$holidayData = $worksheet->rangeToArray('J1:K' . $holidayCount, null, true, true, true);
|
||||||
|
$helper->displayGrid($holidayData);
|
||||||
|
|
||||||
|
for ($days = $workdayStep; $days <= 366; $days += $workdayStep) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'%d workdays from %s is %s; %s with public holidays',
|
||||||
|
$worksheet->getCell('B' . ((int) $days / $workdayStep + 1))->getFormattedValue(),
|
||||||
|
$worksheet->getCell('A1')->getFormattedValue(),
|
||||||
|
$worksheet->getCell('C' . ((int) $days / $workdayStep + 1))->getFormattedValue(),
|
||||||
|
$worksheet->getCell('D' . ((int) $days / $workdayStep + 1))->getFormattedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'YEAR';
|
||||||
|
$description = 'Returns the year of a date, an integer ranging from 1900 to 9999';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testDates = [
|
||||||
|
[1900, 1, 1],
|
||||||
|
[1904, 2, 14],
|
||||||
|
[1936, 3, 17],
|
||||||
|
[1964, 4, 29],
|
||||||
|
[1999, 5, 18],
|
||||||
|
[2000, 6, 21],
|
||||||
|
[2019, 7, 4],
|
||||||
|
[2020, 8, 31],
|
||||||
|
[1956, 9, 10],
|
||||||
|
[2010, 10, 10],
|
||||||
|
[1982, 11, 30],
|
||||||
|
[1960, 12, 19],
|
||||||
|
['=YEAR(TODAY())', '=MONTH(TODAY())', '=DAY(TODAY())'],
|
||||||
|
];
|
||||||
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testDates, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=DATE(A' . $row . ',B' . $row . ',C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
||||||
|
$worksheet->setCellValue('F' . $row, '=YEAR(D' . $row . ')');
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('E1:E' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$helper->log(sprintf('(E%d): %s', $row, $worksheet->getCell('E' . $row)->getFormattedValue()));
|
||||||
|
$helper->log('Year is: ' . $worksheet->getCell('F' . $row)->getCalculatedValue());
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Date/Time';
|
||||||
|
$functionName = 'DAYS360';
|
||||||
|
$description = 'Returns the number of days between two dates based on a 360-day year';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testDates = [
|
||||||
|
[1900, 1, 1],
|
||||||
|
[1904, 1, 1],
|
||||||
|
[1936, 3, 17],
|
||||||
|
[1960, 12, 19],
|
||||||
|
[1999, 12, 31],
|
||||||
|
[2000, 1, 1],
|
||||||
|
[2019, 2, 14],
|
||||||
|
[2020, 7, 4],
|
||||||
|
[2020, 2, 29],
|
||||||
|
[2029, 12, 31],
|
||||||
|
[2525, 1, 1],
|
||||||
|
];
|
||||||
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testDates, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=DATE(A' . $row . ',B' . $row . ',C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
||||||
|
$worksheet->setCellValue('F' . $row, '=DATE(2022,12,31)');
|
||||||
|
$worksheet->setCellValue('G' . $row, '=YEARFRAC(D' . $row . ', F' . $row . ')');
|
||||||
|
$worksheet->setCellValue('H' . $row, '=YEARFRAC(D' . $row . ', F' . $row . ', 1)');
|
||||||
|
$worksheet->setCellValue('I' . $row, '=YEARFRAC(D' . $row . ', F' . $row . ', 2)');
|
||||||
|
$worksheet->setCellValue('J' . $row, '=YEARFRAC(D' . $row . ', F' . $row . ', 3)');
|
||||||
|
$worksheet->setCellValue('K' . $row, '=YEARFRAC(D' . $row . ', F' . $row . ', 4)');
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('E1:F' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mm-dd');
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Between: %s and %s',
|
||||||
|
$worksheet->getCell('E' . $row)->getFormattedValue(),
|
||||||
|
$worksheet->getCell('F' . $row)->getFormattedValue()
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Days: %f - US (NASD) 30/360',
|
||||||
|
$worksheet->getCell('G' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Days: %f - Actual',
|
||||||
|
$worksheet->getCell('H' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Days: %f - Actual/360',
|
||||||
|
$worksheet->getCell('I' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Days: %f - Actual/365',
|
||||||
|
$worksheet->getCell('J' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'Days: %f - European 30/360',
|
||||||
|
$worksheet->getCell('K' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BESSELI';
|
||||||
|
$description = 'Returns the modified Bessel function, which is equivalent to the Bessel function evaluated for purely imaginary arguments';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
for ($n = 0; $n <= 5; ++$n) {
|
||||||
|
for ($x = 0; $x <= 5; $x = $x + 0.25) {
|
||||||
|
Calculation::getInstance($spreadsheet)->flushInstance();
|
||||||
|
$worksheet->setCellValue('A1', "=BESSELI({$x}, {$n})");
|
||||||
|
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'%s = %f',
|
||||||
|
$worksheet->getCell('A1')->getValue(),
|
||||||
|
$worksheet->getCell('A1')->getCalculatedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BESSELJ';
|
||||||
|
$description = 'Returns the Bessel function';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
for ($n = 0; $n <= 5; ++$n) {
|
||||||
|
for ($x = 0; $x <= 5; $x = $x + 0.25) {
|
||||||
|
Calculation::getInstance($spreadsheet)->flushInstance();
|
||||||
|
$worksheet->setCellValue('A1', "=BESSELJ({$x}, {$n})");
|
||||||
|
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'%s = %f',
|
||||||
|
$worksheet->getCell('A1')->getValue(),
|
||||||
|
$worksheet->getCell('A1')->getCalculatedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BESSELK';
|
||||||
|
$description = 'Returns the modified Bessel function, which is equivalent to the Bessel functions evaluated for purely imaginary arguments';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
for ($n = 0; $n <= 5; ++$n) {
|
||||||
|
for ($x = 0; $x <= 5; $x = $x + 0.25) {
|
||||||
|
Calculation::getInstance($spreadsheet)->flushInstance();
|
||||||
|
$worksheet->setCellValue('A1', "=BESSELK({$x}, {$n})");
|
||||||
|
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'%s = %f',
|
||||||
|
$worksheet->getCell('A1')->getValue(),
|
||||||
|
$worksheet->getCell('A1')->getCalculatedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BESSELY';
|
||||||
|
$description = 'Returns the Bessel function, which is also called the Weber function or the Neumann function';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
for ($n = 0; $n <= 5; ++$n) {
|
||||||
|
for ($x = 0; $x <= 5; $x = $x + 0.25) {
|
||||||
|
Calculation::getInstance($spreadsheet)->flushInstance();
|
||||||
|
$worksheet->setCellValue('A1', "=BESSELY({$x}, {$n})");
|
||||||
|
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'%s = %f',
|
||||||
|
$worksheet->getCell('A1')->getValue(),
|
||||||
|
$worksheet->getCell('A1')->getCalculatedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BIN2DEC';
|
||||||
|
$description = 'Converts a binary number to decimal';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[101],
|
||||||
|
[110110],
|
||||||
|
[1000000],
|
||||||
|
[11111111],
|
||||||
|
[100010101],
|
||||||
|
[110001100],
|
||||||
|
[111111111],
|
||||||
|
[1111111111],
|
||||||
|
[1100110011],
|
||||||
|
[1000000000],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=BIN2DEC(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Binary %s is decimal %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BIN2HEX';
|
||||||
|
$description = 'Converts a binary number to hexadecimal';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[101],
|
||||||
|
[110110],
|
||||||
|
[1000000],
|
||||||
|
[11111111],
|
||||||
|
[100010101],
|
||||||
|
[110001100],
|
||||||
|
[111111111],
|
||||||
|
[1111111111],
|
||||||
|
[1100110011],
|
||||||
|
[1000000000],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=BIN2HEX(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Binary %s is hexadecimal %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BIN2OCT';
|
||||||
|
$description = 'Converts a binary number to octal';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[101],
|
||||||
|
[110110],
|
||||||
|
[1000000],
|
||||||
|
[11111111],
|
||||||
|
[100010101],
|
||||||
|
[110001100],
|
||||||
|
[111111111],
|
||||||
|
[1111111111],
|
||||||
|
[1100110011],
|
||||||
|
[1000000000],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=BIN2OCT(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Binary %s is octal %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BITAND';
|
||||||
|
$description = "Returns a bitwise 'AND' of two numbers";
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[1, 5],
|
||||||
|
[3, 5],
|
||||||
|
[1, 6],
|
||||||
|
[9, 6],
|
||||||
|
[13, 25],
|
||||||
|
[23, 10],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=TEXT(DEC2BIN(A' . $row . '), "00000")');
|
||||||
|
$worksheet->setCellValue('D' . $row, '=TEXT(DEC2BIN(B' . $row . '), "00000")');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=BITAND(A' . $row . ',B' . $row . ')');
|
||||||
|
$worksheet->setCellValue('F' . $row, '=TEXT(DEC2BIN(E' . $row . '), "00000")');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise AND of %d (%s) and %d (%s) is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('D' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('E' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('F' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BITLSHIFT';
|
||||||
|
$description = 'Returns a number shifted left by the specified number of bits';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[1],
|
||||||
|
[3],
|
||||||
|
[9],
|
||||||
|
[15],
|
||||||
|
[26],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=DEC2BIN(A' . $row . ')');
|
||||||
|
$worksheet->setCellValue('C' . $row, '=BITLSHIFT(A' . $row . ',1)');
|
||||||
|
$worksheet->setCellValue('D' . $row, '=DEC2BIN(C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=BITLSHIFT(A' . $row . ',2)');
|
||||||
|
$worksheet->setCellValue('F' . $row, '=DEC2BIN(E' . $row . ')');
|
||||||
|
$worksheet->setCellValue('G' . $row, '=BITLSHIFT(A' . $row . ',3)');
|
||||||
|
$worksheet->setCellValue('H' . $row, '=DEC2BIN(G' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise Left Shift of %d (%s) by 1 bit is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('D' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise Left Shift of %d (%s) by 2 bits is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('E' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('F' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise Left Shift of %d (%s) by 3 bits is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('G' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('H' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BITOR';
|
||||||
|
$description = "Returns a bitwise 'OR' of two numbers";
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[1, 5],
|
||||||
|
[3, 5],
|
||||||
|
[1, 6],
|
||||||
|
[9, 6],
|
||||||
|
[13, 25],
|
||||||
|
[23, 10],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=TEXT(DEC2BIN(A' . $row . '), "00000")');
|
||||||
|
$worksheet->setCellValue('D' . $row, '=TEXT(DEC2BIN(B' . $row . '), "00000")');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=BITOR(A' . $row . ',B' . $row . ')');
|
||||||
|
$worksheet->setCellValue('F' . $row, '=TEXT(DEC2BIN(E' . $row . '), "00000")');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise OR of %d (%s) and %d (%s) is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('D' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('E' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('F' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BITRSHIFT';
|
||||||
|
$description = 'Returns a number shifted right by the specified number of bits';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[9],
|
||||||
|
[15],
|
||||||
|
[26],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=DEC2BIN(A' . $row . ')');
|
||||||
|
$worksheet->setCellValue('C' . $row, '=BITRSHIFT(A' . $row . ',1)');
|
||||||
|
$worksheet->setCellValue('D' . $row, '=DEC2BIN(C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=BITRSHIFT(A' . $row . ',2)');
|
||||||
|
$worksheet->setCellValue('F' . $row, '=DEC2BIN(E' . $row . ')');
|
||||||
|
$worksheet->setCellValue('G' . $row, '=BITRSHIFT(A' . $row . ',3)');
|
||||||
|
$worksheet->setCellValue('H' . $row, '=DEC2BIN(G' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise Right Shift of %d (%s) by 1 bit is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('D' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise Right Shift of %d (%s) by 2 bits is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('E' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('F' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise Right Shift of %d (%s) by 3 bits is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('G' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('H' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'BITXOR';
|
||||||
|
$description = "Returns a bitwise 'XOR' of two numbers";
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[1, 5],
|
||||||
|
[3, 5],
|
||||||
|
[1, 6],
|
||||||
|
[9, 6],
|
||||||
|
[13, 25],
|
||||||
|
[23, 10],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=TEXT(DEC2BIN(A' . $row . '), "00000")');
|
||||||
|
$worksheet->setCellValue('D' . $row, '=TEXT(DEC2BIN(B' . $row . '), "00000")');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=BITXOR(A' . $row . ',B' . $row . ')');
|
||||||
|
$worksheet->setCellValue('F' . $row, '=TEXT(DEC2BIN(E' . $row . '), "00000")');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Bitwise XOR of %d (%s) and %d (%s) is %d (%s)',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('D' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('E' . $row)->getCalculatedValue(),
|
||||||
|
$worksheet->getCell('F' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'COMPLEX';
|
||||||
|
$description = 'Converts real and imaginary coefficients into a complex number of the form x + yi or x + yj';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[3, 4],
|
||||||
|
[3, 4, '"j"'],
|
||||||
|
[3.5, 4.75],
|
||||||
|
[0, 1],
|
||||||
|
[1, 0],
|
||||||
|
[0, -1],
|
||||||
|
[0, 2],
|
||||||
|
[2, 0],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('A' . $row, '=COMPLEX(' . implode(',', $testData[$row - 1]) . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(A%d): Formula %s result is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('A' . $row)->getCalculatedValue()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'CONVERT';
|
||||||
|
$description = 'Converts a number from one measurement system to another';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$conversions = [
|
||||||
|
[1, '"lbm"', '"kg"'],
|
||||||
|
[1, '"gal"', '"l"'],
|
||||||
|
[24, '"in"', '"ft"'],
|
||||||
|
[100, '"yd"', '"m"'],
|
||||||
|
[500, '"mi"', '"km"'],
|
||||||
|
[7.5, '"min"', '"sec"'],
|
||||||
|
[5, '"F"', '"C"'],
|
||||||
|
[32, '"C"', '"K"'],
|
||||||
|
[100, '"m2"', '"ft2"'],
|
||||||
|
];
|
||||||
|
$testDataCount = count($conversions);
|
||||||
|
|
||||||
|
$worksheet->fromArray($conversions, null, 'A1');
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=CONVERT(' . implode(',', $conversions[$row - 1]) . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$worksheet->setCellValue('H1', '=CONVERT(CONVERT(100,"m","ft"),"m","ft")');
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(A%d): Unit of Measure Conversion Formula %s - %d %s is %f %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('D' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
trim($worksheet->getCell('B' . $row)->getValue(), '"'),
|
||||||
|
$worksheet->getCell('D' . $row)->getCalculatedValue(),
|
||||||
|
trim($worksheet->getCell('C' . $row)->getValue(), '"')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$helper->log('Old method for area conversions, before MS Excel introduced area Units of Measure');
|
||||||
|
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(A%d): Unit of Measure Conversion Formula %s result is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('H1')->getValue(),
|
||||||
|
$worksheet->getCell('H1')->getCalculatedValue()
|
||||||
|
));
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'DEC2BIN';
|
||||||
|
$description = 'Converts a decimal number to binary';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[-255],
|
||||||
|
[-123],
|
||||||
|
[-15],
|
||||||
|
[-1],
|
||||||
|
[5],
|
||||||
|
[7],
|
||||||
|
[19],
|
||||||
|
[51],
|
||||||
|
[121],
|
||||||
|
[256],
|
||||||
|
[511],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=DEC2BIN(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Decimal %s is binary %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'DEC2HEX';
|
||||||
|
$description = 'Converts a decimal number to hexadecimal';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[-255],
|
||||||
|
[-123],
|
||||||
|
[-15],
|
||||||
|
[-1],
|
||||||
|
[5],
|
||||||
|
[7],
|
||||||
|
[19],
|
||||||
|
[51],
|
||||||
|
[121],
|
||||||
|
[256],
|
||||||
|
[511],
|
||||||
|
[12345678],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=DEC2HEX(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Decimal %s is hexadecimal %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'DEC2OCT';
|
||||||
|
$description = 'Converts a decimal number to octal';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[-255],
|
||||||
|
[-123],
|
||||||
|
[-15],
|
||||||
|
[-1],
|
||||||
|
[5],
|
||||||
|
[7],
|
||||||
|
[19],
|
||||||
|
[51],
|
||||||
|
[121],
|
||||||
|
[256],
|
||||||
|
[511],
|
||||||
|
[12345678],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=DEC2OCT(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Decimal %s is octal %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'DELTA';
|
||||||
|
$description = 'Tests whether two values are equal. Returns 1 if number1 = number2; returns 0 otherwise. This function is also known as the Kronecker Delta function';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[4, 5],
|
||||||
|
[3, 3],
|
||||||
|
[0.5, 0],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=DELTA(A' . $row . ',B' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$comparison = [
|
||||||
|
0 => 'The values are not equal',
|
||||||
|
1 => 'The values are equal',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Compare values %d and %d - Result is %d - %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
$comparison[$worksheet->getCell('C' . $row)->getCalculatedValue()]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'ERF';
|
||||||
|
$description = 'Returns the error function integrated between lower_limit and upper_limit';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData1 = [
|
||||||
|
[0.745],
|
||||||
|
[1],
|
||||||
|
[1.5],
|
||||||
|
[-2],
|
||||||
|
];
|
||||||
|
|
||||||
|
$testData2 = [
|
||||||
|
[0, 1.5],
|
||||||
|
[1, 2],
|
||||||
|
[-2, 1],
|
||||||
|
];
|
||||||
|
$testDataCount1 = count($testData1);
|
||||||
|
$testDataCount2 = count($testData2);
|
||||||
|
$testData2StartRow = $testDataCount1 + 1;
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData1, null, 'A1', true);
|
||||||
|
$worksheet->fromArray($testData2, null, "A{$testData2StartRow}", true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount1; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=ERF(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($row = $testDataCount1 + 1; $row <= $testDataCount2 + $testDataCount1; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=ERF(A' . $row . ', B' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
$helper->log('ERF() With a single argument');
|
||||||
|
for ($row = 1; $row <= $testDataCount1; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(C%d): %s The error function integrated between 0 and %f is %f',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('C' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$helper->log('ERF() With two arguments');
|
||||||
|
for ($row = $testDataCount1 + 1; $row <= $testDataCount2 + $testDataCount1; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(C%d): %s The error function integrated between %f and %f is %f',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('C' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'ERFC';
|
||||||
|
$description = 'Returns the complementary ERF function integrated between x and infinity';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[0],
|
||||||
|
[0.5],
|
||||||
|
[1],
|
||||||
|
[-1],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=ERFC(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): %s The complementary error function integrated by %f and infinity is %f',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('C' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'GESTEP';
|
||||||
|
$description = 'Returns 1 if number ≥ step; returns 0 (zero) otherwise';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[5, 4],
|
||||||
|
[5, 5],
|
||||||
|
[4, 5],
|
||||||
|
[-4, -5],
|
||||||
|
[-5, -4],
|
||||||
|
[1],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=GESTEP(A' . $row . ',B' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$comparison = [
|
||||||
|
0 => 'Value %d is less than step %d',
|
||||||
|
1 => 'Value %d is greater than or equal to step %d',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): Compare value %d and step %d - Result is %d - %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
sprintf(
|
||||||
|
$comparison[$worksheet->getCell('C' . $row)->getCalculatedValue()],
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'HEX2BIN';
|
||||||
|
$description = 'Converts a hexadecimal number to binary';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
[3],
|
||||||
|
[8],
|
||||||
|
[42],
|
||||||
|
[99],
|
||||||
|
['A2'],
|
||||||
|
['F0'],
|
||||||
|
['100'],
|
||||||
|
['128'],
|
||||||
|
['1AB'],
|
||||||
|
['1FF'],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=HEX2BIN(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Hexadecimal %s is binary %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'HEX2DEC';
|
||||||
|
$description = 'Converts a hexadecimal number to decimal';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['08'],
|
||||||
|
['42'],
|
||||||
|
['A2'],
|
||||||
|
['400'],
|
||||||
|
['1000'],
|
||||||
|
['1234'],
|
||||||
|
['ABCD'],
|
||||||
|
['C3B0'],
|
||||||
|
['FFFFFFFFF'],
|
||||||
|
['FFFFFFFFFF'],
|
||||||
|
['FFFFFFF800'],
|
||||||
|
['FEDCBA9876'],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=HEX2DEC(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Hexadecimal %s is decimal %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'HEX2OCT';
|
||||||
|
$description = 'Converts a hexadecimal number to octal';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['08'],
|
||||||
|
['42'],
|
||||||
|
['A2'],
|
||||||
|
['400'],
|
||||||
|
['100'],
|
||||||
|
['1234'],
|
||||||
|
['ABCD'],
|
||||||
|
['C3B0'],
|
||||||
|
['FFFFFFFFFF'],
|
||||||
|
['FFFFFFF800'],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=HEX2OCT(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(B%d): Hexadecimal %s is octal %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMABS';
|
||||||
|
$description = 'Returns the absolute value (modulus) of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMABS(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The absolute value of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMAGINARY';
|
||||||
|
$description = 'Returns the imaginary coefficient of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMAGINARY(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The imaginary component of %s is %f',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMARGUMENT';
|
||||||
|
$description = 'Returns the argument Theta, an angle expressed in radians';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMARGUMENT(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Theta Argument of %s is %f radians',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMCONJUGATE';
|
||||||
|
$description = 'Returns the complex conjugate of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMCONJUGATE(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Conjugate of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMCOS';
|
||||||
|
$description = 'Returns the cosine of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMCOS(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Cosine of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMCOSH';
|
||||||
|
$description = 'Returns the hyperbolic cosine of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMCOSH(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Hyperbolic Cosine of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMCOT';
|
||||||
|
$description = 'Returns the cotangent of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMCOT(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Cotangent of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMCSC';
|
||||||
|
$description = 'Returns the cosecant of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMCSC(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Cosecant of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMCSCH';
|
||||||
|
$description = 'Returns the hyperbolic cosecant of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMCSCH(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Hyperbolic Cosecant of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMDIV';
|
||||||
|
$description = 'Returns the quotient of two complex numbers in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i', '5-3i'],
|
||||||
|
['3+4i', '5+3i'],
|
||||||
|
['-238+240i', '10+24i'],
|
||||||
|
['1+2i', 30],
|
||||||
|
['1+2i', '2i'],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=IMDIV(A' . $row . ', B' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Quotient of %s and %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMEXP';
|
||||||
|
$description = 'Returns the exponential of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMEXP(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Exponential of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMLN';
|
||||||
|
$description = 'Returns the natural logarithm of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMLN(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Natural Logarithm of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMLOG10';
|
||||||
|
$description = 'Returns the base-10 logarithm of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMLOG10(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Base-10 Logarithm of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMLOG2';
|
||||||
|
$description = 'Returns the base-2 logarithm of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMLOG2(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Base-2 Logarithm of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMPOWER';
|
||||||
|
$description = 'Returns a complex number in x + yi or x + yj text format raised to a power';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i', 2],
|
||||||
|
['5-12i', 2],
|
||||||
|
['3.25+7.5i', 3],
|
||||||
|
['3.25-12.5i', 2],
|
||||||
|
['-3.25+7.5i', 3],
|
||||||
|
['-3.25-7.5i', 4],
|
||||||
|
['0-j', 5],
|
||||||
|
['0-2.5j', 3],
|
||||||
|
['0+j', 2.5],
|
||||||
|
['0+1.25j', 2],
|
||||||
|
[4, 3],
|
||||||
|
[-2.5, 2],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=IMPOWER(A' . $row . ', B' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): %s raised to the power of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMPRODUCT';
|
||||||
|
$description = 'Returns the product of two or more complex numbers in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i', '5-3i'],
|
||||||
|
['3+4i', '5+3i'],
|
||||||
|
['-238+240i', '10+24i'],
|
||||||
|
['1+2i', 30],
|
||||||
|
['1+2i', '2i'],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('C' . $row, '=IMPRODUCT(A' . $row . ', B' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Product of %s and %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('C' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMREAL';
|
||||||
|
$description = 'Returns the real coefficient of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMREAL(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The real component of %s is %f radians',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMSEC';
|
||||||
|
$description = 'Returns the secant of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMSEC(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Secant of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMSECH';
|
||||||
|
$description = 'Returns the hyperbolic secant of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMSECH(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Hyperbolic Secant of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMSIN';
|
||||||
|
$description = 'Returns the sine of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMSIN(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Sine of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
|
||||||
|
require __DIR__ . '/../../Header.php';
|
||||||
|
|
||||||
|
$category = 'Engineering';
|
||||||
|
$functionName = 'IMSINH';
|
||||||
|
$description = 'Returns the hyperbolic sine of a complex number in x + yi or x + yj text format';
|
||||||
|
|
||||||
|
$helper->titles($category, $functionName, $description);
|
||||||
|
|
||||||
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
$testData = [
|
||||||
|
['3+4i'],
|
||||||
|
['5-12i'],
|
||||||
|
['3.25+7.5i'],
|
||||||
|
['3.25-12.5i'],
|
||||||
|
['-3.25+7.5i'],
|
||||||
|
['-3.25-7.5i'],
|
||||||
|
['0-j'],
|
||||||
|
['0-2.5j'],
|
||||||
|
['0+j'],
|
||||||
|
['0+1.25j'],
|
||||||
|
[4],
|
||||||
|
[-2.5],
|
||||||
|
];
|
||||||
|
$testDataCount = count($testData);
|
||||||
|
|
||||||
|
$worksheet->fromArray($testData, null, 'A1', true);
|
||||||
|
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('B' . $row, '=IMSINH(A' . $row . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test the formulae
|
||||||
|
for ($row = 1; $row <= $testDataCount; ++$row) {
|
||||||
|
$helper->log(sprintf(
|
||||||
|
'(E%d): The Hyperbolic Sine of %s is %s',
|
||||||
|
$row,
|
||||||
|
$worksheet->getCell('A' . $row)->getValue(),
|
||||||
|
$worksheet->getCell('B' . $row)->getCalculatedValue(),
|
||||||
|
));
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue