Revision of release v1.3.2

This commit is contained in:
CyberPerspectives
2018-07-26 08:33:50 -04:00
committed by Ryan Prather
parent 8c38a6cdb9
commit 750094e3b5
3231 changed files with 133590 additions and 135073 deletions

View File

@ -83,7 +83,7 @@ Then point your browser to:
The samples may also be run directly from the command line, for example:
```sh
php vendor/phpoffice/phpspreadsheet/samples/01_Simple.php
php vendor/phpoffice/phpspreadsheet/samples/Basic/01_Simple.php
```
## Learn by documentation

View File

@ -178,13 +178,13 @@ It is also possible to set a range of cell values in a single call by
passing an array of values to the `fromArray()` method.
``` php
$arrayData = array(
array(NULL, 2010, 2011, 2012),
array('Q1', 12, 15, 21),
array('Q2', 56, 73, 86),
array('Q3', 52, 61, 69),
array('Q4', 30, 32, 0),
);
$arrayData = [
[NULL, 2010, 2011, 2012],
['Q1', 12, 15, 21],
['Q2', 56, 73, 86],
['Q3', 52, 61, 69],
['Q4', 30, 32, 0],
];
$spreadsheet->getActiveSheet()
->fromArray(
$arrayData, // The data to set
@ -201,7 +201,7 @@ and columns. A 1-d array will be treated as a single row, which is
particularly useful if you're fetching an array of data from a database.
``` php
$rowArray = array('Value1', 'Value2', 'Value3', 'Value4');
$rowArray = ['Value1', 'Value2', 'Value3', 'Value4'];
$spreadsheet->getActiveSheet()
->fromArray(
$rowArray, // The data to set
@ -218,7 +218,7 @@ the following will convert it into an appropriately structured 2-d array
that can be fed to the `fromArray()` method:
``` php
$rowArray = array('Value1', 'Value2', 'Value3', 'Value4');
$rowArray = ['Value1', 'Value2', 'Value3', 'Value4'];
$columnArray = array_chunk($rowArray, 1);
$spreadsheet->getActiveSheet()
->fromArray(

View File

@ -185,10 +185,10 @@ DateGroup rule identifying the selected year and month:
$columnFilter->createRule()
->setRule(
\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL,
array(
[
'year' => 2012,
'month' => 1
)
]
)
->setRuleType(
\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP

View File

@ -263,6 +263,28 @@ return an Excel date timestamp.
Takes year, month and day values (and optional hour, minute and second
values) and returns an Excel date timestamp value.
### Timezone support for Excel date timestamp conversions
The default timezone for the date functions in PhpSpreadsheet is UST (Universal Standard Time).
If a different timezone needs to be used, these methods are available:
#### \PhpOffice\PhpSpreadsheet\Shared\Date::getDefaultTimezone()
Returns the current timezone value PhpSpeadsheet is using to handle dates and times.
#### \PhpOffice\PhpSpreadsheet\Shared\Date::setDefaultTimezone($timeZone)
Sets the timezone for Excel date timestamp conversions to $timeZone,
which must be a valid PHP DateTimeZone value.
The return value is a Boolean, where true is success,
and false is failure (e.g. an invalid DateTimeZone value was passed.)
#### \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($excelDate, $timeZone)
#### \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimeStamp($excelDate, $timeZone)
These functions support a timezone as an optional second parameter.
This applies a specific timezone to that function call without affecting the default PhpSpreadsheet Timezone.
## Function Reference
### Database Functions
@ -308,21 +330,21 @@ This is the statistical mean.
##### Examples
``` php
$database = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
array( 'Apple', 18, 20, 14, 105.00 ),
array( 'Pear', 12, 12, 10, 96.00 ),
array( 'Cherry', 13, 14, 9, 105.00 ),
array( 'Apple', 14, 15, 10, 75.00 ),
array( 'Pear', 9, 8, 8, 76.80 ),
array( 'Apple', 8, 9, 6, 45.00 ),
);
$database = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ],
[ 'Apple', 18, 20, 14, 105.00 ],
[ 'Pear', 12, 12, 10, 96.00 ],
[ 'Cherry', 13, 14, 9, 105.00 ],
[ 'Apple', 14, 15, 10, 75.00 ],
[ 'Pear', 9, 8, 8, 76.80 ],
[ 'Apple', 8, 9, 6, 45.00 ],
];
$criteria = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
);
$criteria = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ],
[ '="=Apple"', '>10', NULL, NULL, NULL, '<16' ],
[ '="=Pear"', NULL, NULL, NULL, NULL, NULL ],
];
$worksheet->fromArray( $criteria, NULL, 'A1' )
->fromArray( $database, NULL, 'A4' );
@ -376,21 +398,21 @@ in which you specify a condition for the column.
##### Examples
``` php
$database = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
array( 'Apple', 18, 20, 14, 105.00 ),
array( 'Pear', 12, 12, 10, 96.00 ),
array( 'Cherry', 13, 14, 9, 105.00 ),
array( 'Apple', 14, 15, 10, 75.00 ),
array( 'Pear', 9, 8, 8, 76.80 ),
array( 'Apple', 8, 9, 6, 45.00 ),
);
$database = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ],
[ 'Apple', 18, 20, 14, 105.00 ],
[ 'Pear', 12, 12, 10, 96.00 ],
[ 'Cherry', 13, 14, 9, 105.00 ],
[ 'Apple', 14, 15, 10, 75.00 ],
[ 'Pear', 9, 8, 8, 76.80 ],
[ 'Apple', 8, 9, 6, 45.00 ],
];
$criteria = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
);
$criteria = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ],
[ '="=Apple"', '>10', NULL, NULL, NULL, '<16' ],
[ '="=Pear"', NULL, NULL, NULL, NULL, NULL ],
];
$worksheet->fromArray( $criteria, NULL, 'A1' )
->fromArray( $database, NULL, 'A4' );
@ -447,21 +469,21 @@ in which you specify a condition for the column.
##### Examples
``` php
$database = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
array( 'Apple', 18, 20, 14, 105.00 ),
array( 'Pear', 12, 12, 10, 96.00 ),
array( 'Cherry', 13, 14, 9, 105.00 ),
array( 'Apple', 14, 15, 10, 75.00 ),
array( 'Pear', 9, 8, 8, 76.80 ),
array( 'Apple', 8, 9, 6, 45.00 ),
);
$database = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ],
[ 'Apple', 18, 20, 14, 105.00 ],
[ 'Pear', 12, 12, 10, 96.00 ],
[ 'Cherry', 13, 14, 9, 105.00 ],
[ 'Apple', 14, 15, 10, 75.00 ],
[ 'Pear', 9, 8, 8, 76.80 ],
[ 'Apple', 8, 9, 6, 45.00 ],
];
$criteria = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
);
$criteria = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ],
[ '="=Apple"', '>10', NULL, NULL, NULL, '<16' ],
[ '="=Pear"', NULL, NULL, NULL, NULL, NULL ],
];
$worksheet->fromArray( $criteria, NULL, 'A1' )
->fromArray( $database, NULL, 'A4' );
@ -518,21 +540,21 @@ in which you specify a condition for the column.
#### Examples
``` php
$database = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
array( 'Apple', 18, 20, 14, 105.00 ),
array( 'Pear', 12, 12, 10, 96.00 ),
array( 'Cherry', 13, 14, 9, 105.00 ),
array( 'Apple', 14, 15, 10, 75.00 ),
array( 'Pear', 9, 8, 8, 76.80 ),
array( 'Apple', 8, 9, 6, 45.00 ),
);
$database = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ],
[ 'Apple', 18, 20, 14, 105.00 ],
[ 'Pear', 12, 12, 10, 96.00 ],
[ 'Cherry', 13, 14, 9, 105.00 ],
[ 'Apple', 14, 15, 10, 75.00 ],
[ 'Pear', 9, 8, 8, 76.80 ],
[ 'Apple', 8, 9, 6, 45.00 ],
];
$criteria = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
);
$criteria = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ],
[ '="=Apple"', '>10', NULL, NULL, NULL, '<16' ],
[ '="=Pear"', NULL, NULL, NULL, NULL, NULL ],
];
$worksheet->fromArray( $criteria, NULL, 'A1' )
->fromArray( $database, NULL, 'A4' );
@ -586,21 +608,21 @@ in which you specify a condition for the column.
##### Examples
``` php
$database = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
array( 'Apple', 18, 20, 14, 105.00 ),
array( 'Pear', 12, 12, 10, 96.00 ),
array( 'Cherry', 13, 14, 9, 105.00 ),
array( 'Apple', 14, 15, 10, 75.00 ),
array( 'Pear', 9, 8, 8, 76.80 ),
array( 'Apple', 8, 9, 6, 45.00 ),
);
$database = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ],
[ 'Apple', 18, 20, 14, 105.00 ],
[ 'Pear', 12, 12, 10, 96.00 ],
[ 'Cherry', 13, 14, 9, 105.00 ],
[ 'Apple', 14, 15, 10, 75.00 ],
[ 'Pear', 9, 8, 8, 76.80 ],
[ 'Apple', 8, 9, 6, 45.00 ],
];
$criteria = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
);
$criteria = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ],
[ '="=Apple"', '>10', NULL, NULL, NULL, '<16' ],
[ '="=Pear"', NULL, NULL, NULL, NULL, NULL ],
];
$worksheet->fromArray( $criteria, NULL, 'A1' )
->fromArray( $database, NULL, 'A4' );
@ -654,21 +676,21 @@ in which you specify a condition for the column.
##### Examples
``` php
$database = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
array( 'Apple', 18, 20, 14, 105.00 ),
array( 'Pear', 12, 12, 10, 96.00 ),
array( 'Cherry', 13, 14, 9, 105.00 ),
array( 'Apple', 14, 15, 10, 75.00 ),
array( 'Pear', 9, 8, 8, 76.80 ),
array( 'Apple', 8, 9, 6, 45.00 ),
);
$database = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ],
[ 'Apple', 18, 20, 14, 105.00 ],
[ 'Pear', 12, 12, 10, 96.00 ],
[ 'Cherry', 13, 14, 9, 105.00 ],
[ 'Apple', 14, 15, 10, 75.00 ],
[ 'Pear', 9, 8, 8, 76.80 ],
[ 'Apple', 8, 9, 6, 45.00 ],
];
$criteria = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
);
$criteria = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ],
[ '="=Apple"', '>10', NULL, NULL, NULL, '<16' ],
[ '="=Pear"', NULL, NULL, NULL, NULL, NULL ],
];
$worksheet->fromArray( $criteria, NULL, 'A1' )
->fromArray( $database, NULL, 'A4' );
@ -722,21 +744,21 @@ in which you specify a condition for the column.
##### Examples
``` php
$database = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
array( 'Apple', 18, 20, 14, 105.00 ),
array( 'Pear', 12, 12, 10, 96.00 ),
array( 'Cherry', 13, 14, 9, 105.00 ),
array( 'Apple', 14, 15, 10, 75.00 ),
array( 'Pear', 9, 8, 8, 76.80 ),
array( 'Apple', 8, 9, 6, 45.00 ),
);
$database = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ],
[ 'Apple', 18, 20, 14, 105.00 ],
[ 'Pear', 12, 12, 10, 96.00 ],
[ 'Cherry', 13, 14, 9, 105.00 ],
[ 'Apple', 14, 15, 10, 75.00 ],
[ 'Pear', 9, 8, 8, 76.80 ],
[ 'Apple', 8, 9, 6, 45.00 ],
];
$criteria = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
);
$criteria = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ],
[ '="=Apple"', '>10', NULL, NULL, NULL, '<16' ],
[ '="=Pear"', NULL, NULL, NULL, NULL, NULL ],
];
$worksheet->fromArray( $criteria, NULL, 'A1' )
->fromArray( $database, NULL, 'A4' );
@ -791,21 +813,21 @@ in which you specify a condition for the column.
##### Examples
``` php
$database = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
array( 'Apple', 18, 20, 14, 105.00 ),
array( 'Pear', 12, 12, 10, 96.00 ),
array( 'Cherry', 13, 14, 9, 105.00 ),
array( 'Apple', 14, 15, 10, 75.00 ),
array( 'Pear', 9, 8, 8, 76.80 ),
array( 'Apple', 8, 9, 6, 45.00 ),
);
$database = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ],
[ 'Apple', 18, 20, 14, 105.00 ],
[ 'Pear', 12, 12, 10, 96.00 ],
[ 'Cherry', 13, 14, 9, 105.00 ],
[ 'Apple', 14, 15, 10, 75.00 ],
[ 'Pear', 9, 8, 8, 76.80 ],
[ 'Apple', 8, 9, 6, 45.00 ],
];
$criteria = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
);
$criteria = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ],
[ '="=Apple"', '>10', NULL, NULL, NULL, '<16' ],
[ '="=Pear"', NULL, NULL, NULL, NULL, NULL ],
];
$worksheet->fromArray( $criteria, NULL, 'A1' )
->fromArray( $database, NULL, 'A4' );
@ -860,21 +882,21 @@ in which you specify a condition for the column.
##### Examples
``` php
$database = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
array( 'Apple', 18, 20, 14, 105.00 ),
array( 'Pear', 12, 12, 10, 96.00 ),
array( 'Cherry', 13, 14, 9, 105.00 ),
array( 'Apple', 14, 15, 10, 75.00 ),
array( 'Pear', 9, 8, 8, 76.80 ),
array( 'Apple', 8, 9, 6, 45.00 ),
);
$database = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ],
[ 'Apple', 18, 20, 14, 105.00 ],
[ 'Pear', 12, 12, 10, 96.00 ],
[ 'Cherry', 13, 14, 9, 105.00 ],
[ 'Apple', 14, 15, 10, 75.00 ],
[ 'Pear', 9, 8, 8, 76.80 ],
[ 'Apple', 8, 9, 6, 45.00 ],
];
$criteria = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
);
$criteria = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ],
[ '="=Apple"', '>10', NULL, NULL, NULL, '<16' ],
[ '="=Pear"', NULL, NULL, NULL, NULL, NULL ],
];
$worksheet->fromArray( $criteria, NULL, 'A1' )
->fromArray( $database, NULL, 'A4' );
@ -928,21 +950,21 @@ in which you specify a condition for the column.
##### Examples
``` php
$database = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ),
array( 'Apple', 18, 20, 14, 105.00 ),
array( 'Pear', 12, 12, 10, 96.00 ),
array( 'Cherry', 13, 14, 9, 105.00 ),
array( 'Apple', 14, 15, 10, 75.00 ),
array( 'Pear', 9, 8, 8, 76.80 ),
array( 'Apple', 8, 9, 6, 45.00 ),
);
$database = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit' ],
[ 'Apple', 18, 20, 14, 105.00 ],
[ 'Pear', 12, 12, 10, 96.00 ],
[ 'Cherry', 13, 14, 9, 105.00 ],
[ 'Apple', 14, 15, 10, 75.00 ],
[ 'Pear', 9, 8, 8, 76.80 ],
[ 'Apple', 8, 9, 6, 45.00 ],
];
$criteria = array(
array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ),
array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ),
array( '="=Pear"', NULL, NULL, NULL, NULL, NULL ),
);
$criteria = [
[ 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ],
[ '="=Apple"', '>10', NULL, NULL, NULL, '<16' ],
[ '="=Pear"', NULL, NULL, NULL, NULL, NULL ],
];
$worksheet->fromArray( $criteria, NULL, 'A1' )
->fromArray( $database, NULL, 'A4' );
@ -1046,7 +1068,7 @@ $retVal = $worksheet->getCell('D1')->getCalculatedValue();
``` php
// We're going to be calling the same cell calculation multiple times,
// and expecting different return values, so disable calculation cacheing
\PhpOffice\PhpSpreadsheet\Calculation::getInstance()->setCalculationCacheEnabled(FALSE);
\PhpOffice\PhpSpreadsheet\Calculation\Calculation::getInstance()->setCalculationCacheEnabled(FALSE);
$saveFormat = \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType();
@ -1055,8 +1077,8 @@ $saveFormat = \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType
);
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATE'),
array(2008, 12, 31)
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATE'],
[2008, 12, 31]
);
// $retVal = 39813.0
@ -1065,8 +1087,8 @@ $retVal = call_user_func_array(
);
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATE'),
array(2008, 12, 31)
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATE'],
[2008, 12, 31]
);
// $retVal = 1230681600
@ -1167,38 +1189,38 @@ $date1 = 1193317015; // PHP timestamp for 25-Oct-2007
$date2 = 1449579415; // PHP timestamp for 8-Dec-2015
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATEDIF'),
array($date1, $date2, 'd')
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATEDIF'],
[$date1, $date2, 'd']
);
// $retVal = 2966
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATEDIF'),
array($date1, $date2, 'm')
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATEDIF'],
[$date1, $date2, 'm']
);
// $retVal = 97
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATEDIF'),
array($date1, $date2, 'y')
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATEDIF'],
[$date1, $date2, 'y']
);
// $retVal = 8
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATEDIF'),
array($date1, $date2, 'ym')
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATEDIF'],
[$date1, $date2, 'ym']
);
// $retVal = 1
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATEDIF'),
array($date1, $date2, 'yd')
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATEDIF'],
[$date1, $date2, 'yd']
);
// $retVal = 44
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATEDIF'),
array($date1, $date2, 'md')
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATEDIF'],
[$date1, $date2, 'md']
);
// $retVal = 13
```
@ -1258,7 +1280,7 @@ $retVal = $worksheet->getCell('B4')->getCalculatedValue();
``` php
// We're going to be calling the same cell calculation multiple times,
// and expecting different return values, so disable calculation cacheing
\PhpOffice\PhpSpreadsheet\Calculation::getInstance()->setCalculationCacheEnabled(FALSE);
\PhpOffice\PhpSpreadsheet\Calculation\Calculation::getInstance()->setCalculationCacheEnabled(FALSE);
$saveFormat = \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType();
@ -1267,8 +1289,8 @@ $saveFormat = \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType
);
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATEVALUE'),
array('31-Dec-2008')
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATEVALUE'],
['31-Dec-2008']
);
// $retVal = 39813.0
@ -1277,8 +1299,8 @@ $retVal = call_user_func_array(
);
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATEVALUE'),
array('31-Dec-2008')
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DATEVALUE'],
['31-Dec-2008']
);
// $retVal = 1230681600
@ -1342,8 +1364,8 @@ $retVal = $worksheet->getCell('B3')->getCalculatedValue();
``` php
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DAYOFMONTH'),
array('25-Dec-2008')
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DAYOFMONTH'],
['25-Dec-2008']
);
// $retVal = 25
```
@ -1428,14 +1450,14 @@ $date1 = 37655.0; // Excel timestamp for 25-Oct-2007
$date2 = 39233.0; // Excel timestamp for 8-Dec-2015
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DAYS360'),
array($date1, $date2)
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DAYS360'],
[$date1, $date2]
);
// $retVal = 1558
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DAYS360'),
array($date1, $date2, TRUE)
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'DAYS360'],
[$date1, $date2, TRUE]
);
// $retVal = 1557
```
@ -1508,8 +1530,8 @@ $retVal = $worksheet->getCell('B3')->getCalculatedValue();
);
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'EDATE'),
array('31-Oct-2008',25)
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'EDATE'],
['31-Oct-2008', 25]
);
// $retVal = 40512.0 (30-Nov-2010)
```
@ -1579,8 +1601,8 @@ $retVal = $worksheet->getCell('B3')->getCalculatedValue();
);
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'EOMONTH'),
array('31-Oct-2008',13)
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'EOMONTH'],
['31-Oct-2008', 13]
);
// $retVal = 40147.0 (30-Nov-2010)
```
@ -1637,8 +1659,8 @@ $retVal = $worksheet->getCell('B4')->getCalculatedValue();
``` php
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'HOUROFDAY'),
array('09:30')
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'HOUROFDAY'],
['09:30']
);
// $retVal = 9
```
@ -1695,8 +1717,8 @@ $retVal = $worksheet->getCell('B4')->getCalculatedValue();
``` php
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'MINUTE'),
array('09:30')
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'MINUTE'],
['09:30']
);
// $retVal = 30
```
@ -1748,8 +1770,8 @@ $retVal = $worksheet->getCell('B3')->getCalculatedValue();
``` php
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'MONTHOFYEAR'),
array('14-July-2008')
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'MONTHOFYEAR'],
['14-July-2008']
);
// $retVal = 7
```
@ -1893,8 +1915,8 @@ $retVal = $worksheet->getCell('B4')->getCalculatedValue();
``` php
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'SECOND'),
array('09:30:17')
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'SECOND'],
['09:30:17']
);
// $retVal = 17
```
@ -1977,8 +1999,8 @@ $retVal = $worksheet->getCell('B4')->getCalculatedValue();
``` php
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'WEEKDAY'),
array('14-July-2008')
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'WEEKDAY'],
['14-July-2008']
);
// $retVal = 7
```
@ -2037,8 +2059,8 @@ $retVal = $worksheet->getCell('B3')->getCalculatedValue();
``` php
$retVal = call_user_func_array(
array('\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'YEAR'),
array('14-July-2001')
['\PhpOffice\PhpSpreadsheet\Calculation\Functions', 'YEAR'],
['14-July-2001']
);
// $retVal = 2001
```

View File

@ -425,3 +425,9 @@ All the following methods are affected:
- `PHPExcel_Worksheet::unprotectCellsByColumnAndRow()`
- `PHPExcel_Worksheet_PageSetup::addPrintAreaByColumnAndRow()`
- `PHPExcel_Worksheet_PageSetup::setPrintAreaByColumnAndRow()`
### Removed default values
Default values for many methods were removed when it did not make sense. Typically,
setter methods should not have default values. For a complete list of methods and
their original default values, see [that commit](https://github.com/PHPOffice/PhpSpreadsheet/commit/033a4bdad56340795a5bf7ec3c8a2fde005cda24).

View File

@ -107,7 +107,7 @@ reader to only load the sheets with a given name:
``` php
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$reader->setLoadSheetsOnly( array("Sheet 1", "My special sheet") );
$reader->setLoadSheetsOnly(["Sheet 1", "My special sheet"]);
$spreadsheet = $reader->load("05featuredemo.xlsx");
```
@ -225,7 +225,7 @@ reader to only load the sheets with a given name:
``` php
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls();
$reader->setLoadSheetsOnly( array("Sheet 1", "My special sheet") );
$reader->setLoadSheetsOnly(["Sheet 1", "My special sheet"]);
$spreadsheet = $reader->load("05featuredemo.xls");
```

View File

@ -198,7 +198,7 @@ of sheet names as an array parameter to the `setLoadSheetsOnly()` method.
``` php
$inputFileType = 'Xls';
$inputFileName = './sampleData/example1.xls';
$sheetnames = array('Data Sheet #1','Data Sheet #3');
$sheetnames = ['Data Sheet #1','Data Sheet #3'];
/** Create a new Reader of the type defined in $inputFileType **/
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
@ -292,7 +292,7 @@ class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
{
private $startRow = 0;
private $endRow = 0;
private $columns = array();
private $columns = [];
/** Get the list of rows and columns to read */
public function __construct($startRow, $endRow, $columns) {
@ -395,10 +395,11 @@ the file into that worksheet.
``` php
$inputFileType = 'Csv';
$inputFileNames = array('./sampleData/example1.csv',
$inputFileNames = [
'./sampleData/example1.csv',
'./sampleData/example2.csv'
'./sampleData/example3.csv'
);
];
/** Create a new Reader of the type defined in $inputFileType **/
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);

View File

@ -187,7 +187,7 @@ internal English coding.
``` php
$formula = $spreadsheet->getActiveSheet()->getCell('B8')->getValue();
$translatedFormula = \PhpOffice\PhpSpreadsheet\Calculation::getInstance()->_translateFormulaToLocale($formula);
$translatedFormula = \PhpOffice\PhpSpreadsheet\Calculation\Calculation::getInstance()->_translateFormulaToLocale($formula);
```
You can also create a formula using the function names and argument
@ -196,7 +196,7 @@ English before setting the cell value:
``` php
$formula = '=ДНЕЙ360(ДАТА(2010;2;5);ДАТА(2010;12;31);ИСТИНА)';
$internalFormula = \PhpOffice\PhpSpreadsheet\Calculation::getInstance()->translateFormulaToEnglish($formula);
$internalFormula = \PhpOffice\PhpSpreadsheet\Calculation\Calculation::getInstance()->translateFormulaToEnglish($formula);
$spreadsheet->getActiveSheet()->setCellValue('B8',$internalFormula);
```
@ -461,13 +461,13 @@ To set a print break, use the following code, which sets a row break on
row 10.
``` php
$spreadsheet->getActiveSheet()->setBreak( 'A10' , \PhpOffice\PhpSpreadsheet\Worksheet::BREAK_ROW );
$spreadsheet->getActiveSheet()->setBreak('A10', \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::BREAK_ROW);
```
The following line of code sets a print break on column D:
``` php
$spreadsheet->getActiveSheet()->setBreak( 'D10' , \PhpOffice\PhpSpreadsheet\Worksheet::BREAK_COLUMN );
$spreadsheet->getActiveSheet()->setBreak('D10', \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::BREAK_COLUMN);
```
### Show/hide gridlines when printing
@ -549,29 +549,29 @@ sets a cell's style to font bold, alignment right, top border thin and a
gradient fill:
``` php
$styleArray = array(
'font' => array(
$styleArray = [
'font' => [
'bold' => true,
),
'alignment' => array(
],
'alignment' => [
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT,
),
'borders' => array(
'top' => array(
],
'borders' => [
'top' => [
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
),
),
'fill' => array(
],
],
'fill' => [
'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
'rotation' => 90,
'startColor' => array(
'startColor' => [
'argb' => 'FFA0A0A0',
),
'endColor' => array(
],
'endColor' => [
'argb' => 'FFFFFFFF',
),
),
);
],
],
];
$spreadsheet->getActiveSheet()->getStyle('A3')->applyFromArray($styleArray);
```
@ -690,14 +690,14 @@ selection. Here is how to apply a thick red border outline around cells
B2:G8.
``` php
$styleArray = array(
'borders' => array(
'outline' => array(
$styleArray = [
'borders' => [
'outline' => [
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
'color' => array('argb' => 'FFFF0000'),
),
),
);
'color' => ['argb' => 'FFFF0000'],
],
],
];
$worksheet->getStyle('B2:G8')->applyFromArray($styleArray);
```
@ -1297,14 +1297,14 @@ foreach ($spreadsheet->getActiveSheet()->getDrawingCollection() as $drawing) {
## Add rich text to a cell
Adding rich text to a cell can be done using
`\PhpOffice\PhpSpreadsheet\RichText` instances. Here''s an example, which
`\PhpOffice\PhpSpreadsheet\RichText\RichText` instances. Here''s an example, which
creates the following rich text string:
> This invoice is ***payable within thirty days after the end of the
> month*** unless specified otherwise on the invoice.
``` php
$richText = new \PhpOffice\PhpSpreadsheet\RichText();
$richText = new \PhpOffice\PhpSpreadsheet\RichText\RichText();
$richText->createText('This invoice is ');
$payable = $richText->createTextRun('payable within thirty days after the end of the month');
$payable->getFont()->setBold(true);
@ -1480,15 +1480,15 @@ Set a worksheet to be **hidden** using this code:
``` php
$spreadsheet->getActiveSheet()
->setSheetState(\PhpOffice\PhpSpreadsheet\Worksheet::SHEETSTATE_HIDDEN);
->setSheetState(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::SHEETSTATE_HIDDEN);
```
Sometimes you may even want the worksheet to be **"very hidden"**. The
available sheet states are :
- `\PhpOffice\PhpSpreadsheet\Worksheet::SHEETSTATE_VISIBLE`
- `\PhpOffice\PhpSpreadsheet\Worksheet::SHEETSTATE_HIDDEN`
- `\PhpOffice\PhpSpreadsheet\Worksheet::SHEETSTATE_VERYHIDDEN`
- `\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::SHEETSTATE_VISIBLE`
- `\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::SHEETSTATE_HIDDEN`
- `\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::SHEETSTATE_VERYHIDDEN`
In Excel the sheet state "very hidden" can only be set programmatically,
e.g. with Visual Basic Macro. It is not possible to make such a sheet

View File

@ -80,7 +80,7 @@ whatever you choose) and then insert it into your workbook using the
``` php
// Create a new worksheet called "My Data"
$myWorkSheet = new \PhpOffice\PhpSpreadsheet\Worksheet($spreadsheet, 'My Data');
$myWorkSheet = new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet($spreadsheet, 'My Data');
// Attach the "My Data" worksheet as the first worksheet in the Spreadsheet object
$spreadsheet->addSheet($myWorkSheet, 0);