Merge branch 'develop' of https://github.com/PHPOffice/PhpSpreadsheet into develop
This commit is contained in:
commit
d576855031
|
@ -0,0 +1,29 @@
|
|||
This is:
|
||||
|
||||
- [ ] a bug report
|
||||
- [ ] a feature request
|
||||
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
|
||||
|
||||
### What is the expected behavior?
|
||||
|
||||
|
||||
### What is the current behavior?
|
||||
|
||||
|
||||
### What are the steps to reproduce?
|
||||
|
||||
Please provide a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) of code that exhibits the issue without relying on an external Excel file or a web server:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
|
||||
// add code that show the issue here...
|
||||
```
|
||||
|
||||
|
||||
### Which versions of PhpSpreadsheet and PHP are affected?
|
|
@ -0,0 +1,14 @@
|
|||
This is:
|
||||
|
||||
- [ ] a bugfix
|
||||
- [ ] a new feature
|
||||
|
||||
Checklist:
|
||||
|
||||
- [ ] Changes are covered by unit tests
|
||||
- [ ] Code style is respected
|
||||
- [ ] Commit message explains **why** the change is made (see https://github.com/erlang/otp/wiki/Writing-good-commit-messages)
|
||||
- [ ] CHANGELOG.md contains a short summary of the change
|
||||
- [ ] Documentation is updated as necessary
|
||||
|
||||
What does it change?
|
|
@ -6,14 +6,11 @@ php:
|
|||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- hhvm
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 7.0
|
||||
env: COVERAGE=1
|
||||
allow_failures:
|
||||
- php: hhvm
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
|
26
CHANGELOG.md
26
CHANGELOG.md
|
@ -1,4 +1,5 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
|
@ -8,20 +9,40 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||
|
||||
### Added
|
||||
|
||||
- Support for chart fill color - @CrazyBite [#158](https://github.com/PHPOffice/PhpSpreadsheet/pull/158)
|
||||
|
||||
### Changed
|
||||
|
||||
- Merge data-validations to reduce written worksheet size - @billblume [#131](https://github.com/PHPOffice/PhpSpreadSheet/issues/131)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Control characters in cell values are automatically escaped [#212](https://github.com/PHPOffice/PhpSpreadsheet/issues/212)
|
||||
|
||||
### BREAKING CHANGE
|
||||
|
||||
- Standardization of array keys used for style, see the [migration guide](./docs/topics/migration-from-PHPExcel.md).
|
||||
|
||||
## [1.0.0-beta] - 2017-08-17
|
||||
|
||||
### Added
|
||||
|
||||
- Initial implementation of SUMIFS() function
|
||||
- Additional codepages
|
||||
- MemoryDrawing not working in HTML writer [#808](https://github.com/PHPOffice/PHPExcel/issues/808)
|
||||
- CSV Reader can auto-detect the separator used in file [#141](https://github.com/PHPOffice/PhpSpreadsheet/pull/141)
|
||||
- HTML Reader supports some basic inline styles [#180](https://github.com/PHPOffice/PhpSpreadsheet/pull/180)
|
||||
|
||||
### Changed
|
||||
|
||||
- Start following [SemVer](http://semver.org) properly.
|
||||
|
||||
### Bugfixes
|
||||
### Fixed
|
||||
|
||||
- Fix to getCell() method when cell reference includes a worksheet reference - @MarkBaker
|
||||
- Ignore inlineStr type if formula element exists - @ncrypthic [#570](https://github.com/PHPOffice/PHPExcel/issues/570)
|
||||
- Excel 2007 Reader freezes because of conditional formatting - @rentalhost [#575](https://github.com/PHPOffice/PHPExcel/issues/575)
|
||||
- Readers will now parse files containing worksheet titles over 31 characters [#176](https://github.com/PHPOffice/PhpSpreadsheet/pull/176)
|
||||
|
||||
### General
|
||||
|
||||
|
@ -35,10 +56,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||
- Introduction of namespaces for all classes, eg: `PHPExcel_Calculation_Functions` becomes `PhpOffice\PhpSpreadsheet\Calculation\Functions`
|
||||
- Some classes were renamed for clarity and/or consistency:
|
||||
|
||||
For a comprehensive list of all class changes, and a semi-automated migration path, read the [migration guide](./docs/Migration-from-PHPExcel.md).
|
||||
For a comprehensive list of all class changes, and a semi-automated migration path, read the [migration guide](./docs/topics/migration-from-PHPExcel.md).
|
||||
|
||||
- Dropped `PHPExcel_Calculation_Functions::VERSION()`. Composer or git should be used to know the version.
|
||||
- Dropped `PHPExcel_Settings::setPdfRenderer()` and `PHPExcel_Settings::setPdfRenderer()`. Composer should be used to autoload PDF libs.
|
||||
- Dropped support for HHVM
|
||||
|
||||
## Previous versions of PHPExcel
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
# Want to contribute?
|
||||
|
||||
If you would like to contribute, here are some notes and guidelines:
|
||||
|
||||
- All new development happens on feature/fix branches referenced with the GitHub issue number, and are then merged to the develop branch; so the develop branch is always the most up-to-date, working code
|
||||
- The master branch only contains tagged releases
|
||||
- If you are going to be submitting a pull request, please fork from develop, and submit your pull request back as a fix/feature branch referencing the GitHub issue number
|
||||
- Code changes must be validated by PHP-CS-Fixer and PHP_CodeSniffer (via `./vendor/bin/php-cs-fixer fix --verbose && ./vendor/bin/phpcs samples/ src/ tests/ --standard=PSR2 -n`)
|
||||
- [Helpful article about forking](https://help.github.com/articles/fork-a-repo/ "Forking a GitHub repository")
|
||||
- [Helpful article about pull requests](https://help.github.com/articles/using-pull-requests/ "Pull Requests")
|
35
README.md
35
README.md
|
@ -16,41 +16,14 @@ Develop:
|
|||
|
||||
PhpSpreadsheet is a library written in pure PHP and providing a set of classes that allow you to read from and to write to different spreadsheet file formats, like Excel and LibreOffice Calc.
|
||||
|
||||
## File formats supported
|
||||
## Documentation
|
||||
|
||||
|Format |Reading|Writing|
|
||||
|--------------------------------------------|:-----:|:-----:|
|
||||
|Open Document Format/OASIS (.ods) | ✓ | ✓ |
|
||||
|Office Open XML (.xlsx) Excel 2007 and above| ✓ | ✓ |
|
||||
|BIFF 8 (.xls) Excel 97 and above | ✓ | ✓ |
|
||||
|BIFF 5 (.xls) Excel 95 | ✓ | |
|
||||
|SpreadsheetML (.xml) Excel 2003 | ✓ | |
|
||||
|Gnumeric | ✓ | |
|
||||
|HTML | ✓ | ✓ |
|
||||
|SYLK | ✓ | |
|
||||
|CSV | ✓ | ✓ |
|
||||
|PDF (using either the tcPDF, DomPDF or mPDF libraries, which need to be installed separately)| | ✓ |
|
||||
Read more about it, including install instructions, in the official documentation, either at the online version:
|
||||
|
||||
## Requirements
|
||||
https://phpspreadsheet.readthedocs.io
|
||||
|
||||
* PHP version 5.6 or higher
|
||||
* PHP extension php_zip enabled
|
||||
* PHP extension php_xml enabled
|
||||
* PHP extension php_gd2 enabled (optional, but required for exact column width autocalculation)
|
||||
Or directly in this repository in the folder `docs/`.
|
||||
|
||||
## PHP version support
|
||||
|
||||
Support for PHP versions will only be maintained for a period of six months beyond the end-of-life of that PHP version
|
||||
|
||||
## Want to contribute?
|
||||
|
||||
If you would like to contribute, here are some notes and guidelines:
|
||||
- All new development happens on feature/fix branches referenced with the GitHub issue number, and are then merged to the develop branch; so the develop branch is always the most up-to-date, working code
|
||||
- The master branch only contains tagged releases
|
||||
- If you are going to be submitting a pull request, please fork from develop, and submit your pull request back as a fix/feature branch referencing the GitHub issue number
|
||||
- Code changes must be validated by PHP-CS-Fixer and PHP_CodeSniffer (via `./vendor/bin/php-cs-fixer fix --verbose && ./vendor/bin/phpcs samples/ src/ tests/ --standard=PSR2 -n`)
|
||||
- [Helpful article about forking](https://help.github.com/articles/fork-a-repo/ "Forking a GitHub repository")
|
||||
- [Helpful article about pull requests](https://help.github.com/articles/using-pull-requests/ "Pull Requests")
|
||||
|
||||
## PHPExcel vs PhpSpreadsheet ?
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
use PhpOffice\PhpSpreadsheet\Helper\Migrator;
|
||||
|
||||
require_once __DIR__ . '/../src/Bootstrap.php';
|
||||
|
||||
$migrator = new \PhpOffice\PhpSpreadsheet\Helper\Migrator();
|
||||
$migrator = new Migrator();
|
||||
$migrator->migrate();
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,11 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>DAVERAGE</h1>
|
||||
<h2>Returns the average of selected database entries.</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
@ -73,7 +73,6 @@ var_dump($criteriaData);
|
|||
|
||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||
echo 'DAVERAGE() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,11 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>DCOUNT</h1>
|
||||
<h2>Counts the cells that contain numbers in a database.</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
@ -73,7 +73,6 @@ var_dump($criteriaData);
|
|||
|
||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||
echo 'DCOUNT() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,11 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>DGET</h1>
|
||||
<h2>Extracts a single value from a column of a list or database that matches conditions that you specify.</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
@ -69,7 +69,6 @@ var_dump($criteriaData);
|
|||
|
||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||
echo 'DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,11 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>DMAX</h1>
|
||||
<h2>Returns the maximum value from selected database entries.</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
@ -72,7 +72,6 @@ var_dump($criteriaData);
|
|||
|
||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||
echo 'DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,11 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>DMIN</h1>
|
||||
<h2>Returns the minimum value from selected database entries.</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
@ -72,7 +72,6 @@ var_dump($criteriaData);
|
|||
|
||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||
echo 'DMIN() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,11 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>DPRODUCT</h1>
|
||||
<h2>Multiplies the values in a column of a list or database that match conditions that you specify.</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
@ -69,7 +69,6 @@ var_dump($criteriaData);
|
|||
|
||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||
echo 'DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,11 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>DSTDEV</h1>
|
||||
<h2>Estimates the standard deviation based on a sample of selected database entries.</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
@ -73,7 +73,6 @@ var_dump($criteriaData);
|
|||
|
||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||
echo 'DSTDEV() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,11 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>DSTDEVP</h1>
|
||||
<h2>Calculates the standard deviation based on the entire population of selected database entries.</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
@ -73,7 +73,6 @@ var_dump($criteriaData);
|
|||
|
||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||
echo 'DSTDEVP() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,11 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>DVAR</h1>
|
||||
<h2>Estimates variance based on a sample from selected database entries.</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
@ -73,7 +73,6 @@ var_dump($criteriaData);
|
|||
|
||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||
echo 'DVAR() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,11 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>DVARP</h1>
|
||||
<h2>Calculates variance based on the entire population of selected database entries,</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
@ -73,7 +73,6 @@ var_dump($criteriaData);
|
|||
|
||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||
echo 'DVARP() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,11 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>DATE</h1>
|
||||
<h2>Returns the serial number of a particular date.</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,11 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>DATEVALUE</h1>
|
||||
<h2>Converts a date in the form of text to a serial number.</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,11 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>TIME</h1>
|
||||
<h2>Returns the serial number of a particular time.</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,11 +19,10 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>TIMEVALUE</h1>
|
||||
<h2>Converts a time in the form of text to a serial number.</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||
|
||||
// Create new PhpSpreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Add some data
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -16,7 +14,6 @@ date_default_timezone_set('Europe/London');
|
|||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
echo '<h1>PhpSpreadsheet Calculation Function Examples</h1>';
|
||||
|
||||
$exampleTypeList = glob('./*', GLOB_ONLYDIR);
|
||||
|
@ -43,7 +40,6 @@ foreach ($exampleTypeList as $exampleType) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -16,20 +17,18 @@ date_default_timezone_set('Europe/London');
|
|||
<body>
|
||||
|
||||
<h1>PhpSpreadsheet Reader Example #01</h1>
|
||||
<h2>Simple File Reader using \PhpOffice\PhpSpreadsheet\IOFactory::load()</h2>
|
||||
<h2>Simple File Reader using IOFactory::load()</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory to identify the format<br />';
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
|
||||
$spreadsheet = IOFactory::load($inputFileName);
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||
var_dump($sheetData);
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,12 +1,13 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Xls;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -20,24 +21,16 @@ require_once __DIR__ . '/../../../src/Bootstrap.php';
|
|||
<h1>PhpSpreadsheet Reader Example #02</h1>
|
||||
<h2>Simple File Reader using a Specified Reader</h2>
|
||||
<?php
|
||||
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using \PhpOffice\PhpSpreadsheet\Reader\Xls<br />';
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls();
|
||||
// $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
|
||||
// $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xml();
|
||||
// $reader = new \PhpOffice\PhpSpreadsheet\Reader\Ods();
|
||||
// $reader = new \PhpOffice\PhpSpreadsheet\Reader\Slk();
|
||||
// $reader = new \PhpOffice\PhpSpreadsheet\Reader\Gnumeric();
|
||||
// $reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv();
|
||||
$reader = new Xls();
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||
var_dump($sheetData);
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -16,29 +17,21 @@ date_default_timezone_set('Europe/London');
|
|||
<body>
|
||||
|
||||
<h1>PhpSpreadsheet Reader Example #03</h1>
|
||||
<h2>Simple File Reader using the \PhpOffice\PhpSpreadsheet\IOFactory to Return a Reader</h2>
|
||||
<h2>Simple File Reader using the IOFactory to Return a Reader</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
// $inputFileType = 'Xml';
|
||||
// $inputFileType = 'Ods';
|
||||
// $inputFileType = 'Slk';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
// $inputFileType = 'Csv';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||
var_dump($sheetData);
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -16,25 +17,23 @@ date_default_timezone_set('Europe/London');
|
|||
<body>
|
||||
|
||||
<h1>PhpSpreadsheet Reader Example #04</h1>
|
||||
<h2>Simple File Reader using the \PhpOffice\PhpSpreadsheet\IOFactory to Identify a Reader to Use</h2>
|
||||
<h2>Simple File Reader using the IOFactory to Identify a Reader to Use</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
$inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($inputFileName);
|
||||
$inputFileType = IOFactory::identify($inputFileName);
|
||||
echo 'File ', pathinfo($inputFileName, PATHINFO_BASENAME), ' has been identified as an ', $inputFileType, ' file<br />';
|
||||
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with the identified reader type<br />';
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||
var_dump($sheetData);
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,18 +19,13 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reader Example #05</h1>
|
||||
<h2>Simple File Reader using the "Read Data Only" Option</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
// $inputFileType = 'Xml';
|
||||
// $inputFileType = 'Ods';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
echo 'Turning Formatting off for Load<br />';
|
||||
$reader->setReadDataOnly(true);
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
@ -38,7 +34,6 @@ echo '<hr />';
|
|||
|
||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||
var_dump($sheetData);
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,18 +19,13 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reader Example #06</h1>
|
||||
<h2>Simple File Reader Loading All WorkSheets</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
// $inputFileType = 'Xml';
|
||||
// $inputFileType = 'Ods';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
echo 'Loading all WorkSheets<br />';
|
||||
$reader->setLoadAllSheets();
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
@ -41,7 +37,6 @@ $loadedSheetNames = $spreadsheet->getSheetNames();
|
|||
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||
echo $sheetIndex, ' -> ', $loadedSheetName, '<br />';
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,19 +19,14 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reader Example #07</h1>
|
||||
<h2>Simple File Reader Loading a Single Named WorkSheet</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
// $inputFileType = 'Xml';
|
||||
// $inputFileType = 'Ods';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
$sheetname = 'Data Sheet #2';
|
||||
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
echo 'Loading Sheet "', $sheetname, '" only<br />';
|
||||
$reader->setLoadSheetsOnly($sheetname);
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
@ -42,7 +38,6 @@ $loadedSheetNames = $spreadsheet->getSheetNames();
|
|||
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||
echo $sheetIndex, ' -> ', $loadedSheetName, '<br />';
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,19 +19,14 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reader Example #08</h1>
|
||||
<h2>Simple File Reader Loading Several Named WorkSheets</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
// $inputFileType = 'Xml';
|
||||
// $inputFileType = 'Ods';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
$sheetnames = ['Data Sheet #1', 'Data Sheet #3'];
|
||||
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
echo 'Loading Sheet', ((count($sheetnames) == 1) ? '' : 's'), ' "', implode('" and "', $sheetnames), '" only<br />';
|
||||
$reader->setLoadSheetsOnly($sheetnames);
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
@ -42,7 +38,6 @@ $loadedSheetNames = $spreadsheet->getSheetNames();
|
|||
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||
echo $sheetIndex, ' -> ', $loadedSheetName, '<br />';
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,18 +20,13 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reader Example #09</h1>
|
||||
<h2>Simple File Reader Using a Read Filter</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
// $inputFileType = 'Xml';
|
||||
// $inputFileType = 'Ods';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
$sheetname = 'Data Sheet #3';
|
||||
|
||||
class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
|
||||
class MyReadFilter implements IReadFilter
|
||||
{
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
{
|
||||
|
@ -42,12 +39,13 @@ class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$filterSubset = new MyReadFilter();
|
||||
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
echo 'Loading Sheet "', $sheetname, '" only<br />';
|
||||
$reader->setLoadSheetsOnly($sheetname);
|
||||
echo 'Loading Sheet using filter<br />';
|
||||
|
@ -58,7 +56,6 @@ echo '<hr />';
|
|||
|
||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||
var_dump($sheetData);
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,23 +20,17 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reader Example #10</h1>
|
||||
<h2>Simple File Reader Using a Configurable Read Filter</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
// $inputFileType = 'Xml';
|
||||
// $inputFileType = 'Ods';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
$sheetname = 'Data Sheet #3';
|
||||
|
||||
class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
|
||||
class MyReadFilter implements IReadFilter
|
||||
{
|
||||
|
||||
private $_startRow = 0;
|
||||
|
||||
private $_endRow = 0;
|
||||
|
||||
private $_columns = [];
|
||||
|
||||
public function __construct($startRow, $endRow, $columns)
|
||||
|
@ -54,12 +50,13 @@ class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$filterSubset = new MyReadFilter(9, 15, range('G', 'K'));
|
||||
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
echo 'Loading Sheet "', $sheetname, '" only<br />';
|
||||
$reader->setLoadSheetsOnly($sheetname);
|
||||
echo 'Loading Sheet using configurable filter<br />';
|
||||
|
@ -70,7 +67,6 @@ echo '<hr />';
|
|||
|
||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||
var_dump($sheetData);
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,21 +20,16 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reader Example #11</h1>
|
||||
<h2>Reading a Workbook in "Chunks" Using a Configurable Read Filter (Version 1)</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
// $inputFileType = 'Xml';
|
||||
// $inputFileType = 'Ods';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example2.xls';
|
||||
|
||||
/** Define a Read Filter class implementing \PhpOffice\PhpSpreadsheet\Reader\IReadFilter */
|
||||
class chunkReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
|
||||
/** Define a Read Filter class implementing IReadFilter */
|
||||
class chunkReadFilter implements IReadFilter
|
||||
{
|
||||
private $_startRow = 0;
|
||||
|
||||
private $_startRow = 0;
|
||||
private $_endRow = 0;
|
||||
|
||||
/**
|
||||
|
@ -56,11 +53,12 @@ class chunkReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||
/* Create a new Reader of the type defined in $inputFileType * */
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
|
@ -83,7 +81,6 @@ for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
|
|||
var_dump($sheetData);
|
||||
echo '<br /><br />';
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,21 +20,16 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reader Example #12</h1>
|
||||
<h2>Reading a Workbook in "Chunks" Using a Configurable Read Filter (Version 2)</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
// $inputFileType = 'Xml';
|
||||
// $inputFileType = 'Ods';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example2.xls';
|
||||
|
||||
/** Define a Read Filter class implementing \PhpOffice\PhpSpreadsheet\Reader\IReadFilter */
|
||||
class chunkReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
|
||||
/** Define a Read Filter class implementing IReadFilter */
|
||||
class chunkReadFilter implements IReadFilter
|
||||
{
|
||||
private $_startRow = 0;
|
||||
|
||||
private $_startRow = 0;
|
||||
private $_endRow = 0;
|
||||
|
||||
/**
|
||||
|
@ -56,11 +53,12 @@ class chunkReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||
/* Create a new Reader of the type defined in $inputFileType * */
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
|
@ -86,7 +84,6 @@ for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
|
|||
var_dump($sheetData);
|
||||
echo '<br /><br />';
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,13 +19,12 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reader Example #13</h1>
|
||||
<h2>Simple File Reader for Multiple CSV Files</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Csv';
|
||||
$inputFileNames = ['./sampleData/example1.csv', './sampleData/example2.csv'];
|
||||
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
$inputFileName = array_shift($inputFileNames);
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' into WorkSheet #1 using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
@ -47,7 +47,6 @@ foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
|||
var_dump($sheetData);
|
||||
echo '<br /><br />';
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,13 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,17 +21,16 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reader Example #14</h1>
|
||||
<h2>Reading a Large CSV file in "Chunks" to split across multiple Worksheets</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Csv';
|
||||
$inputFileName = './sampleData/example2.csv';
|
||||
|
||||
/** Define a Read Filter class implementing \PhpOffice\PhpSpreadsheet\Reader\IReadFilter */
|
||||
class chunkReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
|
||||
/** Define a Read Filter class implementing IReadFilter */
|
||||
class chunkReadFilter implements IReadFilter
|
||||
{
|
||||
private $_startRow = 0;
|
||||
|
||||
private $_startRow = 0;
|
||||
private $_endRow = 0;
|
||||
|
||||
/**
|
||||
|
@ -52,11 +54,12 @@ class chunkReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||
/* Create a new Reader of the type defined in $inputFileType * */
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
|
@ -71,7 +74,7 @@ $reader->setReadFilter($chunkFilter)
|
|||
->setContiguous(true);
|
||||
|
||||
/* Instantiate a new PhpSpreadsheet object manually * */
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
/* Set a sheet index * */
|
||||
$sheet = 0;
|
||||
|
@ -102,7 +105,6 @@ foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
|||
var_dump($sheetData);
|
||||
echo '<br />';
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,15 +20,14 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reader Example #15</h1>
|
||||
<h2>Simple File Reader for Tab-Separated Value File using the Advanced Value Binder</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
\PhpOffice\PhpSpreadsheet\Cell::setValueBinder(new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder());
|
||||
Cell::setValueBinder(new Cell\AdvancedValueBinder());
|
||||
|
||||
$inputFileType = 'Csv';
|
||||
$inputFileName = './sampleData/example1.tsv';
|
||||
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' into WorkSheet #1 using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||
$reader->setDelimiter("\t");
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
@ -63,7 +64,6 @@ foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
|||
var_dump($sheetData);
|
||||
echo '<br />';
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use InvalidArgumentException;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,14 +20,13 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reader Example #16</h1>
|
||||
<h2>Handling Loader Exceptions using Try/Catch</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileName = './sampleData/example_1.xls';
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory to identify the format<br />';
|
||||
try {
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$spreadsheet = IOFactory::load($inputFileName);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage());
|
||||
}
|
||||
|
||||
|
@ -33,7 +34,6 @@ echo '<hr />';
|
|||
|
||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||
var_dump($sheetData);
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,18 +19,13 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reader Example #17</h1>
|
||||
<h2>Simple File Reader Loading Several Named WorkSheets</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
// $inputFileType = 'Xml';
|
||||
// $inputFileType = 'Ods';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
|
||||
/* Read the list of Worksheet Names from the Workbook file * */
|
||||
echo 'Read the list of Worksheets in the WorkBook<br />';
|
||||
|
@ -39,7 +35,6 @@ echo 'There are ',count($worksheetNames),' worksheet',((count($worksheetNames) =
|
|||
foreach ($worksheetNames as $worksheetName) {
|
||||
echo $worksheetName, '<br />';
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,19 +19,14 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reader Example #18</h1>
|
||||
<h2>Reading list of WorkSheets without loading entire file</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
// $inputFileType = 'Xml';
|
||||
// $inputFileType = 'Ods';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' information using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
$worksheetNames = $reader->listWorksheetNames($inputFileName);
|
||||
|
||||
echo '<h3>Worksheet Names</h3>';
|
||||
|
@ -39,7 +35,6 @@ foreach ($worksheetNames as $worksheetName) {
|
|||
echo '<li>', $worksheetName, '</li>';
|
||||
}
|
||||
echo '</ol>';
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,19 +19,14 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reader Example #19</h1>
|
||||
<h2>Reading WorkSheet information without loading entire file</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
// $inputFileType = 'Xlsx';
|
||||
// $inputFileType = 'Xml';
|
||||
// $inputFileType = 'Ods';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' information using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
$worksheetData = $reader->listWorksheetInfo($inputFileName);
|
||||
|
||||
echo '<h3>Worksheet Information</h3>';
|
||||
|
@ -42,7 +38,6 @@ foreach ($worksheetData as $worksheet) {
|
|||
echo '</li>';
|
||||
}
|
||||
echo '</ol>';
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,14 +19,13 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reading WorkBook Data Example #01</h1>
|
||||
<h2>Read the WorkBook Properties</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
/* Create a new Reader of the type defined in $inputFileType * */
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
/* Load $inputFileName to a PhpSpreadsheet Object * */
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
||||
|
@ -80,7 +80,6 @@ echo '<b>Company: </b>',$company,'<br />';
|
|||
/* Read the workbook manager property * */
|
||||
$manager = $spreadsheet->getProperties()->getManager();
|
||||
echo '<b>Manager: </b>', $manager, '<br />';
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,14 +19,13 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reading WorkBook Data Example #02</h1>
|
||||
<h2>Read a list of Custom Properties for a WorkBook</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xlsx';
|
||||
$inputFileName = './sampleData/example1.xlsx';
|
||||
|
||||
/* Create a new Reader of the type defined in $inputFileType * */
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
/* Load $inputFileName to a PhpSpreadsheet Object * */
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
||||
|
@ -38,7 +38,6 @@ echo '<b>Custom Property names: </b><br />';
|
|||
foreach ($customPropertyList as $customPropertyName) {
|
||||
echo $customPropertyName, '<br />';
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,14 +19,13 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reading WorkBook Data Example #03</h1>
|
||||
<h2>Read Custom Property Values for a WorkBook</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xlsx';
|
||||
$inputFileName = './sampleData/example1.xlsx';
|
||||
|
||||
/* Create a new Reader of the type defined in $inputFileType * */
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
/* Load $inputFileName to a PhpSpreadsheet Object * */
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
||||
|
@ -66,7 +66,6 @@ foreach ($customPropertyList as $customPropertyName) {
|
|||
|
||||
echo $propertyValue, ' (', $propertyType, ')<br />';
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -18,14 +19,13 @@ date_default_timezone_set('Europe/London');
|
|||
<h1>PhpSpreadsheet Reading WorkBook Data Example #04</h1>
|
||||
<h2>Get a List of the Worksheets in a WorkBook</h2>
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
$inputFileName = './sampleData/example2.xls';
|
||||
|
||||
/* Create a new Reader of the type defined in $inputFileType * */
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
/* Load $inputFileName to a PhpSpreadsheet Object * */
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
||||
|
@ -42,7 +42,6 @@ $sheetNames = $spreadsheet->getSheetNames();
|
|||
foreach ($sheetNames as $sheetIndex => $sheetName) {
|
||||
echo 'WorkSheet #', $sheetIndex, ' is named "', $sheetName, '"<br />';
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -16,7 +14,6 @@ date_default_timezone_set('Europe/London');
|
|||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
$exampleTypeList = glob('./*', GLOB_ONLYDIR);
|
||||
|
||||
foreach ($exampleTypeList as $exampleType) {
|
||||
|
@ -42,7 +39,6 @@ foreach ($exampleTypeList as $exampleType) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
|
@ -0,0 +1,8 @@
|
|||
/* Make the huge table always visible */
|
||||
table.features-cross-reference {
|
||||
overflow: visible !important;
|
||||
}
|
||||
.rst-content table.features-cross-reference.docutils th,
|
||||
.rst-content table.features-cross-reference.docutils td {
|
||||
background-color: white;
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
var nodemcu = nodemcu || {};
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
$(document).ready(function () {
|
||||
fixSearch();
|
||||
});
|
||||
|
||||
/*
|
||||
* RTD messes up MkDocs' search feature by tinkering with the search box defined in the theme, see
|
||||
* https://github.com/rtfd/readthedocs.org/issues/1088. This function sets up a DOM4 MutationObserver
|
||||
* to react to changes to the search form (triggered by RTD on doc ready). It then reverts everything
|
||||
* the RTD JS code modified.
|
||||
*/
|
||||
function fixSearch() {
|
||||
var target = document.getElementById('rtd-search-form');
|
||||
var config = {attributes: true, childList: true};
|
||||
|
||||
var observer = new MutationObserver(function (mutations) {
|
||||
// if it isn't disconnected it'll loop infinitely because the observed element is modified
|
||||
observer.disconnect();
|
||||
var form = $('#rtd-search-form');
|
||||
form.empty();
|
||||
form.attr('action', 'https://' + window.location.hostname + '/en/' + determineSelectedBranch() + '/search.html');
|
||||
$('<input>').attr({
|
||||
type: "text",
|
||||
name: "q",
|
||||
placeholder: "Search docs"
|
||||
}).appendTo(form);
|
||||
});
|
||||
|
||||
if (window.location.origin.indexOf('readthedocs') > -1) {
|
||||
observer.observe(target, config);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyzes the URL of the current page to find out what the selected GitHub branch is. It's usually
|
||||
* part of the location path. The code needs to distinguish between running MkDocs standalone
|
||||
* and docs served from RTD. If no valid branch could be determined 'dev' returned.
|
||||
*
|
||||
* @returns GitHub branch name
|
||||
*/
|
||||
function determineSelectedBranch() {
|
||||
var branch = 'dev', path = window.location.pathname;
|
||||
if (window.location.origin.indexOf('readthedocs') > -1) {
|
||||
// path is like /en/<branch>/<lang>/build/ -> extract 'lang'
|
||||
// split[0] is an '' because the path starts with the separator
|
||||
var thirdPathSegment = path.split('/')[2];
|
||||
// 'latest' is an alias on RTD for the 'dev' branch - which is the default for 'branch' here
|
||||
if (thirdPathSegment !== 'latest') {
|
||||
branch = thirdPathSegment;
|
||||
}
|
||||
}
|
||||
return branch;
|
||||
}
|
||||
}());
|
|
@ -6,6 +6,21 @@ PhpSpreadsheet is a library written in pure PHP and providing a set of
|
|||
classes that allow you to read from and to write to different
|
||||
spreadsheet file formats, like Excel and LibreOffice Calc.
|
||||
|
||||
## File formats supported
|
||||
|
||||
|Format |Reading|Writing|
|
||||
|--------------------------------------------|:-----:|:-----:|
|
||||
|Open Document Format/OASIS (.ods) | ✓ | ✓ |
|
||||
|Office Open XML (.xlsx) Excel 2007 and above| ✓ | ✓ |
|
||||
|BIFF 8 (.xls) Excel 97 and above | ✓ | ✓ |
|
||||
|BIFF 5 (.xls) Excel 95 | ✓ | |
|
||||
|SpreadsheetML (.xml) Excel 2003 | ✓ | |
|
||||
|Gnumeric | ✓ | |
|
||||
|HTML | ✓ | ✓ |
|
||||
|SYLK | ✓ | |
|
||||
|CSV | ✓ | ✓ |
|
||||
|PDF (using either the tcPDF, DomPDF or mPDF libraries, which need to be installed separately)| | ✓ |
|
||||
|
||||
# Getting started
|
||||
|
||||
## Software requirements
|
||||
|
@ -17,6 +32,10 @@ The following software is required to develop using PhpSpreadsheet:
|
|||
- PHP extension php\_xml enabled
|
||||
- PHP extension php\_gd2 enabled (if not compiled in)
|
||||
|
||||
### PHP version support
|
||||
|
||||
Support for PHP versions will only be maintained for a period of six months beyond the end-of-life of that PHP version
|
||||
|
||||
## Installation
|
||||
|
||||
Use [composer](https://getcomposer.org/) to install PhpSpreadsheet into your project:
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
- <span style="text-align: center; color: red;">✖</span> Not supported
|
||||
- N/A Cannot be supported
|
||||
|
||||
<table>
|
||||
<table class="features-cross-reference">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th colspan="7">Readers</th>
|
||||
|
@ -906,7 +906,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td style="text-align: center; color: orange;">●</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
|
|
@ -90,7 +90,7 @@ calculated values, or force recalculation in Excel2003.
|
|||
### Excel functions that return a Date and Time value
|
||||
|
||||
Any of the Date and Time functions that return a date value in Excel can
|
||||
return either an Excel timestamp or a PHP timestamp or date object.
|
||||
return either an Excel timestamp or a PHP timestamp or `DateTime` object.
|
||||
|
||||
It is possible for scripts to change the data type used for returning
|
||||
date values by calling the
|
||||
|
@ -117,11 +117,11 @@ method can be used to determine the current value of this setting:
|
|||
$returnDateType = \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType();
|
||||
```
|
||||
|
||||
The default is RETURNDATE\_PHP\_NUMERIC.
|
||||
The default is `RETURNDATE_PHP_NUMERIC`.
|
||||
|
||||
#### PHP Timestamps
|
||||
|
||||
If RETURNDATE\_PHP\_NUMERIC is set for the Return Date Type, then any
|
||||
If `RETURNDATE_PHP_NUMERIC` is set for the Return Date Type, then any
|
||||
date value returned to the calling script by any access to the Date and
|
||||
Time functions in Excel will be an integer value that represents the
|
||||
number of seconds from the PHP/Unix base date. The PHP/Unix base date
|
||||
|
@ -131,15 +131,15 @@ while a value of +3600 would be 01:00 hrs on 1st January 1970. This
|
|||
gives PHP a date range of between 14th December 1901 and 19th January
|
||||
2038.
|
||||
|
||||
#### PHP DateTime Objects
|
||||
#### PHP `DateTime` Objects
|
||||
|
||||
If the Return Date Type is set for RETURNDATE\_PHP\_NUMERIC, then any
|
||||
If the Return Date Type is set for `RETURNDATE_PHP_OBJECT`, then any
|
||||
date value returned to the calling script by any access to the Date and
|
||||
Time functions in Excel will be a PHP date/time object.
|
||||
Time functions in Excel will be a PHP `DateTime` object.
|
||||
|
||||
#### Excel Timestamps
|
||||
|
||||
If RETURNDATE\_EXCEL is set for the Return Date Type, then the returned
|
||||
If `RETURNDATE_EXCEL` is set for the Return Date Type, then the returned
|
||||
date value by any access to the Date and Time functions in Excel will be
|
||||
a floating point value that represents a number of days from the Excel
|
||||
base date. The Excel base date is determined by which calendar Excel
|
||||
|
@ -157,8 +157,8 @@ Excel date values by calling the
|
|||
|
||||
where the following constants can be used for `$baseDate`:
|
||||
|
||||
- \PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR\_WINDOWS\_1900
|
||||
- \PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR\_MAC\_1904
|
||||
- `\PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR_WINDOWS_1900`
|
||||
- `\PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR_MAC_1904`
|
||||
|
||||
The method will return a Boolean True on success, False on failure (e.g.
|
||||
if an invalid value is passed in).
|
||||
|
@ -170,7 +170,7 @@ be used to determine the current value of this setting:
|
|||
$baseDate = \PhpOffice\PhpSpreadsheet\Shared\Date::getExcelCalendar();
|
||||
```
|
||||
|
||||
The default is CALENDAR\_WINDOWS\_1900.
|
||||
The default is `CALENDAR_WINDOWS_1900`.
|
||||
|
||||
#### Functions that return a Date/Time Value
|
||||
|
||||
|
@ -186,15 +186,15 @@ The default is CALENDAR\_WINDOWS\_1900.
|
|||
### Excel functions that accept Date and Time values as parameters
|
||||
|
||||
Date values passed in as parameters to a function can be an Excel
|
||||
timestamp or a PHP timestamp; or date object; or a string containing a
|
||||
timestamp or a PHP timestamp; or `DateTime` object; or a string containing a
|
||||
date value (e.g. '1-Jan-2009'). PhpSpreadsheet will attempt to identify
|
||||
their type based on the PHP datatype:
|
||||
|
||||
An integer numeric value will be treated as a PHP/Unix timestamp. A real
|
||||
(floating point) numeric value will be treated as an Excel
|
||||
date/timestamp. Any PHP DateTime object will be treated as a DateTime
|
||||
date/timestamp. Any PHP `DateTime` object will be treated as a `DateTime`
|
||||
object. Any string value (even one containing straight numeric data)
|
||||
will be converted to a date/time object for validation as a date value
|
||||
will be converted to a `DateTime` object for validation as a date value
|
||||
based on the server locale settings, so passing through an ambiguous
|
||||
value of '07/08/2008' will be treated as 7th August 2008 if your server
|
||||
settings are UK, but as 8th July 2008 if your server settings are US.
|
||||
|
@ -202,7 +202,7 @@ However, if you pass through a value such as '31/12/2008' that would be
|
|||
considered an error by a US-based server, but which is not ambiguous,
|
||||
then PhpSpreadsheet will attempt to correct this to 31st December 2008.
|
||||
If the content of the string doesn’t match any of the formats recognised
|
||||
by the php date/time object implementation of `strtotime()` (which can
|
||||
by the php `DateTime` object implementation of `strtotime()` (which can
|
||||
handle a wider range of formats than the normal `strtotime()` function),
|
||||
then the function will return a `#VALUE` error. However, Excel
|
||||
recommends that you should always use date/timestamps for your date
|
||||
|
@ -213,7 +213,7 @@ The same principle applies when data is being written to Excel. Cells
|
|||
containing date actual values (rather than Excel functions that return a
|
||||
date value) are always written as Excel dates, converting where
|
||||
necessary. If a cell formatted as a date contains an integer or
|
||||
date/time object value, then it is converted to an Excel value for
|
||||
`DateTime` object value, then it is converted to an Excel value for
|
||||
writing: if a cell formatted as a date contains a real value, then no
|
||||
conversion is required. Note that string values are written as strings
|
||||
rather than converted to Excel date timestamp values.
|
||||
|
@ -243,7 +243,7 @@ number of other methods are available in the
|
|||
\PhpOffice\PhpSpreadsheet\Shared\Date class that can help when working
|
||||
with dates:
|
||||
|
||||
#### \PhpOffice\PhpSpreadsheet\Shared\Date::ExcelToPHP($excelDate)
|
||||
#### \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($excelDate)
|
||||
|
||||
Converts a date/time from an Excel date timestamp to return a PHP
|
||||
serialized date/timestamp.
|
||||
|
@ -251,17 +251,17 @@ serialized date/timestamp.
|
|||
Note that this method does not trap for Excel dates that fall outside of
|
||||
the valid range for a PHP date timestamp.
|
||||
|
||||
#### \PhpOffice\PhpSpreadsheet\Shared\Date::ExcelToPHPObject($excelDate)
|
||||
#### \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($excelDate)
|
||||
|
||||
Converts a date from an Excel date/timestamp to return a PHP DateTime
|
||||
Converts a date from an Excel date/timestamp to return a PHP `DateTime`
|
||||
object.
|
||||
|
||||
#### \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($PHPDate)
|
||||
|
||||
Converts a PHP serialized date/timestamp or a PHP DateTime object to
|
||||
Converts a PHP serialized date/timestamp or a PHP `DateTime` object to
|
||||
return an Excel date timestamp.
|
||||
|
||||
#### \PhpOffice\PhpSpreadsheet\Shared\Date::FormattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0)
|
||||
#### \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0)
|
||||
|
||||
Takes year, month and day values (and optional hour, minute and second
|
||||
values) and returns an Excel date timestamp value.
|
||||
|
@ -979,7 +979,7 @@ Excel and in PHP.
|
|||
|
||||
#### DATE
|
||||
|
||||
The DATE function returns an Excel timestamp or a PHP timestamp or date
|
||||
The DATE function returns an Excel timestamp or a PHP timestamp or `DateTime`
|
||||
object representing the date that is referenced by the parameters.
|
||||
|
||||
##### Syntax
|
||||
|
@ -1025,7 +1025,7 @@ February 27, 2008.
|
|||
|
||||
**mixed** A date/time stamp that corresponds to the given date.
|
||||
|
||||
This could be a PHP timestamp value (integer), a PHP date/time object,
|
||||
This could be a PHP timestamp value (integer), a PHP `DateTime` object,
|
||||
or an Excel timestamp value (real), depending on the value of
|
||||
\PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType().
|
||||
|
||||
|
@ -1093,12 +1093,12 @@ variety of different intervals, such number of years, months, or days.
|
|||
|
||||
**date1** First Date.
|
||||
|
||||
An Excel date value, PHP date timestamp, PHP date object, or a date
|
||||
An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date
|
||||
represented as a string.
|
||||
|
||||
**date2** Second Date.
|
||||
|
||||
An Excel date value, PHP date timestamp, PHP date object, or a date
|
||||
An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date
|
||||
represented as a string.
|
||||
|
||||
**unit** The interval type to use for the calculation
|
||||
|
@ -1230,7 +1230,7 @@ A string, representing a date value.
|
|||
|
||||
**mixed** A date/time stamp that corresponds to the given date.
|
||||
|
||||
This could be a PHP timestamp value (integer), a PHP date/time object,
|
||||
This could be a PHP timestamp value (integer), a PHP `DateTime` object,
|
||||
or an Excel timestamp value (real), depending on the value of
|
||||
\PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType().
|
||||
|
||||
|
@ -1290,7 +1290,7 @@ $retVal = call_user_func_array(
|
|||
|
||||
##### Notes
|
||||
|
||||
DATEVALUE uses the php date/time object implementation of `strtotime()`
|
||||
DATEVALUE uses the php `DateTime` object implementation of `strtotime()`
|
||||
(which can handle a wider range of formats than the normal `strtotime()`
|
||||
function), and it is also called for any date parameter passed to other
|
||||
date functions (such as DATEDIF) when the parameter value is a string.
|
||||
|
@ -1317,7 +1317,7 @@ integer ranging from 1 to 31.
|
|||
|
||||
**datetime** Date.
|
||||
|
||||
An Excel date value, PHP date timestamp, PHP date object, or a date
|
||||
An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date
|
||||
represented as a string.
|
||||
|
||||
##### Return Value
|
||||
|
@ -1371,12 +1371,12 @@ accounting systems.
|
|||
|
||||
**date1** First Date.
|
||||
|
||||
An Excel date value, PHP date timestamp, PHP date object, or a date
|
||||
An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date
|
||||
represented as a string.
|
||||
|
||||
**date2** Second Date.
|
||||
|
||||
An Excel date value, PHP date timestamp, PHP date object, or a date
|
||||
An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date
|
||||
represented as a string.
|
||||
|
||||
**method** A boolean flag (TRUE or FALSE)
|
||||
|
@ -1453,7 +1453,7 @@ Excel `TRUE()` and `FALSE()` functions are used instead.
|
|||
|
||||
#### EDATE
|
||||
|
||||
The EDATE function returns an Excel timestamp or a PHP timestamp or date
|
||||
The EDATE function returns an Excel timestamp or a PHP timestamp or `DateTime`
|
||||
object representing the date that is the indicated number of months
|
||||
before or after a specified date (the start\_date). Use EDATE to
|
||||
calculate maturity dates or due dates that fall on the same day of the
|
||||
|
@ -1467,7 +1467,7 @@ month as the date of issue.
|
|||
|
||||
**baseDate** Start Date.
|
||||
|
||||
An Excel date value, PHP date timestamp, PHP date object, or a date
|
||||
An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date
|
||||
represented as a string.
|
||||
|
||||
**months** Number of months to add.
|
||||
|
@ -1480,7 +1480,7 @@ value yields a past date.
|
|||
|
||||
**mixed** A date/time stamp that corresponds to the basedate + months.
|
||||
|
||||
This could be a PHP timestamp value (integer), a PHP date/time object,
|
||||
This could be a PHP timestamp value (integer), a PHP `DateTime` object,
|
||||
or an Excel timestamp value (real), depending on the value of
|
||||
\PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType().
|
||||
|
||||
|
@ -1526,7 +1526,7 @@ the Analysis ToolPak.
|
|||
#### EOMONTH
|
||||
|
||||
The EOMONTH function returns an Excel timestamp or a PHP timestamp or
|
||||
date object representing the date of the last day of the month that is
|
||||
`DateTime` object representing the date of the last day of the month that is
|
||||
the indicated number of months before or after a specified date (the
|
||||
start\_date). Use EOMONTH to calculate maturity dates or due dates that
|
||||
fall on the last day of the month.
|
||||
|
@ -1539,7 +1539,7 @@ fall on the last day of the month.
|
|||
|
||||
**baseDate** Start Date.
|
||||
|
||||
An Excel date value, PHP date timestamp, PHP date object, or a date
|
||||
An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date
|
||||
represented as a string.
|
||||
|
||||
**months** Number of months to add.
|
||||
|
@ -1553,7 +1553,7 @@ value yields a past date.
|
|||
**mixed** A date/time stamp that corresponds to the last day of basedate
|
||||
+ months.
|
||||
|
||||
This could be a PHP timestamp value (integer), a PHP date/time object,
|
||||
This could be a PHP timestamp value (integer), a PHP `DateTime` object,
|
||||
or an Excel timestamp value (real), depending on the value of
|
||||
\PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType().
|
||||
|
||||
|
@ -1607,7 +1607,7 @@ an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.).
|
|||
|
||||
**datetime** Time.
|
||||
|
||||
An Excel date/time value, PHP date timestamp, PHP date object, or a
|
||||
An Excel date/time value, PHP date timestamp, PHP `DateTime` object, or a
|
||||
date/time represented as a string.
|
||||
|
||||
##### Return Value
|
||||
|
@ -1665,7 +1665,7 @@ given as an integer, ranging from 0 to 59.
|
|||
|
||||
**datetime** Time.
|
||||
|
||||
An Excel date/time value, PHP date timestamp, PHP date object, or a
|
||||
An Excel date/time value, PHP date timestamp, PHP `DateTime` object, or a
|
||||
date/time represented as a string.
|
||||
|
||||
##### Return Value
|
||||
|
@ -1723,7 +1723,7 @@ integer ranging from 1 to 12.
|
|||
|
||||
**datetime** Date.
|
||||
|
||||
An Excel date value, PHP date timestamp, PHP date object, or a date
|
||||
An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date
|
||||
represented as a string.
|
||||
|
||||
##### Return Value
|
||||
|
@ -1779,12 +1779,12 @@ a specific term.
|
|||
|
||||
**startDate** Start Date of the period.
|
||||
|
||||
An Excel date value, PHP date timestamp, PHP date object, or a date
|
||||
An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date
|
||||
represented as a string.
|
||||
|
||||
**endDate** End Date of the period.
|
||||
|
||||
An Excel date value, PHP date timestamp, PHP date object, or a date
|
||||
An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date
|
||||
represented as a string.
|
||||
|
||||
**holidays** Optional array of Holiday dates.
|
||||
|
@ -1831,7 +1831,7 @@ There are no parameters for the `NOW()` function.
|
|||
**mixed** A date/time stamp that corresponds to the current date and
|
||||
time.
|
||||
|
||||
This could be a PHP timestamp value (integer), a PHP date/time object,
|
||||
This could be a PHP timestamp value (integer), a PHP `DateTime` object,
|
||||
or an Excel timestamp value (real), depending on the value of
|
||||
\PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType().
|
||||
|
||||
|
@ -1862,7 +1862,7 @@ given as an integer, ranging from 0 to 59.
|
|||
|
||||
**datetime** Time.
|
||||
|
||||
An Excel date/time value, PHP date timestamp, PHP date object, or a
|
||||
An Excel date/time value, PHP date timestamp, PHP `DateTime` object, or a
|
||||
date/time represented as a string.
|
||||
|
||||
##### Return Value
|
||||
|
@ -1934,7 +1934,7 @@ modified to return a value between 0 and 6.
|
|||
|
||||
**datetime** Date.
|
||||
|
||||
An Excel date value, PHP date timestamp, PHP date object, or a date
|
||||
An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date
|
||||
represented as a string.
|
||||
|
||||
**method** An integer flag (values 0, 1 or 2)
|
||||
|
@ -2012,7 +2012,7 @@ The YEAR function returns the year of a date.
|
|||
|
||||
**datetime** Date.
|
||||
|
||||
An Excel date value, PHP date timestamp, PHP date object, or a date
|
||||
An Excel date value, PHP date timestamp, PHP `DateTime` object, or a date
|
||||
represented as a string.
|
||||
|
||||
##### Return Value
|
||||
|
|
|
@ -192,3 +192,74 @@ $cell = $worksheet->setCellValue('A1', 'value', true);
|
|||
// After
|
||||
$cell = $worksheet->getCell('A1')->setValue('value');
|
||||
```
|
||||
|
||||
## Standardized keys for styling
|
||||
|
||||
Array keys used for styling have been standardized for a more coherent experience.
|
||||
It now uses the same wording and casing as the getter and setter:
|
||||
|
||||
```php
|
||||
// Before
|
||||
$style = [
|
||||
'numberformat' => [
|
||||
'code' => NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE,
|
||||
],
|
||||
'font' => [
|
||||
'strike' => true,
|
||||
'superScript' => true,
|
||||
'subScript' => true,
|
||||
],
|
||||
'alignment' => [
|
||||
'rotation' => 90,
|
||||
'readorder' => Alignment::READORDER_RTL,
|
||||
'wrap' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'diagonaldirection' => Borders::DIAGONAL_BOTH,
|
||||
'allborders' => [
|
||||
'style' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
'fill' => [
|
||||
'type' => Fill::FILL_GRADIENT_LINEAR,
|
||||
'startcolor' => [
|
||||
'argb' => 'FFA0A0A0',
|
||||
],
|
||||
'endcolor' => [
|
||||
'argb' => 'FFFFFFFF',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// After
|
||||
$style = [
|
||||
'numberFormat' => [
|
||||
'formatCode' => NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE,
|
||||
],
|
||||
'font' => [
|
||||
'strikethrough' => true,
|
||||
'superscript' => true,
|
||||
'subscript' => true,
|
||||
],
|
||||
'alignment' => [
|
||||
'textRotation' => 90,
|
||||
'readOrder' => Alignment::READORDER_RTL,
|
||||
'wrapText' => true,
|
||||
],
|
||||
'borders' => [
|
||||
'diagonalDirection' => Borders::DIAGONAL_BOTH,
|
||||
'allBorders' => [
|
||||
'borderStyle' => Border::BORDER_THIN,
|
||||
],
|
||||
],
|
||||
'fill' => [
|
||||
'fillType' => Fill::FILL_GRADIENT_LINEAR,
|
||||
'startColor' => [
|
||||
'argb' => 'FFA0A0A0',
|
||||
],
|
||||
'endColor' => [
|
||||
'argb' => 'FFFFFFFF',
|
||||
],
|
||||
],
|
||||
];
|
||||
```
|
||||
|
|
|
@ -558,16 +558,16 @@ $styleArray = array(
|
|||
),
|
||||
'borders' => array(
|
||||
'top' => array(
|
||||
'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
|
||||
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
|
||||
),
|
||||
),
|
||||
'fill' => array(
|
||||
'type' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
|
||||
'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
|
||||
'rotation' => 90,
|
||||
'startcolor' => array(
|
||||
'startColor' => array(
|
||||
'argb' => 'FFA0A0A0',
|
||||
),
|
||||
'endcolor' => array(
|
||||
'endColor' => array(
|
||||
'argb' => 'FFFFFFFF',
|
||||
),
|
||||
),
|
||||
|
@ -693,7 +693,7 @@ B2:G8.
|
|||
$styleArray = array(
|
||||
'borders' => array(
|
||||
'outline' => array(
|
||||
'style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
|
||||
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
|
||||
'color' => array('argb' => 'FFFF0000'),
|
||||
),
|
||||
),
|
||||
|
@ -721,7 +721,7 @@ operating on a single cell at a time:
|
|||
Additional shortcut borders come in handy like in the example above.
|
||||
These are the shortcut borders available:
|
||||
|
||||
- allborders
|
||||
- allBorders
|
||||
- outline
|
||||
- inside
|
||||
- vertical
|
||||
|
@ -731,10 +731,10 @@ An overview of all border shortcuts can be seen in the following image:
|
|||
|
||||
![08-styling-border-options.png](./images/08-styling-border-options.png)
|
||||
|
||||
If you simultaneously set e.g. allborders and vertical, then we have
|
||||
If you simultaneously set e.g. allBorders and vertical, then we have
|
||||
"overlapping" borders, and one of the components has to win over the
|
||||
other where there is border overlap. In PhpSpreadsheet, from weakest to
|
||||
strongest borders, the list is as follows: allborders, outline/inside,
|
||||
strongest borders, the list is as follows: allBorders, outline/inside,
|
||||
vertical/horizontal, left/right/top/bottom/diagonal.
|
||||
|
||||
This border hierarchy can be utilized to achieve various effects in an
|
||||
|
@ -757,17 +757,17 @@ fill | getFill()
|
|||
font | getFont()
|
||||
borders | getBorders()
|
||||
alignment | getAlignment()
|
||||
numberformat | getNumberFormat()
|
||||
numberFormat | getNumberFormat()
|
||||
protection | getProtection()
|
||||
|
||||
**\PhpOffice\PhpSpreadsheet\Style\Fill**
|
||||
|
||||
Array key | Maps to property
|
||||
-----------|-------------------
|
||||
type | setFillType()
|
||||
fillType | setFillType()
|
||||
rotation | setRotation()
|
||||
startcolor | getStartColor()
|
||||
endcolor | getEndColor()
|
||||
startColor | getStartColor()
|
||||
endColor | getEndColor()
|
||||
color | getStartColor()
|
||||
|
||||
|
||||
|
@ -779,17 +779,17 @@ name | setName()
|
|||
bold | setBold()
|
||||
italic | setItalic()
|
||||
underline | setUnderline()
|
||||
strike | setStrikethrough()
|
||||
strikethrough | setStrikethrough()
|
||||
color | getColor()
|
||||
size | setSize()
|
||||
superScript | setSuperScript()
|
||||
subScript | setSubScript()
|
||||
superscript | setSuperscript()
|
||||
subscript | setSubscript()
|
||||
|
||||
**\PhpOffice\PhpSpreadsheet\Style\Borders**
|
||||
|
||||
Array key | Maps to property
|
||||
------------------|-------------------
|
||||
allborders | getLeft(); getRight(); getTop(); getBottom()
|
||||
allBorders | getLeft(); getRight(); getTop(); getBottom()
|
||||
left | getLeft()
|
||||
right | getRight()
|
||||
top | getTop()
|
||||
|
@ -797,7 +797,7 @@ bottom | getBottom()
|
|||
diagonal | getDiagonal()
|
||||
vertical | getVertical()
|
||||
horizontal | getHorizontal()
|
||||
diagonaldirection | setDiagonalDirection()
|
||||
diagonalDirection | setDiagonalDirection()
|
||||
outline | setOutline()
|
||||
|
||||
**\PhpOffice\PhpSpreadsheet\Style\Border**
|
||||
|
@ -813,8 +813,8 @@ Array key | Maps to property
|
|||
------------|-------------------
|
||||
horizontal | setHorizontal()
|
||||
vertical | setVertical()
|
||||
rotation | setTextRotation()
|
||||
wrap | setWrapText()
|
||||
textRotation| setTextRotation()
|
||||
wrapText | setWrapText()
|
||||
shrinkToFit | setShrinkToFit()
|
||||
indent | setIndent()
|
||||
|
||||
|
@ -822,7 +822,7 @@ indent | setIndent()
|
|||
|
||||
Array key | Maps to property
|
||||
----------|-------------------
|
||||
code | setFormatCode()
|
||||
formatCode | setFormatCode()
|
||||
|
||||
**\PhpOffice\PhpSpreadsheet\Style\Protection**
|
||||
|
||||
|
@ -910,15 +910,18 @@ practice...
|
|||
|
||||
## Setting security on a spreadsheet
|
||||
|
||||
Excel offers 3 levels of "protection": document security, sheet security
|
||||
and cell security.
|
||||
Excel offers 3 levels of "protection":
|
||||
|
||||
Document security allows you to set a password on a complete
|
||||
- Document: allows you to set a password on a complete
|
||||
spreadsheet, allowing changes to be made only when that password is
|
||||
entered.Worksheet security offers other security options: you can
|
||||
disallow inserting rows on a specific sheet, disallow sorting, ... Cell
|
||||
security offers the option to lock/unlock a cell as well as show/hide
|
||||
the internal formulaAn example on setting document security:
|
||||
entered.
|
||||
- Worksheet: offers other security options: you can
|
||||
disallow inserting rows on a specific sheet, disallow sorting, ...
|
||||
- Cell: offers the option to lock/unlock a cell as well as show/hide
|
||||
the internal formula.
|
||||
|
||||
|
||||
An example on setting document security:
|
||||
|
||||
``` php
|
||||
$spreadsheet->getSecurity()->setLockWindows(true);
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
site_name: PhpSpreadsheet Documentation
|
||||
repo_url: https://github.com/PHPOffice/phpspreadsheet
|
||||
edit_uri: edit/develop/docs/
|
||||
|
||||
theme: readthedocs
|
||||
extra_css:
|
||||
- extra/extra.css
|
||||
|
||||
extra_javascript:
|
||||
- extra/extra.js
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Helper\Sample;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
require_once __DIR__ . '/../src/Bootstrap.php';
|
||||
|
||||
$helper = new \PhpOffice\PhpSpreadsheet\Helper\Sample();
|
||||
$helper = new Sample();
|
||||
if ($helper->isCli()) {
|
||||
echo 'This example should only be run from a Web Browser' . PHP_EOL;
|
||||
|
||||
|
@ -10,7 +14,7 @@ if ($helper->isCli()) {
|
|||
}
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$spreadsheet->getProperties()->setCreator('Maarten Balliauw')
|
||||
|
@ -52,6 +56,6 @@ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modifie
|
|||
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
|
||||
header('Pragma: public'); // HTTP/1.0
|
||||
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Ods');
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Ods');
|
||||
$writer->save('php://output');
|
||||
exit;
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Helper\Sample;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
require_once __DIR__ . '/../src/Bootstrap.php';
|
||||
|
||||
$helper = new \PhpOffice\PhpSpreadsheet\Helper\Sample();
|
||||
$helper = new Sample();
|
||||
if ($helper->isCli()) {
|
||||
echo 'This example should only be run from a Web Browser' . PHP_EOL;
|
||||
|
||||
|
@ -12,11 +17,11 @@ if ($helper->isCli()) {
|
|||
// Change these values to select the Rendering library that you wish to use
|
||||
// and its directory location on your server
|
||||
//$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_TCPDF;
|
||||
$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_MPDF;
|
||||
$rendererName = Settings::PDF_RENDERER_MPDF;
|
||||
//$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_DOMPDF;
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$spreadsheet->getProperties()->setCreator('Maarten Balliauw')
|
||||
|
@ -46,13 +51,13 @@ $spreadsheet->getActiveSheet()->setShowGridLines(false);
|
|||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$spreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setPdfRendererName($rendererName);
|
||||
Settings::setPdfRendererName($rendererName);
|
||||
|
||||
// Redirect output to a client’s web browser (PDF)
|
||||
header('Content-Type: application/pdf');
|
||||
header('Content-Disposition: attachment;filename="01simple.pdf"');
|
||||
header('Cache-Control: max-age=0');
|
||||
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Pdf');
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Pdf');
|
||||
$writer->save('php://output');
|
||||
exit;
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Helper\Sample;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
require_once __DIR__ . '/../src/Bootstrap.php';
|
||||
|
||||
$helper = new \PhpOffice\PhpSpreadsheet\Helper\Sample();
|
||||
$helper = new Sample();
|
||||
if ($helper->isCli()) {
|
||||
echo 'This example should only be run from a Web Browser' . PHP_EOL;
|
||||
|
||||
|
@ -10,7 +14,7 @@ if ($helper->isCli()) {
|
|||
}
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$spreadsheet->getProperties()->setCreator('Maarten Balliauw')
|
||||
|
@ -52,6 +56,6 @@ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modifie
|
|||
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
|
||||
header('Pragma: public'); // HTTP/1.0
|
||||
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls');
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xls');
|
||||
$writer->save('php://output');
|
||||
exit;
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Helper\Sample;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
require_once __DIR__ . '/../src/Bootstrap.php';
|
||||
|
||||
$helper = new \PhpOffice\PhpSpreadsheet\Helper\Sample();
|
||||
$helper = new Sample();
|
||||
if ($helper->isCli()) {
|
||||
echo 'This example should only be run from a Web Browser' . PHP_EOL;
|
||||
|
||||
return;
|
||||
}
|
||||
// Create new Spreadsheet object
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$spreadsheet->getProperties()->setCreator('Maarten Balliauw')
|
||||
|
@ -51,6 +55,6 @@ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modifie
|
|||
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
|
||||
header('Pragma: public'); // HTTP/1.0
|
||||
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save('php://output');
|
||||
exit;
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\RichText;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Color;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
@ -70,41 +76,41 @@ $dateTimeNow = time();
|
|||
$spreadsheet->getActiveSheet()
|
||||
->setCellValue('A9', 'Date/Time')
|
||||
->setCellValue('B9', 'Date')
|
||||
->setCellValue('C9', \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($dateTimeNow));
|
||||
->setCellValue('C9', Date::PHPToExcel($dateTimeNow));
|
||||
$spreadsheet->getActiveSheet()
|
||||
->getStyle('C9')
|
||||
->getNumberFormat()
|
||||
->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
||||
->setFormatCode(NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
||||
|
||||
$spreadsheet->getActiveSheet()
|
||||
->setCellValue('A10', 'Date/Time')
|
||||
->setCellValue('B10', 'Time')
|
||||
->setCellValue('C10', \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($dateTimeNow));
|
||||
->setCellValue('C10', Date::PHPToExcel($dateTimeNow));
|
||||
$spreadsheet->getActiveSheet()
|
||||
->getStyle('C10')
|
||||
->getNumberFormat()
|
||||
->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME4);
|
||||
->setFormatCode(NumberFormat::FORMAT_DATE_TIME4);
|
||||
|
||||
$spreadsheet->getActiveSheet()
|
||||
->setCellValue('A11', 'Date/Time')
|
||||
->setCellValue('B11', 'Date and Time')
|
||||
->setCellValue('C11', \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($dateTimeNow));
|
||||
->setCellValue('C11', Date::PHPToExcel($dateTimeNow));
|
||||
$spreadsheet->getActiveSheet()
|
||||
->getStyle('C11')
|
||||
->getNumberFormat()
|
||||
->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME);
|
||||
->setFormatCode(NumberFormat::FORMAT_DATE_DATETIME);
|
||||
|
||||
$spreadsheet->getActiveSheet()
|
||||
->setCellValue('A12', 'NULL')
|
||||
->setCellValue('C12', null);
|
||||
|
||||
$richText = new \PhpOffice\PhpSpreadsheet\RichText();
|
||||
$richText = new RichText();
|
||||
$richText->createText('你好 ');
|
||||
|
||||
$payable = $richText->createTextRun('你 好 吗?');
|
||||
$payable->getFont()->setBold(true);
|
||||
$payable->getFont()->setItalic(true);
|
||||
$payable->getFont()->setColor(new \PhpOffice\PhpSpreadsheet\Style\Color(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_DARKGREEN));
|
||||
$payable->getFont()->setColor(new Color(Color::COLOR_DARKGREEN));
|
||||
|
||||
$richText->createText(', unless specified otherwise on the invoice.');
|
||||
|
||||
|
@ -112,11 +118,11 @@ $spreadsheet->getActiveSheet()
|
|||
->setCellValue('A13', 'Rich Text')
|
||||
->setCellValue('C13', $richText);
|
||||
|
||||
$richText2 = new \PhpOffice\PhpSpreadsheet\RichText();
|
||||
$richText2 = new RichText();
|
||||
$richText2->createText("black text\n");
|
||||
|
||||
$red = $richText2->createTextRun('red text');
|
||||
$red->getFont()->setColor(new \PhpOffice\PhpSpreadsheet\Style\Color(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_RED));
|
||||
$red->getFont()->setColor(new Color(Color::COLOR_RED));
|
||||
|
||||
$spreadsheet->getActiveSheet()
|
||||
->getCell('C14')
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooter;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
@ -34,22 +39,22 @@ $spreadsheet->getActiveSheet()
|
|||
|
||||
// Add a drawing to the header
|
||||
$helper->log('Add a drawing to the header');
|
||||
$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing();
|
||||
$drawing = new HeaderFooterDrawing();
|
||||
$drawing->setName('PhpSpreadsheet logo');
|
||||
$drawing->setPath(__DIR__ . '/images/PhpSpreadsheet_logo.png');
|
||||
$drawing->setHeight(36);
|
||||
$spreadsheet->getActiveSheet()
|
||||
->getHeaderFooter()
|
||||
->addImage($drawing, \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooter::IMAGE_HEADER_LEFT);
|
||||
->addImage($drawing, HeaderFooter::IMAGE_HEADER_LEFT);
|
||||
|
||||
// Set page orientation and size
|
||||
$helper->log('Set page orientation and size');
|
||||
$spreadsheet->getActiveSheet()
|
||||
->getPageSetup()
|
||||
->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
|
||||
->setOrientation(PageSetup::ORIENTATION_LANDSCAPE);
|
||||
$spreadsheet->getActiveSheet()
|
||||
->getPageSetup()
|
||||
->setPaperSize(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4);
|
||||
->setPaperSize(PageSetup::PAPERSIZE_A4);
|
||||
|
||||
// Rename worksheet
|
||||
$helper->log('Rename worksheet');
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create temporary file that will be read
|
||||
$sampleSpreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
|
||||
$filename = $helper->getTemporaryFilename();
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($sampleSpreadsheet);
|
||||
$writer = new Xlsx($sampleSpreadsheet);
|
||||
$writer->save($filename);
|
||||
|
||||
$callStartTime = microtime(true);
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename);
|
||||
$spreadsheet = IOFactory::load($filename);
|
||||
$helper->logRead('Xlsx', $filename, $callStartTime);
|
||||
|
||||
// Save
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Color;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Conditional;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
@ -47,30 +53,30 @@ $spreadsheet->getActiveSheet()->getColumnDimension('B')->setWidth(12);
|
|||
|
||||
// Add conditional formatting
|
||||
$helper->log('Add conditional formatting');
|
||||
$conditional1 = new \PhpOffice\PhpSpreadsheet\Style\Conditional();
|
||||
$conditional1->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS)
|
||||
->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_BETWEEN)
|
||||
$conditional1 = new Conditional();
|
||||
$conditional1->setConditionType(Conditional::CONDITION_CELLIS)
|
||||
->setOperatorType(Conditional::OPERATOR_BETWEEN)
|
||||
->addCondition('200')
|
||||
->addCondition('400');
|
||||
$conditional1->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_YELLOW);
|
||||
$conditional1->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_YELLOW);
|
||||
$conditional1->getStyle()->getFont()->setBold(true);
|
||||
$conditional1->getStyle()->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
||||
$conditional1->getStyle()->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
||||
|
||||
$conditional2 = new \PhpOffice\PhpSpreadsheet\Style\Conditional();
|
||||
$conditional2->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS)
|
||||
->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_LESSTHAN)
|
||||
$conditional2 = new Conditional();
|
||||
$conditional2->setConditionType(Conditional::CONDITION_CELLIS)
|
||||
->setOperatorType(Conditional::OPERATOR_LESSTHAN)
|
||||
->addCondition('0');
|
||||
$conditional2->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_RED);
|
||||
$conditional2->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_RED);
|
||||
$conditional2->getStyle()->getFont()->setItalic(true);
|
||||
$conditional2->getStyle()->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
||||
$conditional2->getStyle()->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
||||
|
||||
$conditional3 = new \PhpOffice\PhpSpreadsheet\Style\Conditional();
|
||||
$conditional3->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS)
|
||||
->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_GREATERTHANOREQUAL)
|
||||
$conditional3 = new Conditional();
|
||||
$conditional3->setConditionType(Conditional::CONDITION_CELLIS)
|
||||
->setOperatorType(Conditional::OPERATOR_GREATERTHANOREQUAL)
|
||||
->addCondition('0');
|
||||
$conditional3->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_GREEN);
|
||||
$conditional3->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_GREEN);
|
||||
$conditional3->getStyle()->getFont()->setItalic(true);
|
||||
$conditional3->getStyle()->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
||||
$conditional3->getStyle()->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
||||
|
||||
$conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('B2')->getConditionalStyles();
|
||||
array_push($conditionalStyles, $conditional1);
|
||||
|
@ -98,8 +104,8 @@ $spreadsheet->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $spread
|
|||
|
||||
// Set page orientation and size
|
||||
$helper->log('Set page orientation and size');
|
||||
$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_PORTRAIT);
|
||||
$spreadsheet->getActiveSheet()->getPageSetup()->setPaperSize(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4);
|
||||
$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_PORTRAIT);
|
||||
$spreadsheet->getActiveSheet()->getPageSetup()->setPaperSize(PageSetup::PAPERSIZE_A4);
|
||||
|
||||
// Rename worksheet
|
||||
$helper->log('Rename worksheet');
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Color;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Conditional;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
@ -32,22 +37,22 @@ $spreadsheet->getActiveSheet()
|
|||
$spreadsheet->getActiveSheet()->getStyle('A1:A8')
|
||||
->getNumberFormat()
|
||||
->setFormatCode(
|
||||
\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_PERCENTAGE_00
|
||||
NumberFormat::FORMAT_PERCENTAGE_00
|
||||
);
|
||||
|
||||
// Add conditional formatting
|
||||
$helper->log('Add conditional formatting');
|
||||
$conditional1 = new \PhpOffice\PhpSpreadsheet\Style\Conditional();
|
||||
$conditional1->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS)
|
||||
->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_LESSTHAN)
|
||||
$conditional1 = new Conditional();
|
||||
$conditional1->setConditionType(Conditional::CONDITION_CELLIS)
|
||||
->setOperatorType(Conditional::OPERATOR_LESSTHAN)
|
||||
->addCondition('0');
|
||||
$conditional1->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_RED);
|
||||
$conditional1->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_RED);
|
||||
|
||||
$conditional3 = new \PhpOffice\PhpSpreadsheet\Style\Conditional();
|
||||
$conditional3->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS)
|
||||
->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_GREATERTHANOREQUAL)
|
||||
$conditional3 = new Conditional();
|
||||
$conditional3->setConditionType(Conditional::CONDITION_CELLIS)
|
||||
->setOperatorType(Conditional::OPERATOR_GREATERTHANOREQUAL)
|
||||
->addCondition('1');
|
||||
$conditional3->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_GREEN);
|
||||
$conditional3->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_GREEN);
|
||||
|
||||
$conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('A1')->getConditionalStyles();
|
||||
array_push($conditionalStyles, $conditional1);
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
@ -36,7 +39,7 @@ for ($i = 2; $i <= 50; ++$i) {
|
|||
// Add page breaks every 10 rows
|
||||
if ($i % 10 == 0) {
|
||||
// Add a page break
|
||||
$spreadsheet->getActiveSheet()->setBreak('A' . $i, \PhpOffice\PhpSpreadsheet\Worksheet::BREAK_ROW);
|
||||
$spreadsheet->getActiveSheet()->setBreak('A' . $i, Worksheet::BREAK_ROW);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
@ -48,7 +54,7 @@ foreach ($years as $year) {
|
|||
foreach ($countries as $country) {
|
||||
$endDays = date('t', mktime(0, 0, 0, $period, 1, $year));
|
||||
for ($i = 1; $i <= $endDays; ++$i) {
|
||||
$eDate = \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel(
|
||||
$eDate = Date::formattedPHPToExcel(
|
||||
$year,
|
||||
$period,
|
||||
$i
|
||||
|
@ -86,8 +92,8 @@ $spreadsheet->getActiveSheet()->getStyle('A1:F1')->getFont()->setBold(true);
|
|||
$spreadsheet->getActiveSheet()->getStyle('A1:F1')->getAlignment()->setWrapText(true);
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension('C')->setWidth(12.5);
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension('D')->setWidth(10.5);
|
||||
$spreadsheet->getActiveSheet()->getStyle('D2:D' . $row)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
||||
$spreadsheet->getActiveSheet()->getStyle('E2:F' . $row)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
|
||||
$spreadsheet->getActiveSheet()->getStyle('D2:D' . $row)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
||||
$spreadsheet->getActiveSheet()->getStyle('E2:F' . $row)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension('F')->setWidth(14);
|
||||
$spreadsheet->getActiveSheet()->freezePane('A2');
|
||||
|
||||
|
@ -104,45 +110,45 @@ $helper->log('Set active filters');
|
|||
// Filter the Country column on a filter value of countries beginning with the letter U (or Japan)
|
||||
// We use * as a wildcard, so specify as U* and using a wildcard requires customFilter
|
||||
$autoFilter->getColumn('C')
|
||||
->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER)
|
||||
->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
'u*'
|
||||
)
|
||||
->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
$autoFilter->getColumn('C')
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
'japan'
|
||||
)
|
||||
->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
// Filter the Date column on a filter value of the first day of every period of the current year
|
||||
// We us a dateGroup ruletype for this, although it is still a standard filter
|
||||
foreach ($periods as $period) {
|
||||
$endDate = date('t', mktime(0, 0, 0, $period, 1, $currentYear));
|
||||
|
||||
$autoFilter->getColumn('D')
|
||||
->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER)
|
||||
->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
[
|
||||
'year' => $currentYear,
|
||||
'month' => $period,
|
||||
'day' => $endDate,
|
||||
]
|
||||
)
|
||||
->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP);
|
||||
->setRuleType(Rule::AUTOFILTER_RULETYPE_DATEGROUP);
|
||||
}
|
||||
// Display only sales values that are blank
|
||||
// Standard filter, operator equals, and value of NULL
|
||||
$autoFilter->getColumn('E')
|
||||
->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER)
|
||||
->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
''
|
||||
);
|
||||
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
@ -48,7 +54,7 @@ foreach ($years as $year) {
|
|||
foreach ($countries as $country) {
|
||||
$endDays = date('t', mktime(0, 0, 0, $period, 1, $year));
|
||||
for ($i = 1; $i <= $endDays; ++$i) {
|
||||
$eDate = \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel(
|
||||
$eDate = Date::formattedPHPToExcel(
|
||||
$year,
|
||||
$period,
|
||||
$i
|
||||
|
@ -86,8 +92,8 @@ $spreadsheet->getActiveSheet()->getStyle('A1:F1')->getFont()->setBold(true);
|
|||
$spreadsheet->getActiveSheet()->getStyle('A1:F1')->getAlignment()->setWrapText(true);
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension('C')->setWidth(12.5);
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension('D')->setWidth(10.5);
|
||||
$spreadsheet->getActiveSheet()->getStyle('D2:D' . $row)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
||||
$spreadsheet->getActiveSheet()->getStyle('E2:F' . $row)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
|
||||
$spreadsheet->getActiveSheet()->getStyle('D2:D' . $row)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
||||
$spreadsheet->getActiveSheet()->getStyle('E2:F' . $row)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension('F')->setWidth(14);
|
||||
$spreadsheet->getActiveSheet()->freezePane('A2');
|
||||
|
||||
|
@ -104,39 +110,39 @@ $helper->log('Set active filters');
|
|||
// Filter the Country column on a filter value of Germany
|
||||
// As it's just a simple value filter, we can use FILTERTYPE_FILTER
|
||||
$autoFilter->getColumn('C')
|
||||
->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER)
|
||||
->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
'Germany'
|
||||
);
|
||||
// Filter the Date column on a filter value of the year to date
|
||||
$autoFilter->getColumn('D')
|
||||
->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER)
|
||||
->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
null,
|
||||
\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE
|
||||
Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE
|
||||
)
|
||||
->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER);
|
||||
->setRuleType(Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER);
|
||||
// Display only sales values that are between 400 and 600
|
||||
$autoFilter->getColumn('E')
|
||||
->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER)
|
||||
->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL,
|
||||
Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL,
|
||||
400
|
||||
)
|
||||
->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
$autoFilter->getColumn('E')
|
||||
->setJoin(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_AND)
|
||||
->setJoin(Column::AUTOFILTER_COLUMN_JOIN_AND)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL,
|
||||
Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL,
|
||||
600
|
||||
)
|
||||
->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
|
||||
// Save
|
||||
$helper->write($spreadsheet, __FILE__);
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
@ -48,7 +54,7 @@ foreach ($years as $year) {
|
|||
foreach ($countries as $country) {
|
||||
$endDays = date('t', mktime(0, 0, 0, $period, 1, $year));
|
||||
for ($i = 1; $i <= $endDays; ++$i) {
|
||||
$eDate = \PhpOffice\PhpSpreadsheet\Shared\Date::formattedPHPToExcel(
|
||||
$eDate = Date::formattedPHPToExcel(
|
||||
$year,
|
||||
$period,
|
||||
$i
|
||||
|
@ -86,8 +92,8 @@ $spreadsheet->getActiveSheet()->getStyle('A1:F1')->getFont()->setBold(true);
|
|||
$spreadsheet->getActiveSheet()->getStyle('A1:F1')->getAlignment()->setWrapText(true);
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension('C')->setWidth(12.5);
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension('D')->setWidth(10.5);
|
||||
$spreadsheet->getActiveSheet()->getStyle('D2:D' . $row)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
||||
$spreadsheet->getActiveSheet()->getStyle('E2:F' . $row)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
|
||||
$spreadsheet->getActiveSheet()->getStyle('D2:D' . $row)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_DATE_YYYYMMDD2);
|
||||
$spreadsheet->getActiveSheet()->getStyle('E2:F' . $row)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension('F')->setWidth(14);
|
||||
$spreadsheet->getActiveSheet()->freezePane('A2');
|
||||
|
||||
|
@ -104,45 +110,45 @@ $helper->log('Set active filters');
|
|||
// Filter the Country column on a filter value of countries beginning with the letter U (or Japan)
|
||||
// We use * as a wildcard, so specify as U* and using a wildcard requires customFilter
|
||||
$autoFilter->getColumn('C')
|
||||
->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER)
|
||||
->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
'u*'
|
||||
)
|
||||
->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
$autoFilter->getColumn('C')
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
'japan'
|
||||
)
|
||||
->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
->setRuleType(Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
|
||||
// Filter the Date column on a filter value of the first day of every period of the current year
|
||||
// We us a dateGroup ruletype for this, although it is still a standard filter
|
||||
foreach ($periods as $period) {
|
||||
$endDate = date('t', mktime(0, 0, 0, $period, 1, $currentYear));
|
||||
|
||||
$autoFilter->getColumn('D')
|
||||
->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER)
|
||||
->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
[
|
||||
'year' => $currentYear,
|
||||
'month' => $period,
|
||||
'day' => $endDate,
|
||||
]
|
||||
)
|
||||
->setRuleType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP);
|
||||
->setRuleType(Rule::AUTOFILTER_RULETYPE_DATEGROUP);
|
||||
}
|
||||
// Display only sales values that are blank
|
||||
// Standard filter, operator equals, and value of NULL
|
||||
$autoFilter->getColumn('E')
|
||||
->setFilterType(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER)
|
||||
->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER)
|
||||
->createRule()
|
||||
->setRule(
|
||||
\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
|
||||
''
|
||||
);
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Protection;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
@ -37,7 +40,7 @@ $spreadsheet->getActiveSheet()->getProtection()->setSheet(true);
|
|||
$spreadsheet->getActiveSheet()
|
||||
->getStyle('A2:B2')
|
||||
->getProtection()->setLocked(
|
||||
\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED
|
||||
Protection::PROTECTION_UNPROTECTED
|
||||
);
|
||||
|
||||
// Save
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
mt_srand(1234567890);
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// List functions
|
||||
$helper->log('List implemented functions');
|
||||
$calc = \PhpOffice\PhpSpreadsheet\Calculation::getInstance();
|
||||
$calc = Calculation::getInstance();
|
||||
print_r($calc->getImplementedFunctionNames());
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Add some data, we will use some formulas here
|
||||
$helper->log('Add some data and formulas');
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Add some data, we will use some formulas here
|
||||
$helper->log('Add some data and formulas');
|
||||
|
@ -13,7 +16,7 @@ $spreadsheet->getActiveSheet()->setCellValue('A1', '=B1')
|
|||
->setCellValue('B1', '=A1+1')
|
||||
->setCellValue('B2', '=A2');
|
||||
|
||||
\PhpOffice\PhpSpreadsheet\Calculation::getInstance($spreadsheet)->cyclicFormulaCount = 100;
|
||||
Calculation::getInstance($spreadsheet)->cyclicFormulaCount = 100;
|
||||
|
||||
// Calculated data
|
||||
$helper->log('Calculated data');
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
$spreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
|
||||
|
||||
$filename = $helper->getFilename(__FILE__, 'xls');
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls');
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xls');
|
||||
|
||||
$callStartTime = microtime(true);
|
||||
$writer->save($filename);
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataValidation;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
@ -35,8 +38,8 @@ $spreadsheet->getActiveSheet()->setCellValue('A1', 'Cell B3 and B5 contain data
|
|||
// Set data validation
|
||||
$helper->log('Set data validation');
|
||||
$validation = $spreadsheet->getActiveSheet()->getCell('B3')->getDataValidation();
|
||||
$validation->setType(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_WHOLE);
|
||||
$validation->setErrorStyle(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_STOP);
|
||||
$validation->setType(DataValidation::TYPE_WHOLE);
|
||||
$validation->setErrorStyle(DataValidation::STYLE_STOP);
|
||||
$validation->setAllowBlank(true);
|
||||
$validation->setShowInputMessage(true);
|
||||
$validation->setShowErrorMessage(true);
|
||||
|
@ -48,8 +51,8 @@ $validation->setFormula1(10);
|
|||
$validation->setFormula2(20);
|
||||
|
||||
$validation = $spreadsheet->getActiveSheet()->getCell('B5')->getDataValidation();
|
||||
$validation->setType(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST);
|
||||
$validation->setErrorStyle(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_INFORMATION);
|
||||
$validation->setType(DataValidation::TYPE_LIST);
|
||||
$validation->setErrorStyle(DataValidation::STYLE_INFORMATION);
|
||||
$validation->setAllowBlank(false);
|
||||
$validation->setShowInputMessage(true);
|
||||
$validation->setShowErrorMessage(true);
|
||||
|
@ -61,8 +64,8 @@ $validation->setPrompt('Please pick a value from the drop-down list.');
|
|||
$validation->setFormula1('"Item A,Item B,Item C"'); // Make sure to put the list items between " and " if your list is simply a comma-separated list of values !!!
|
||||
|
||||
$validation = $spreadsheet->getActiveSheet()->getCell('B7')->getDataValidation();
|
||||
$validation->setType(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST);
|
||||
$validation->setErrorStyle(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_INFORMATION);
|
||||
$validation->setType(DataValidation::TYPE_LIST);
|
||||
$validation->setErrorStyle(DataValidation::STYLE_INFORMATION);
|
||||
$validation->setAllowBlank(false);
|
||||
$validation->setShowInputMessage(true);
|
||||
$validation->setShowErrorMessage(true);
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
$spreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
|
||||
|
||||
$helper->log('Write to CSV format');
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Csv')->setDelimiter(',')
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Csv')->setDelimiter(',')
|
||||
->setEnclosure('"')
|
||||
->setSheetIndex(0);
|
||||
|
||||
|
@ -15,7 +17,7 @@ $helper->logWrite($writer, $filename, $callStartTime);
|
|||
|
||||
$helper->log('Read from CSV format');
|
||||
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Csv')->setDelimiter(',')
|
||||
$reader = IOFactory::createReader('Csv')->setDelimiter(',')
|
||||
->setEnclosure('"')
|
||||
->setSheetIndex(0);
|
||||
|
||||
|
@ -28,7 +30,7 @@ $helper->write($spreadsheetFromCSV, __FILE__, ['Xlsx']);
|
|||
|
||||
// Write CSV
|
||||
$filenameCSV = $helper->getFilename(__FILE__, 'csv');
|
||||
$writerCSV = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheetFromCSV, 'Csv');
|
||||
$writerCSV = IOFactory::createWriter($spreadsheetFromCSV, 'Csv');
|
||||
$writerCSV->setExcelCompatibility(true);
|
||||
|
||||
$callStartTime = microtime(true);
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
$spreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
|
||||
|
||||
$filename = $helper->getFilename(__FILE__, 'html');
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Html');
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Html');
|
||||
|
||||
$callStartTime = microtime(true);
|
||||
$writer->save($filename);
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// List functions
|
||||
$helper->log('List implemented functions');
|
||||
$calc = \PhpOffice\PhpSpreadsheet\Calculation::getInstance();
|
||||
$calc = Calculation::getInstance();
|
||||
print_r($calc->getImplementedFunctionNames());
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Add some data, we will use some formulas here
|
||||
$helper->log('Add some data');
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\NamedRange;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
@ -28,8 +31,8 @@ $spreadsheet->getActiveSheet()->setCellValue('A1', 'Firstname:')
|
|||
|
||||
// Define named ranges
|
||||
$helper->log('Define named ranges');
|
||||
$spreadsheet->addNamedRange(new \PhpOffice\PhpSpreadsheet\NamedRange('PersonName', $spreadsheet->getActiveSheet(), 'B1'));
|
||||
$spreadsheet->addNamedRange(new \PhpOffice\PhpSpreadsheet\NamedRange('PersonLN', $spreadsheet->getActiveSheet(), 'B2'));
|
||||
$spreadsheet->addNamedRange(new NamedRange('PersonName', $spreadsheet->getActiveSheet(), 'B1'));
|
||||
$spreadsheet->addNamedRange(new NamedRange('PersonLN', $spreadsheet->getActiveSheet(), 'B2'));
|
||||
|
||||
// Rename named ranges
|
||||
$helper->log('Rename named ranges');
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
$filename = __DIR__ . '/templates/Excel2003XMLTest.xml';
|
||||
$callStartTime = microtime(true);
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename);
|
||||
$spreadsheet = IOFactory::load($filename);
|
||||
$helper->logRead('Xml', $filename, $callStartTime);
|
||||
|
||||
// Save
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
$filename = __DIR__ . '/templates/GnumericTest.gnumeric';
|
||||
$callStartTime = microtime(true);
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename);
|
||||
$spreadsheet = IOFactory::load($filename);
|
||||
$helper->logRead('Gnumeric', $filename, $callStartTime);
|
||||
|
||||
// Save
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
$filename = __DIR__ . '/templates/OOCalcTest.ods';
|
||||
$callStartTime = microtime(true);
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename);
|
||||
$spreadsheet = IOFactory::load($filename);
|
||||
$helper->logRead('Ods', $filename, $callStartTime);
|
||||
|
||||
// Save
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
$filename = __DIR__ . '/templates/SylkTest.slk';
|
||||
$callStartTime = microtime(true);
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename);
|
||||
$spreadsheet = IOFactory::load($filename);
|
||||
$helper->logRead('Slk', $filename, $callStartTime);
|
||||
|
||||
// Save
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
$spreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
|
||||
|
||||
// Write temporary file
|
||||
$filename = $helper->getTemporaryFilename('xls');
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls');
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xls');
|
||||
$callStartTime = microtime(true);
|
||||
$writer->save($filename);
|
||||
$helper->logWrite($writer, $filename, $callStartTime);
|
||||
|
||||
// Read Xls file
|
||||
$callStartTime = microtime(true);
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename);
|
||||
$spreadsheet = IOFactory::load($filename);
|
||||
$helper->logRead('Xls', $filename, $callStartTime);
|
||||
|
||||
// Save
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
$spreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
|
||||
|
||||
|
@ -7,11 +10,11 @@ $helper->log('Hide grid lines');
|
|||
$spreadsheet->getActiveSheet()->setShowGridLines(false);
|
||||
|
||||
$helper->log('Set orientation to landscape');
|
||||
$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
|
||||
$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE);
|
||||
|
||||
$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_DOMPDF;
|
||||
$rendererName = Settings::PDF_RENDERER_DOMPDF;
|
||||
$helper->log("Write to PDF format using {$rendererName}");
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setPdfRendererName($rendererName);
|
||||
Settings::setPdfRendererName($rendererName);
|
||||
|
||||
// Save
|
||||
$helper->write($spreadsheet, __FILE__, ['Pdf']);
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
$spreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
|
||||
|
||||
|
@ -7,11 +10,11 @@ $helper->log('Hide grid lines');
|
|||
$spreadsheet->getActiveSheet()->setShowGridLines(false);
|
||||
|
||||
$helper->log('Set orientation to landscape');
|
||||
$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
|
||||
$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE);
|
||||
|
||||
$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_TCPDF;
|
||||
$rendererName = Settings::PDF_RENDERER_TCPDF;
|
||||
$helper->log("Write to PDF format using {$rendererName}");
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setPdfRendererName($rendererName);
|
||||
Settings::setPdfRendererName($rendererName);
|
||||
|
||||
// Save
|
||||
$helper->write($spreadsheet, __FILE__, ['Pdf']);
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
$spreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
|
||||
|
||||
|
@ -7,11 +10,11 @@ $helper->log('Hide grid lines');
|
|||
$spreadsheet->getActiveSheet()->setShowGridLines(false);
|
||||
|
||||
$helper->log('Set orientation to landscape');
|
||||
$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
|
||||
$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE);
|
||||
|
||||
$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_MPDF;
|
||||
$rendererName = Settings::PDF_RENDERER_MPDF;
|
||||
$helper->log("Write to PDF format using {$rendererName}");
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setPdfRendererName($rendererName);
|
||||
Settings::setPdfRendererName($rendererName);
|
||||
|
||||
// Save
|
||||
$helper->write($spreadsheet, __FILE__, ['Pdf']);
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
@ -22,19 +26,19 @@ $spreadsheet->setActiveSheetIndex(0);
|
|||
|
||||
$spreadsheet->getActiveSheet()->getStyle('A1:T100')->applyFromArray(
|
||||
['fill' => [
|
||||
'type' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
|
||||
'fillType' => Fill::FILL_SOLID,
|
||||
'color' => ['argb' => 'FFCCFFCC'],
|
||||
],
|
||||
'borders' => [
|
||||
'bottom' => ['style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN],
|
||||
'right' => ['style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM],
|
||||
'bottom' => ['borderStyle' => Border::BORDER_THIN],
|
||||
'right' => ['borderStyle' => Border::BORDER_MEDIUM],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$spreadsheet->getActiveSheet()->getStyle('C5:R95')->applyFromArray(
|
||||
['fill' => [
|
||||
'type' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
|
||||
'fillType' => Fill::FILL_SOLID,
|
||||
'color' => ['argb' => 'FFFFFF00'],
|
||||
],
|
||||
]
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
@ -20,29 +25,29 @@ $spreadsheet->getProperties()->setCreator('Maarten Balliauw')
|
|||
$helper->log('Add some data');
|
||||
$spreadsheet->setActiveSheetIndex(0);
|
||||
|
||||
$sharedStyle1 = new \PhpOffice\PhpSpreadsheet\Style();
|
||||
$sharedStyle2 = new \PhpOffice\PhpSpreadsheet\Style();
|
||||
$sharedStyle1 = new Style();
|
||||
$sharedStyle2 = new Style();
|
||||
|
||||
$sharedStyle1->applyFromArray(
|
||||
['fill' => [
|
||||
'type' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
|
||||
'fillType' => Fill::FILL_SOLID,
|
||||
'color' => ['argb' => 'FFCCFFCC'],
|
||||
],
|
||||
'borders' => [
|
||||
'bottom' => ['style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN],
|
||||
'right' => ['style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM],
|
||||
'bottom' => ['borderStyle' => Border::BORDER_THIN],
|
||||
'right' => ['borderStyle' => Border::BORDER_MEDIUM],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$sharedStyle2->applyFromArray(
|
||||
['fill' => [
|
||||
'type' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
|
||||
'fillType' => Fill::FILL_SOLID,
|
||||
'color' => ['argb' => 'FFFFFF00'],
|
||||
],
|
||||
'borders' => [
|
||||
'bottom' => ['style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN],
|
||||
'right' => ['style' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM],
|
||||
'bottom' => ['borderStyle' => Border::BORDER_THIN],
|
||||
'right' => ['borderStyle' => Border::BORDER_MEDIUM],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
|
|
@ -2,17 +2,20 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Write temporary file
|
||||
$largeSpreadsheet = require __DIR__ . '/templates/largeSpreadsheet.php';
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($largeSpreadsheet);
|
||||
$writer = new Xlsx($largeSpreadsheet);
|
||||
$filename = $helper->getTemporaryFilename();
|
||||
$callStartTime = microtime(true);
|
||||
$writer->save($filename);
|
||||
$helper->logWrite($writer, $filename, $callStartTime);
|
||||
|
||||
class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
|
||||
class MyReadFilter implements IReadFilter
|
||||
{
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
{
|
||||
|
@ -26,7 +29,7 @@ class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
|
|||
}
|
||||
|
||||
$helper->log('Load from Xlsx file');
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
|
||||
$reader = IOFactory::createReader('Xlsx');
|
||||
$reader->setReadFilter(new MyReadFilter());
|
||||
$callStartTime = microtime(true);
|
||||
$spreadsheet = $reader->load($filename);
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
@ -24,12 +27,12 @@ imagestring($gdImage, 1, 5, 5, 'Created with PhpSpreadsheet', $textColor);
|
|||
|
||||
// Add a drawing to the worksheet
|
||||
$helper->log('Add a drawing to the worksheet');
|
||||
$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing();
|
||||
$drawing = new MemoryDrawing();
|
||||
$drawing->setName('Sample image');
|
||||
$drawing->setDescription('Sample image');
|
||||
$drawing->setImageResource($gdImage);
|
||||
$drawing->setRenderingFunction(\PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::RENDERING_JPEG);
|
||||
$drawing->setMimeType(\PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::MIMETYPE_DEFAULT);
|
||||
$drawing->setRenderingFunction(MemoryDrawing::RENDERING_JPEG);
|
||||
$drawing->setMimeType(MemoryDrawing::MIMETYPE_DEFAULT);
|
||||
$drawing->setHeight(36);
|
||||
$drawing->setWorksheet($spreadsheet->getActiveSheet());
|
||||
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Change these values to select the PDF Rendering library that you wish to use
|
||||
// and its directory location on your server
|
||||
//$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_TCPDF;
|
||||
//$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_MPDF;
|
||||
$rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_DOMPDF;
|
||||
$rendererName = Settings::PDF_RENDERER_DOMPDF;
|
||||
|
||||
// Read from Xlsx (.xlsx) template
|
||||
$helper->log('Load Xlsx template file');
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
|
||||
$reader = IOFactory::createReader('Xlsx');
|
||||
$spreadsheet = $reader->load(__DIR__ . '/templates/26template.xlsx');
|
||||
|
||||
/* at this point, we could do some manipulations with the template, but we skip this step */
|
||||
|
@ -18,7 +21,7 @@ $helper->write($spreadsheet, __FILE__, ['Xlsx', 'Xls', 'Html']);
|
|||
|
||||
// Export to PDF (.pdf)
|
||||
$helper->log('Write to PDF format');
|
||||
\PhpOffice\PhpSpreadsheet\Settings::setPdfRendererName($rendererName);
|
||||
Settings::setPdfRendererName($rendererName);
|
||||
$helper->write($spreadsheet, __FILE__, ['Pdf']);
|
||||
|
||||
// Remove first two rows with field headers before exporting to CSV
|
||||
|
@ -28,7 +31,7 @@ $worksheet->removeRow(1, 2);
|
|||
|
||||
// Export to CSV (.csv)
|
||||
$helper->log('Write to CSV format');
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Csv');
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Csv');
|
||||
$filename = $helper->getFilename(__FILE__, 'csv');
|
||||
$callStartTime = microtime(true);
|
||||
$writer->save($filename);
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
// Read from Xls (.xls) template
|
||||
$helper->log('Load Xlsx template file');
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xls');
|
||||
$reader = IOFactory::createReader('Xls');
|
||||
$spreadsheet = $reader->load(__DIR__ . '/templates/27template.xls');
|
||||
|
||||
// Save
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
$sampleSpreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
|
||||
$filename = $helper->getTemporaryFilename();
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($sampleSpreadsheet);
|
||||
$writer = new Xlsx($sampleSpreadsheet);
|
||||
$callStartTime = microtime(true);
|
||||
$writer->save($filename);
|
||||
$helper->logWrite($writer, $filename, $callStartTime);
|
||||
|
||||
$callStartTime = microtime(true);
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
|
||||
$reader = IOFactory::createReader('Xlsx');
|
||||
$spreadsheet = $reader->load($filename);
|
||||
$helper->logRead('Xlsx', $filename, $callStartTime);
|
||||
$helper->log('Iterate worksheets');
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
|
@ -9,11 +11,11 @@ date_default_timezone_set('UTC');
|
|||
|
||||
// Set value binder
|
||||
$helper->log('Set value binder');
|
||||
\PhpOffice\PhpSpreadsheet\Cell::setValueBinder(new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder());
|
||||
Cell::setValueBinder(new Cell\AdvancedValueBinder());
|
||||
|
||||
// Create new Spreadsheet object
|
||||
$helper->log('Create new Spreadsheet object');
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
// Set document properties
|
||||
$helper->log('Set document properties');
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
$helper->log('Load from Xls template');
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xls');
|
||||
$reader = IOFactory::createReader('Xls');
|
||||
$spreadsheet = $reader->load(__DIR__ . '/templates/30template.xls');
|
||||
|
||||
$helper->log('Add new data to the template');
|
||||
|
@ -21,7 +24,7 @@ $data = [['title' => 'Excel for dummies',
|
|||
],
|
||||
];
|
||||
|
||||
$spreadsheet->getActiveSheet()->setCellValue('D1', \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(time()));
|
||||
$spreadsheet->getActiveSheet()->setCellValue('D1', Date::PHPToExcel(time()));
|
||||
|
||||
$baseRow = 5;
|
||||
foreach ($data as $r => $dataRow) {
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Document\Properties;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
$inputFileType = 'Xlsx';
|
||||
$inputFileName = __DIR__ . '/templates/31docproperties.xlsx';
|
||||
|
||||
$spreadsheetReader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$spreadsheetReader = IOFactory::createReader($inputFileType);
|
||||
$callStartTime = microtime(true);
|
||||
$spreadsheet = $spreadsheetReader->load($inputFileName);
|
||||
$helper->logRead($inputFileType, $inputFileName, $callStartTime);
|
||||
|
@ -18,7 +21,7 @@ $spreadsheet->getProperties()->setTitle('Office 2007 XLSX Test Document')
|
|||
|
||||
// Save Excel 2007 file
|
||||
$filename = $helper->getFilename(__FILE__);
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$callStartTime = microtime(true);
|
||||
$writer->save($filename);
|
||||
$helper->logWrite($writer, $filename, $callStartTime);
|
||||
|
@ -28,7 +31,7 @@ $helper->logEndingNotes();
|
|||
|
||||
// Reread File
|
||||
$helper->log('Reread Xlsx file');
|
||||
$spreadsheetRead = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename);
|
||||
$spreadsheetRead = IOFactory::load($filename);
|
||||
|
||||
// Set properties
|
||||
$helper->log('Get properties');
|
||||
|
@ -53,9 +56,9 @@ $customProperties = $spreadsheet->getProperties()->getCustomProperties();
|
|||
foreach ($customProperties as $customProperty) {
|
||||
$propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customProperty);
|
||||
$propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customProperty);
|
||||
if ($propertyType == \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_DATE) {
|
||||
if ($propertyType == Properties::PROPERTY_TYPE_DATE) {
|
||||
$formattedValue = date('d-M-Y H:i:s', $propertyValue);
|
||||
} elseif ($propertyType == \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_BOOLEAN) {
|
||||
} elseif ($propertyType == Properties::PROPERTY_TYPE_BOOLEAN) {
|
||||
$formattedValue = $propertyValue ? 'TRUE' : 'FALSE';
|
||||
} else {
|
||||
$formattedValue = $propertyValue;
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Document\Properties;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
$inputFileType = 'Xls';
|
||||
$inputFileName = __DIR__ . '/templates/31docproperties.xls';
|
||||
|
||||
$spreadsheetReader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$spreadsheetReader = IOFactory::createReader($inputFileType);
|
||||
$callStartTime = microtime(true);
|
||||
$spreadsheet = $spreadsheetReader->load($inputFileName);
|
||||
$helper->logRead($inputFileType, $inputFileName, $callStartTime);
|
||||
|
@ -18,7 +21,7 @@ $spreadsheet->getProperties()->setTitle('Office 95 XLS Test Document')
|
|||
|
||||
// Save Excel 95 file
|
||||
$filename = $helper->getFilename(__FILE__, 'xls');
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls');
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xls');
|
||||
$callStartTime = microtime(true);
|
||||
$writer->save($filename);
|
||||
$helper->logWrite($writer, $filename, $callStartTime);
|
||||
|
@ -28,7 +31,7 @@ $helper->logEndingNotes();
|
|||
|
||||
// Reread File
|
||||
$helper->log('Reread Xls file');
|
||||
$spreadsheetRead = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename);
|
||||
$spreadsheetRead = IOFactory::load($filename);
|
||||
|
||||
// Set properties
|
||||
$helper->log('Get properties');
|
||||
|
@ -53,9 +56,9 @@ $customProperties = $spreadsheet->getProperties()->getCustomProperties();
|
|||
foreach ($customProperties as $customProperty) {
|
||||
$propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customProperty);
|
||||
$propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customProperty);
|
||||
if ($propertyType == \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_DATE) {
|
||||
if ($propertyType == Properties::PROPERTY_TYPE_DATE) {
|
||||
$formattedValue = date('d-M-Y H:i:s', $propertyValue);
|
||||
} elseif ($propertyType == \PhpOffice\PhpSpreadsheet\Document\Properties::PROPERTY_TYPE_BOOLEAN) {
|
||||
} elseif ($propertyType == Properties::PROPERTY_TYPE_BOOLEAN) {
|
||||
$formattedValue = $propertyValue ? 'TRUE' : 'FALSE';
|
||||
} else {
|
||||
$formattedValue = $propertyValue;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
require __DIR__ . '/Header.php';
|
||||
|
||||
$inputFileType = 'Xlsx';
|
||||
|
@ -20,7 +22,7 @@ foreach ($inputFileNames as $inputFileName) {
|
|||
$helper->log('File ' . $inputFileNameShort . ' does not exist');
|
||||
continue;
|
||||
}
|
||||
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
|
||||
$reader = IOFactory::createReader($inputFileType);
|
||||
$reader->setIncludeCharts(true);
|
||||
$callStartTime = microtime(true);
|
||||
$spreadsheet = $reader->load($inputFileName);
|
||||
|
@ -69,7 +71,7 @@ foreach ($inputFileNames as $inputFileName) {
|
|||
}
|
||||
|
||||
$outputFileName = $helper->getFilename($inputFileName);
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->setIncludeCharts(true);
|
||||
$callStartTime = microtime(true);
|
||||
$writer->save($outputFileName);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue