Merge branch 'develop'
This commit is contained in:
commit
5e49a87746
|
@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
- Fix to getCell() method when cell reference includes a worksheet reference - @MarkBaker
|
- 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)
|
- 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)
|
- 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
|
### General
|
||||||
|
|
||||||
|
|
|
@ -6,76 +6,73 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Calculation Examples</title>
|
<title>PhpSpreadsheet Calculation Examples</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>DAVERAGE</h1>
|
<h1>DAVERAGE</h1>
|
||||||
<h2>Returns the average of selected database entries.</h2>
|
<h2>Returns the average of selected database entries.</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Add some data
|
||||||
$spreadsheet = new Spreadsheet();
|
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
['Apple', 18, 20, 14, 105.00],
|
||||||
|
['Pear', 12, 12, 10, 96.00],
|
||||||
|
['Cherry', 13, 14, 9, 105.00],
|
||||||
|
['Apple', 14, 15, 10, 75.00],
|
||||||
|
['Pear', 9, 8, 8, 76.80],
|
||||||
|
['Apple', 8, 9, 6, 45.00],
|
||||||
|
];
|
||||||
|
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
||||||
|
['="=Apple"', '>10', null, null, null, '<16'],
|
||||||
|
['="=Pear"', null, null, null, null, null],
|
||||||
|
];
|
||||||
|
|
||||||
// Add some data
|
$worksheet->fromArray($criteria, null, 'A1');
|
||||||
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
$worksheet->fromArray($database, null, 'A4');
|
||||||
['Apple', 18, 20, 14, 105.00],
|
|
||||||
['Pear', 12, 12, 10, 96.00],
|
|
||||||
['Cherry', 13, 14, 9, 105.00],
|
|
||||||
['Apple', 14, 15, 10, 75.00],
|
|
||||||
['Pear', 9, 8, 8, 76.80],
|
|
||||||
['Apple', 8, 9, 6, 45.00],
|
|
||||||
];
|
|
||||||
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
|
||||||
['="=Apple"', '>10', null, null, null, '<16'],
|
|
||||||
['="=Pear"', null, null, null, null, null],
|
|
||||||
];
|
|
||||||
|
|
||||||
$worksheet->fromArray($criteria, null, 'A1');
|
$worksheet->setCellValue('A12', 'The Average yield of Apple trees over 10\' in height');
|
||||||
$worksheet->fromArray($database, null, 'A4');
|
$worksheet->setCellValue('B12', '=DAVERAGE(A4:E10,"Yield",A1:B2)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A12', 'The Average yield of Apple trees over 10\' in height');
|
$worksheet->setCellValue('A13', 'The Average age of all Apple and Pear trees in the orchard');
|
||||||
$worksheet->setCellValue('B12', '=DAVERAGE(A4:E10,"Yield",A1:B2)');
|
$worksheet->setCellValue('B13', '=DAVERAGE(A4:E10,3,A1:A3)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A13', 'The Average age of all Apple and Pear trees in the orchard');
|
echo '<hr />';
|
||||||
$worksheet->setCellValue('B13', '=DAVERAGE(A4:E10,3,A1:A3)');
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo '<h4>Database</h4>';
|
||||||
|
|
||||||
echo '<h4>Database</h4>';
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
|
var_dump($databaseData);
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
echo '<hr />';
|
||||||
var_dump($databaseData);
|
|
||||||
|
|
||||||
echo '<hr />';
|
// Test the formulae
|
||||||
|
echo '<h4>Criteria</h4>';
|
||||||
|
|
||||||
// Test the formulae
|
$criteriaData = $worksheet->rangeToArray('A1:B2', null, true, true, true);
|
||||||
echo '<h4>Criteria</h4>';
|
var_dump($criteriaData);
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:B2', null, true, true, true);
|
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
||||||
var_dump($criteriaData);
|
echo 'DAVERAGE() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
||||||
|
|
||||||
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
echo '<h4>Criteria</h4>';
|
||||||
echo 'DAVERAGE() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
|
||||||
|
|
||||||
echo '<h4>Criteria</h4>';
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
|
var_dump($criteriaData);
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||||
var_dump($criteriaData);
|
echo 'DAVERAGE() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||||
|
?>
|
||||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
<body>
|
||||||
echo 'DAVERAGE() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,76 +6,73 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Calculation Examples</title>
|
<title>PhpSpreadsheet Calculation Examples</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>DCOUNT</h1>
|
<h1>DCOUNT</h1>
|
||||||
<h2>Counts the cells that contain numbers in a database.</h2>
|
<h2>Counts the cells that contain numbers in a database.</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Add some data
|
||||||
$spreadsheet = new Spreadsheet();
|
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
['Apple', 18, 20, 14, 105.00],
|
||||||
|
['Pear', 12, 12, 10, 96.00],
|
||||||
|
['Cherry', 13, 14, 9, 105.00],
|
||||||
|
['Apple', 14, 15, 10, 75.00],
|
||||||
|
['Pear', 9, 8, 8, 76.80],
|
||||||
|
['Apple', 8, 9, 6, 45.00],
|
||||||
|
];
|
||||||
|
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
||||||
|
['="=Apple"', '>10', null, null, null, '<16'],
|
||||||
|
['="=Pear"', null, null, null, null, null],
|
||||||
|
];
|
||||||
|
|
||||||
// Add some data
|
$worksheet->fromArray($criteria, null, 'A1');
|
||||||
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
$worksheet->fromArray($database, null, 'A4');
|
||||||
['Apple', 18, 20, 14, 105.00],
|
|
||||||
['Pear', 12, 12, 10, 96.00],
|
|
||||||
['Cherry', 13, 14, 9, 105.00],
|
|
||||||
['Apple', 14, 15, 10, 75.00],
|
|
||||||
['Pear', 9, 8, 8, 76.80],
|
|
||||||
['Apple', 8, 9, 6, 45.00],
|
|
||||||
];
|
|
||||||
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
|
||||||
['="=Apple"', '>10', null, null, null, '<16'],
|
|
||||||
['="=Pear"', null, null, null, null, null],
|
|
||||||
];
|
|
||||||
|
|
||||||
$worksheet->fromArray($criteria, null, 'A1');
|
$worksheet->setCellValue('A12', 'The Number of Apple trees over 10\' in height');
|
||||||
$worksheet->fromArray($database, null, 'A4');
|
$worksheet->setCellValue('B12', '=DCOUNT(A4:E10,"Yield",A1:B2)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A12', 'The Number of Apple trees over 10\' in height');
|
$worksheet->setCellValue('A13', 'The Number of Apple and Pear trees in the orchard');
|
||||||
$worksheet->setCellValue('B12', '=DCOUNT(A4:E10,"Yield",A1:B2)');
|
$worksheet->setCellValue('B13', '=DCOUNT(A4:E10,3,A1:A3)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A13', 'The Number of Apple and Pear trees in the orchard');
|
echo '<hr />';
|
||||||
$worksheet->setCellValue('B13', '=DCOUNT(A4:E10,3,A1:A3)');
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo '<h4>Database</h4>';
|
||||||
|
|
||||||
echo '<h4>Database</h4>';
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
|
var_dump($databaseData);
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
echo '<hr />';
|
||||||
var_dump($databaseData);
|
|
||||||
|
|
||||||
echo '<hr />';
|
// Test the formulae
|
||||||
|
echo '<h4>Criteria</h4>';
|
||||||
|
|
||||||
// Test the formulae
|
$criteriaData = $worksheet->rangeToArray('A1:B2', null, true, true, true);
|
||||||
echo '<h4>Criteria</h4>';
|
var_dump($criteriaData);
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:B2', null, true, true, true);
|
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
||||||
var_dump($criteriaData);
|
echo 'DCOUNT() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
||||||
|
|
||||||
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
echo '<h4>Criteria</h4>';
|
||||||
echo 'DCOUNT() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
|
||||||
|
|
||||||
echo '<h4>Criteria</h4>';
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
|
var_dump($criteriaData);
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||||
var_dump($criteriaData);
|
echo 'DCOUNT() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||||
|
?>
|
||||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
<body>
|
||||||
echo 'DCOUNT() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,72 +6,69 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Calculation Examples</title>
|
<title>PhpSpreadsheet Calculation Examples</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>DGET</h1>
|
<h1>DGET</h1>
|
||||||
<h2>Extracts a single value from a column of a list or database that matches conditions that you specify.</h2>
|
<h2>Extracts a single value from a column of a list or database that matches conditions that you specify.</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Add some data
|
||||||
$spreadsheet = new Spreadsheet();
|
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
['Apple', 18, 20, 14, 105.00],
|
||||||
|
['Pear', 12, 12, 10, 96.00],
|
||||||
|
['Cherry', 13, 14, 9, 105.00],
|
||||||
|
['Apple', 14, 15, 10, 75.00],
|
||||||
|
['Pear', 9, 8, 8, 76.80],
|
||||||
|
['Apple', 8, 9, 6, 45.00],
|
||||||
|
];
|
||||||
|
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
||||||
|
['="=Apple"', '>10', null, null, null, '<16'],
|
||||||
|
['="=Pear"', null, null, null, null, null],
|
||||||
|
];
|
||||||
|
|
||||||
// Add some data
|
$worksheet->fromArray($criteria, null, 'A1');
|
||||||
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
$worksheet->fromArray($database, null, 'A4');
|
||||||
['Apple', 18, 20, 14, 105.00],
|
|
||||||
['Pear', 12, 12, 10, 96.00],
|
|
||||||
['Cherry', 13, 14, 9, 105.00],
|
|
||||||
['Apple', 14, 15, 10, 75.00],
|
|
||||||
['Pear', 9, 8, 8, 76.80],
|
|
||||||
['Apple', 8, 9, 6, 45.00],
|
|
||||||
];
|
|
||||||
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
|
||||||
['="=Apple"', '>10', null, null, null, '<16'],
|
|
||||||
['="=Pear"', null, null, null, null, null],
|
|
||||||
];
|
|
||||||
|
|
||||||
$worksheet->fromArray($criteria, null, 'A1');
|
$worksheet->setCellValue('A12', 'The height of the Apple tree between 10\' and 16\' tall');
|
||||||
$worksheet->fromArray($database, null, 'A4');
|
$worksheet->setCellValue('B12', '=DGET(A4:E10,"Height",A1:F2)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A12', 'The height of the Apple tree between 10\' and 16\' tall');
|
echo '<hr />';
|
||||||
$worksheet->setCellValue('B12', '=DGET(A4:E10,"Height",A1:F2)');
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo '<h4>Database</h4>';
|
||||||
|
|
||||||
echo '<h4>Database</h4>';
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
|
var_dump($databaseData);
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
echo '<hr />';
|
||||||
var_dump($databaseData);
|
|
||||||
|
|
||||||
echo '<hr />';
|
// Test the formulae
|
||||||
|
echo '<h4>Criteria</h4>';
|
||||||
|
|
||||||
// Test the formulae
|
echo 'ALL' . '<br /><br />';
|
||||||
echo '<h4>Criteria</h4>';
|
|
||||||
|
|
||||||
echo 'ALL' . '<br /><br />';
|
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
||||||
|
echo 'DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
||||||
|
|
||||||
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
echo '<h4>Criteria</h4>';
|
||||||
echo 'DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
|
||||||
|
|
||||||
echo '<h4>Criteria</h4>';
|
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
||||||
|
var_dump($criteriaData);
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||||
var_dump($criteriaData);
|
echo 'DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||||
|
?>
|
||||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
<body>
|
||||||
echo 'DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,75 +6,72 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Calculation Examples</title>
|
<title>PhpSpreadsheet Calculation Examples</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>DMAX</h1>
|
<h1>DMAX</h1>
|
||||||
<h2>Returns the maximum value from selected database entries.</h2>
|
<h2>Returns the maximum value from selected database entries.</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Add some data
|
||||||
$spreadsheet = new Spreadsheet();
|
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
['Apple', 18, 20, 14, 105.00],
|
||||||
|
['Pear', 12, 12, 10, 96.00],
|
||||||
|
['Cherry', 13, 14, 9, 105.00],
|
||||||
|
['Apple', 14, 15, 10, 75.00],
|
||||||
|
['Pear', 9, 8, 8, 76.80],
|
||||||
|
['Apple', 8, 9, 6, 45.00],
|
||||||
|
];
|
||||||
|
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
||||||
|
['="=Apple"', '>10', null, null, null, '<16'],
|
||||||
|
['="=Pear"', null, null, null, null, null],
|
||||||
|
];
|
||||||
|
|
||||||
// Add some data
|
$worksheet->fromArray($criteria, null, 'A1');
|
||||||
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
$worksheet->fromArray($database, null, 'A4');
|
||||||
['Apple', 18, 20, 14, 105.00],
|
|
||||||
['Pear', 12, 12, 10, 96.00],
|
|
||||||
['Cherry', 13, 14, 9, 105.00],
|
|
||||||
['Apple', 14, 15, 10, 75.00],
|
|
||||||
['Pear', 9, 8, 8, 76.80],
|
|
||||||
['Apple', 8, 9, 6, 45.00],
|
|
||||||
];
|
|
||||||
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
|
||||||
['="=Apple"', '>10', null, null, null, '<16'],
|
|
||||||
['="=Pear"', null, null, null, null, null],
|
|
||||||
];
|
|
||||||
|
|
||||||
$worksheet->fromArray($criteria, null, 'A1');
|
$worksheet->setCellValue('A12', 'The tallest tree in the orchard');
|
||||||
$worksheet->fromArray($database, null, 'A4');
|
$worksheet->setCellValue('B12', '=DMAX(A4:E10,"Height",A4:E10)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A12', 'The tallest tree in the orchard');
|
$worksheet->setCellValue('A13', 'The Oldest apple tree in the orchard');
|
||||||
$worksheet->setCellValue('B12', '=DMAX(A4:E10,"Height",A4:E10)');
|
$worksheet->setCellValue('B13', '=DMAX(A4:E10,3,A1:A2)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A13', 'The Oldest apple tree in the orchard');
|
echo '<hr />';
|
||||||
$worksheet->setCellValue('B13', '=DMAX(A4:E10,3,A1:A2)');
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo '<h4>Database</h4>';
|
||||||
|
|
||||||
echo '<h4>Database</h4>';
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
|
var_dump($databaseData);
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
echo '<hr />';
|
||||||
var_dump($databaseData);
|
|
||||||
|
|
||||||
echo '<hr />';
|
// Test the formulae
|
||||||
|
echo '<h4>Criteria</h4>';
|
||||||
|
|
||||||
// Test the formulae
|
echo 'ALL' . '<br /><br />';
|
||||||
echo '<h4>Criteria</h4>';
|
|
||||||
|
|
||||||
echo 'ALL' . '<br /><br />';
|
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
||||||
|
echo 'DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
||||||
|
|
||||||
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
echo '<h4>Criteria</h4>';
|
||||||
echo 'DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
|
||||||
|
|
||||||
echo '<h4>Criteria</h4>';
|
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
||||||
|
var_dump($criteriaData);
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||||
var_dump($criteriaData);
|
echo 'DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||||
|
?>
|
||||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
<body>
|
||||||
echo 'DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,75 +6,72 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Calculation Examples</title>
|
<title>PhpSpreadsheet Calculation Examples</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>DMIN</h1>
|
<h1>DMIN</h1>
|
||||||
<h2>Returns the minimum value from selected database entries.</h2>
|
<h2>Returns the minimum value from selected database entries.</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Add some data
|
||||||
$spreadsheet = new Spreadsheet();
|
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
['Apple', 18, 20, 14, 105.00],
|
||||||
|
['Pear', 12, 12, 10, 96.00],
|
||||||
|
['Cherry', 13, 14, 9, 105.00],
|
||||||
|
['Apple', 14, 15, 10, 75.00],
|
||||||
|
['Pear', 9, 8, 8, 76.80],
|
||||||
|
['Apple', 8, 9, 6, 45.00],
|
||||||
|
];
|
||||||
|
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
||||||
|
['="=Apple"', '>10', null, null, null, '<16'],
|
||||||
|
['="=Pear"', null, null, null, null, null],
|
||||||
|
];
|
||||||
|
|
||||||
// Add some data
|
$worksheet->fromArray($criteria, null, 'A1');
|
||||||
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
$worksheet->fromArray($database, null, 'A4');
|
||||||
['Apple', 18, 20, 14, 105.00],
|
|
||||||
['Pear', 12, 12, 10, 96.00],
|
|
||||||
['Cherry', 13, 14, 9, 105.00],
|
|
||||||
['Apple', 14, 15, 10, 75.00],
|
|
||||||
['Pear', 9, 8, 8, 76.80],
|
|
||||||
['Apple', 8, 9, 6, 45.00],
|
|
||||||
];
|
|
||||||
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
|
||||||
['="=Apple"', '>10', null, null, null, '<16'],
|
|
||||||
['="=Pear"', null, null, null, null, null],
|
|
||||||
];
|
|
||||||
|
|
||||||
$worksheet->fromArray($criteria, null, 'A1');
|
$worksheet->setCellValue('A12', 'The shortest tree in the orchard');
|
||||||
$worksheet->fromArray($database, null, 'A4');
|
$worksheet->setCellValue('B12', '=DMIN(A4:E10,"Height",A4:E10)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A12', 'The shortest tree in the orchard');
|
$worksheet->setCellValue('A13', 'The Youngest apple tree in the orchard');
|
||||||
$worksheet->setCellValue('B12', '=DMIN(A4:E10,"Height",A4:E10)');
|
$worksheet->setCellValue('B13', '=DMIN(A4:E10,3,A1:A2)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A13', 'The Youngest apple tree in the orchard');
|
echo '<hr />';
|
||||||
$worksheet->setCellValue('B13', '=DMIN(A4:E10,3,A1:A2)');
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo '<h4>Database</h4>';
|
||||||
|
|
||||||
echo '<h4>Database</h4>';
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
|
var_dump($databaseData);
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
echo '<hr />';
|
||||||
var_dump($databaseData);
|
|
||||||
|
|
||||||
echo '<hr />';
|
// Test the formulae
|
||||||
|
echo '<h4>Criteria</h4>';
|
||||||
|
|
||||||
// Test the formulae
|
echo 'ALL' . '<br /><br />';
|
||||||
echo '<h4>Criteria</h4>';
|
|
||||||
|
|
||||||
echo 'ALL' . '<br /><br />';
|
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
||||||
|
echo 'DMIN() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
||||||
|
|
||||||
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
echo '<h4>Criteria</h4>';
|
||||||
echo 'DMIN() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
|
||||||
|
|
||||||
echo '<h4>Criteria</h4>';
|
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
||||||
|
var_dump($criteriaData);
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||||
var_dump($criteriaData);
|
echo 'DMIN() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||||
|
?>
|
||||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
<body>
|
||||||
echo 'DMIN() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,72 +6,69 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Calculation Examples</title>
|
<title>PhpSpreadsheet Calculation Examples</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>DPRODUCT</h1>
|
<h1>DPRODUCT</h1>
|
||||||
<h2>Multiplies the values in a column of a list or database that match conditions that you specify.</h2>
|
<h2>Multiplies the values in a column of a list or database that match conditions that you specify.</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Add some data
|
||||||
$spreadsheet = new Spreadsheet();
|
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
['Apple', 18, 20, 14, 105.00],
|
||||||
|
['Pear', 12, 12, 10, 96.00],
|
||||||
|
['Cherry', 13, 14, 9, 105.00],
|
||||||
|
['Apple', 14, 15, 10, 75.00],
|
||||||
|
['Pear', 9, 8, 8, 76.80],
|
||||||
|
['Apple', 8, 9, 6, 45.00],
|
||||||
|
];
|
||||||
|
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
||||||
|
['="=Apple"', '>10', null, null, null, '<16'],
|
||||||
|
['="=Pear"', null, null, null, null, null],
|
||||||
|
];
|
||||||
|
|
||||||
// Add some data
|
$worksheet->fromArray($criteria, null, 'A1');
|
||||||
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
$worksheet->fromArray($database, null, 'A4');
|
||||||
['Apple', 18, 20, 14, 105.00],
|
|
||||||
['Pear', 12, 12, 10, 96.00],
|
|
||||||
['Cherry', 13, 14, 9, 105.00],
|
|
||||||
['Apple', 14, 15, 10, 75.00],
|
|
||||||
['Pear', 9, 8, 8, 76.80],
|
|
||||||
['Apple', 8, 9, 6, 45.00],
|
|
||||||
];
|
|
||||||
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
|
||||||
['="=Apple"', '>10', null, null, null, '<16'],
|
|
||||||
['="=Pear"', null, null, null, null, null],
|
|
||||||
];
|
|
||||||
|
|
||||||
$worksheet->fromArray($criteria, null, 'A1');
|
$worksheet->setCellValue('A12', 'The product of the yields of all Apple trees over 10\' in the orchard');
|
||||||
$worksheet->fromArray($database, null, 'A4');
|
$worksheet->setCellValue('B12', '=DPRODUCT(A4:E10,"Yield",A1:B2)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A12', 'The product of the yields of all Apple trees over 10\' in the orchard');
|
echo '<hr />';
|
||||||
$worksheet->setCellValue('B12', '=DPRODUCT(A4:E10,"Yield",A1:B2)');
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo '<h4>Database</h4>';
|
||||||
|
|
||||||
echo '<h4>Database</h4>';
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
|
var_dump($databaseData);
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
echo '<hr />';
|
||||||
var_dump($databaseData);
|
|
||||||
|
|
||||||
echo '<hr />';
|
// Test the formulae
|
||||||
|
echo '<h4>Criteria</h4>';
|
||||||
|
|
||||||
// Test the formulae
|
echo 'ALL' . '<br /><br />';
|
||||||
echo '<h4>Criteria</h4>';
|
|
||||||
|
|
||||||
echo 'ALL' . '<br /><br />';
|
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
||||||
|
echo 'DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
||||||
|
|
||||||
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
echo '<h4>Criteria</h4>';
|
||||||
echo 'DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
|
||||||
|
|
||||||
echo '<h4>Criteria</h4>';
|
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
||||||
|
var_dump($criteriaData);
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
|
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||||
var_dump($criteriaData);
|
echo 'DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||||
|
?>
|
||||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
<body>
|
||||||
echo 'DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,76 +6,73 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Calculation Examples</title>
|
<title>PhpSpreadsheet Calculation Examples</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>DSTDEV</h1>
|
<h1>DSTDEV</h1>
|
||||||
<h2>Estimates the standard deviation based on a sample of selected database entries.</h2>
|
<h2>Estimates the standard deviation based on a sample of selected database entries.</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Add some data
|
||||||
$spreadsheet = new Spreadsheet();
|
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
['Apple', 18, 20, 14, 105.00],
|
||||||
|
['Pear', 12, 12, 10, 96.00],
|
||||||
|
['Cherry', 13, 14, 9, 105.00],
|
||||||
|
['Apple', 14, 15, 10, 75.00],
|
||||||
|
['Pear', 9, 8, 8, 76.80],
|
||||||
|
['Apple', 8, 9, 6, 45.00],
|
||||||
|
];
|
||||||
|
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
||||||
|
['="=Apple"', '>10', null, null, null, '<16'],
|
||||||
|
['="=Pear"', null, null, null, null, null],
|
||||||
|
];
|
||||||
|
|
||||||
// Add some data
|
$worksheet->fromArray($criteria, null, 'A1');
|
||||||
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
$worksheet->fromArray($database, null, 'A4');
|
||||||
['Apple', 18, 20, 14, 105.00],
|
|
||||||
['Pear', 12, 12, 10, 96.00],
|
|
||||||
['Cherry', 13, 14, 9, 105.00],
|
|
||||||
['Apple', 14, 15, 10, 75.00],
|
|
||||||
['Pear', 9, 8, 8, 76.80],
|
|
||||||
['Apple', 8, 9, 6, 45.00],
|
|
||||||
];
|
|
||||||
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
|
||||||
['="=Apple"', '>10', null, null, null, '<16'],
|
|
||||||
['="=Pear"', null, null, null, null, null],
|
|
||||||
];
|
|
||||||
|
|
||||||
$worksheet->fromArray($criteria, null, 'A1');
|
$worksheet->setCellValue('A12', 'The estimated standard deviation in the yield of Apple and Pear trees');
|
||||||
$worksheet->fromArray($database, null, 'A4');
|
$worksheet->setCellValue('B12', '=DSTDEV(A4:E10,"Yield",A1:A3)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A12', 'The estimated standard deviation in the yield of Apple and Pear trees');
|
$worksheet->setCellValue('A13', 'The estimated standard deviation in height of Apple and Pear trees');
|
||||||
$worksheet->setCellValue('B12', '=DSTDEV(A4:E10,"Yield",A1:A3)');
|
$worksheet->setCellValue('B13', '=DSTDEV(A4:E10,2,A1:A3)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A13', 'The estimated standard deviation in height of Apple and Pear trees');
|
echo '<hr />';
|
||||||
$worksheet->setCellValue('B13', '=DSTDEV(A4:E10,2,A1:A3)');
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo '<h4>Database</h4>';
|
||||||
|
|
||||||
echo '<h4>Database</h4>';
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
|
var_dump($databaseData);
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
echo '<hr />';
|
||||||
var_dump($databaseData);
|
|
||||||
|
|
||||||
echo '<hr />';
|
// Test the formulae
|
||||||
|
echo '<h4>Criteria</h4>';
|
||||||
|
|
||||||
// Test the formulae
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
echo '<h4>Criteria</h4>';
|
var_dump($criteriaData);
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
||||||
var_dump($criteriaData);
|
echo 'DSTDEV() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
||||||
|
|
||||||
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
echo '<h4>Criteria</h4>';
|
||||||
echo 'DSTDEV() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
|
||||||
|
|
||||||
echo '<h4>Criteria</h4>';
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
|
var_dump($criteriaData);
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||||
var_dump($criteriaData);
|
echo 'DSTDEV() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||||
|
?>
|
||||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
<body>
|
||||||
echo 'DSTDEV() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,76 +6,73 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Calculation Examples</title>
|
<title>PhpSpreadsheet Calculation Examples</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>DSTDEVP</h1>
|
<h1>DSTDEVP</h1>
|
||||||
<h2>Calculates the standard deviation based on the entire population of selected database entries.</h2>
|
<h2>Calculates the standard deviation based on the entire population of selected database entries.</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Add some data
|
||||||
$spreadsheet = new Spreadsheet();
|
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
['Apple', 18, 20, 14, 105.00],
|
||||||
|
['Pear', 12, 12, 10, 96.00],
|
||||||
|
['Cherry', 13, 14, 9, 105.00],
|
||||||
|
['Apple', 14, 15, 10, 75.00],
|
||||||
|
['Pear', 9, 8, 8, 76.80],
|
||||||
|
['Apple', 8, 9, 6, 45.00],
|
||||||
|
];
|
||||||
|
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
||||||
|
['="=Apple"', '>10', null, null, null, '<16'],
|
||||||
|
['="=Pear"', null, null, null, null, null],
|
||||||
|
];
|
||||||
|
|
||||||
// Add some data
|
$worksheet->fromArray($criteria, null, 'A1');
|
||||||
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
$worksheet->fromArray($database, null, 'A4');
|
||||||
['Apple', 18, 20, 14, 105.00],
|
|
||||||
['Pear', 12, 12, 10, 96.00],
|
|
||||||
['Cherry', 13, 14, 9, 105.00],
|
|
||||||
['Apple', 14, 15, 10, 75.00],
|
|
||||||
['Pear', 9, 8, 8, 76.80],
|
|
||||||
['Apple', 8, 9, 6, 45.00],
|
|
||||||
];
|
|
||||||
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
|
||||||
['="=Apple"', '>10', null, null, null, '<16'],
|
|
||||||
['="=Pear"', null, null, null, null, null],
|
|
||||||
];
|
|
||||||
|
|
||||||
$worksheet->fromArray($criteria, null, 'A1');
|
$worksheet->setCellValue('A12', 'The standard deviation in the yield of Apple and Pear trees');
|
||||||
$worksheet->fromArray($database, null, 'A4');
|
$worksheet->setCellValue('B12', '=DSTDEVP(A4:E10,"Yield",A1:A3)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A12', 'The standard deviation in the yield of Apple and Pear trees');
|
$worksheet->setCellValue('A13', 'The standard deviation in height of Apple and Pear trees');
|
||||||
$worksheet->setCellValue('B12', '=DSTDEVP(A4:E10,"Yield",A1:A3)');
|
$worksheet->setCellValue('B13', '=DSTDEVP(A4:E10,2,A1:A3)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A13', 'The standard deviation in height of Apple and Pear trees');
|
echo '<hr />';
|
||||||
$worksheet->setCellValue('B13', '=DSTDEVP(A4:E10,2,A1:A3)');
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo '<h4>Database</h4>';
|
||||||
|
|
||||||
echo '<h4>Database</h4>';
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
|
var_dump($databaseData);
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
echo '<hr />';
|
||||||
var_dump($databaseData);
|
|
||||||
|
|
||||||
echo '<hr />';
|
// Test the formulae
|
||||||
|
echo '<h4>Criteria</h4>';
|
||||||
|
|
||||||
// Test the formulae
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
echo '<h4>Criteria</h4>';
|
var_dump($criteriaData);
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
||||||
var_dump($criteriaData);
|
echo 'DSTDEVP() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
||||||
|
|
||||||
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
echo '<h4>Criteria</h4>';
|
||||||
echo 'DSTDEVP() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
|
||||||
|
|
||||||
echo '<h4>Criteria</h4>';
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
|
var_dump($criteriaData);
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||||
var_dump($criteriaData);
|
echo 'DSTDEVP() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||||
|
?>
|
||||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
<body>
|
||||||
echo 'DSTDEVP() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,76 +6,73 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Calculation Examples</title>
|
<title>PhpSpreadsheet Calculation Examples</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>DVAR</h1>
|
<h1>DVAR</h1>
|
||||||
<h2>Estimates variance based on a sample from selected database entries.</h2>
|
<h2>Estimates variance based on a sample from selected database entries.</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Add some data
|
||||||
$spreadsheet = new Spreadsheet();
|
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
['Apple', 18, 20, 14, 105.00],
|
||||||
|
['Pear', 12, 12, 10, 96.00],
|
||||||
|
['Cherry', 13, 14, 9, 105.00],
|
||||||
|
['Apple', 14, 15, 10, 75.00],
|
||||||
|
['Pear', 9, 8, 8, 76.80],
|
||||||
|
['Apple', 8, 9, 6, 45.00],
|
||||||
|
];
|
||||||
|
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
||||||
|
['="=Apple"', '>10', null, null, null, '<16'],
|
||||||
|
['="=Pear"', null, null, null, null, null],
|
||||||
|
];
|
||||||
|
|
||||||
// Add some data
|
$worksheet->fromArray($criteria, null, 'A1');
|
||||||
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
$worksheet->fromArray($database, null, 'A4');
|
||||||
['Apple', 18, 20, 14, 105.00],
|
|
||||||
['Pear', 12, 12, 10, 96.00],
|
|
||||||
['Cherry', 13, 14, 9, 105.00],
|
|
||||||
['Apple', 14, 15, 10, 75.00],
|
|
||||||
['Pear', 9, 8, 8, 76.80],
|
|
||||||
['Apple', 8, 9, 6, 45.00],
|
|
||||||
];
|
|
||||||
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
|
||||||
['="=Apple"', '>10', null, null, null, '<16'],
|
|
||||||
['="=Pear"', null, null, null, null, null],
|
|
||||||
];
|
|
||||||
|
|
||||||
$worksheet->fromArray($criteria, null, 'A1');
|
$worksheet->setCellValue('A12', 'The estimated variance in the yield of Apple and Pear trees');
|
||||||
$worksheet->fromArray($database, null, 'A4');
|
$worksheet->setCellValue('B12', '=DVAR(A4:E10,"Yield",A1:A3)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A12', 'The estimated variance in the yield of Apple and Pear trees');
|
$worksheet->setCellValue('A13', 'The estimated variance in height of Apple and Pear trees');
|
||||||
$worksheet->setCellValue('B12', '=DVAR(A4:E10,"Yield",A1:A3)');
|
$worksheet->setCellValue('B13', '=DVAR(A4:E10,2,A1:A3)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A13', 'The estimated variance in height of Apple and Pear trees');
|
echo '<hr />';
|
||||||
$worksheet->setCellValue('B13', '=DVAR(A4:E10,2,A1:A3)');
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo '<h4>Database</h4>';
|
||||||
|
|
||||||
echo '<h4>Database</h4>';
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
|
var_dump($databaseData);
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
echo '<hr />';
|
||||||
var_dump($databaseData);
|
|
||||||
|
|
||||||
echo '<hr />';
|
// Test the formulae
|
||||||
|
echo '<h4>Criteria</h4>';
|
||||||
|
|
||||||
// Test the formulae
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
echo '<h4>Criteria</h4>';
|
var_dump($criteriaData);
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
||||||
var_dump($criteriaData);
|
echo 'DVAR() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
||||||
|
|
||||||
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
echo '<h4>Criteria</h4>';
|
||||||
echo 'DVAR() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
|
||||||
|
|
||||||
echo '<h4>Criteria</h4>';
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
|
var_dump($criteriaData);
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||||
var_dump($criteriaData);
|
echo 'DVAR() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||||
|
?>
|
||||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
<body>
|
||||||
echo 'DVAR() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,76 +6,73 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Calculation Examples</title>
|
<title>PhpSpreadsheet Calculation Examples</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>DVARP</h1>
|
<h1>DVARP</h1>
|
||||||
<h2>Calculates variance based on the entire population of selected database entries,</h2>
|
<h2>Calculates variance based on the entire population of selected database entries,</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Add some data
|
||||||
$spreadsheet = new Spreadsheet();
|
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
['Apple', 18, 20, 14, 105.00],
|
||||||
|
['Pear', 12, 12, 10, 96.00],
|
||||||
|
['Cherry', 13, 14, 9, 105.00],
|
||||||
|
['Apple', 14, 15, 10, 75.00],
|
||||||
|
['Pear', 9, 8, 8, 76.80],
|
||||||
|
['Apple', 8, 9, 6, 45.00],
|
||||||
|
];
|
||||||
|
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
||||||
|
['="=Apple"', '>10', null, null, null, '<16'],
|
||||||
|
['="=Pear"', null, null, null, null, null],
|
||||||
|
];
|
||||||
|
|
||||||
// Add some data
|
$worksheet->fromArray($criteria, null, 'A1');
|
||||||
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
|
$worksheet->fromArray($database, null, 'A4');
|
||||||
['Apple', 18, 20, 14, 105.00],
|
|
||||||
['Pear', 12, 12, 10, 96.00],
|
|
||||||
['Cherry', 13, 14, 9, 105.00],
|
|
||||||
['Apple', 14, 15, 10, 75.00],
|
|
||||||
['Pear', 9, 8, 8, 76.80],
|
|
||||||
['Apple', 8, 9, 6, 45.00],
|
|
||||||
];
|
|
||||||
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
|
|
||||||
['="=Apple"', '>10', null, null, null, '<16'],
|
|
||||||
['="=Pear"', null, null, null, null, null],
|
|
||||||
];
|
|
||||||
|
|
||||||
$worksheet->fromArray($criteria, null, 'A1');
|
$worksheet->setCellValue('A12', 'The variance in the yield of Apple and Pear trees');
|
||||||
$worksheet->fromArray($database, null, 'A4');
|
$worksheet->setCellValue('B12', '=DVARP(A4:E10,"Yield",A1:A3)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A12', 'The variance in the yield of Apple and Pear trees');
|
$worksheet->setCellValue('A13', 'The variance in height of Apple and Pear trees');
|
||||||
$worksheet->setCellValue('B12', '=DVARP(A4:E10,"Yield",A1:A3)');
|
$worksheet->setCellValue('B13', '=DVARP(A4:E10,2,A1:A3)');
|
||||||
|
|
||||||
$worksheet->setCellValue('A13', 'The variance in height of Apple and Pear trees');
|
echo '<hr />';
|
||||||
$worksheet->setCellValue('B13', '=DVARP(A4:E10,2,A1:A3)');
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo '<h4>Database</h4>';
|
||||||
|
|
||||||
echo '<h4>Database</h4>';
|
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
||||||
|
var_dump($databaseData);
|
||||||
|
|
||||||
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
|
echo '<hr />';
|
||||||
var_dump($databaseData);
|
|
||||||
|
|
||||||
echo '<hr />';
|
// Test the formulae
|
||||||
|
echo '<h4>Criteria</h4>';
|
||||||
|
|
||||||
// Test the formulae
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
echo '<h4>Criteria</h4>';
|
var_dump($criteriaData);
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
||||||
var_dump($criteriaData);
|
echo 'DVARP() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
||||||
|
|
||||||
echo $worksheet->getCell('A12')->getValue() . '<br />';
|
echo '<h4>Criteria</h4>';
|
||||||
echo 'DVARP() Result is ' . $worksheet->getCell('B12')->getCalculatedValue() . '<br /><br />';
|
|
||||||
|
|
||||||
echo '<h4>Criteria</h4>';
|
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
||||||
|
var_dump($criteriaData);
|
||||||
|
|
||||||
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
|
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
||||||
var_dump($criteriaData);
|
echo 'DVARP() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
||||||
|
?>
|
||||||
echo $worksheet->getCell('A13')->getValue() . '<br />';
|
<body>
|
||||||
echo 'DVARP() Result is ' . $worksheet->getCell('B13')->getCalculatedValue();
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,74 +6,72 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Calculation Examples</title>
|
<title>PhpSpreadsheet Calculation Examples</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>DATE</h1>
|
<h1>DATE</h1>
|
||||||
<h2>Returns the serial number of a particular date.</h2>
|
<h2>Returns the serial number of a particular date.</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Add some data
|
||||||
$spreadsheet = new Spreadsheet();
|
$testDates = [[2012, 3, 26], [2012, 2, 29], [2012, 4, 1], [2012, 12, 25],
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
[2012, 10, 31], [2012, 11, 5], [2012, 1, 1], [2012, 3, 17],
|
||||||
|
[2011, 2, 29], [7, 5, 3], [2012, 13, 1], [2012, 11, 45],
|
||||||
|
[2012, 0, 0], [2012, 1, 0], [2012, 0, 1],
|
||||||
|
[2012, -2, 2], [2012, 2, -2], [2012, -2, -2],
|
||||||
|
];
|
||||||
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
// Add some data
|
$worksheet->fromArray($testDates, null, 'A1', true);
|
||||||
$testDates = [[2012, 3, 26], [2012, 2, 29], [2012, 4, 1], [2012, 12, 25],
|
|
||||||
[2012, 10, 31], [2012, 11, 5], [2012, 1, 1], [2012, 3, 17],
|
|
||||||
[2011, 2, 29], [7, 5, 3], [2012, 13, 1], [2012, 11, 45],
|
|
||||||
[2012, 0, 0], [2012, 1, 0], [2012, 0, 1],
|
|
||||||
[2012, -2, 2], [2012, 2, -2], [2012, -2, -2],
|
|
||||||
];
|
|
||||||
$testDateCount = count($testDates);
|
|
||||||
|
|
||||||
$worksheet->fromArray($testDates, null, 'A1', true);
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=DATE(A' . $row . ',B' . $row . ',C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('E1:E' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('yyyy-mmm-dd');
|
||||||
|
|
||||||
for ($row = 1; $row <= $testDateCount; ++$row) {
|
echo '<hr />';
|
||||||
$worksheet->setCellValue('D' . $row, '=DATE(A' . $row . ',B' . $row . ',C' . $row . ')');
|
|
||||||
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
|
||||||
}
|
|
||||||
$worksheet->getStyle('E1:E' . $testDateCount)
|
|
||||||
->getNumberFormat()
|
|
||||||
->setFormatCode('yyyy-mmm-dd');
|
|
||||||
|
|
||||||
echo '<hr />';
|
// Test the formulae
|
||||||
|
?>
|
||||||
// Test the formulae
|
<table border="1" cellspacing="0">
|
||||||
?>
|
<tr>
|
||||||
<table border="1" cellspacing="0">
|
<th colspan="3">Date Value</th>
|
||||||
<tr>
|
<th rowspan="2" valign="bottom">Formula</th>
|
||||||
<th colspan="3">Date Value</th>
|
<th rowspan="2" valign="bottom">Excel DateStamp</th>
|
||||||
<th rowspan="2" valign="bottom">Formula</th>
|
<th rowspan="2" valign="bottom">Formatted DateStamp</th>
|
||||||
<th rowspan="2" valign="bottom">Excel DateStamp</th>
|
</tr>
|
||||||
<th rowspan="2" valign="bottom">Formatted DateStamp</th>
|
<tr>
|
||||||
</tr>
|
<th>Year</th>
|
||||||
<tr>
|
<th>Month</th>
|
||||||
<th>Year</th>
|
<th>Day</th>
|
||||||
<th>Month</th>
|
<tr>
|
||||||
<th>Day</th>
|
<?php
|
||||||
<tr>
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
<?php
|
echo '<tr>';
|
||||||
for ($row = 1; $row <= $testDateCount; ++$row) {
|
echo '<td>', $worksheet->getCell('A' . $row)->getFormattedValue(), '</td>';
|
||||||
echo '<tr>';
|
echo '<td>', $worksheet->getCell('B' . $row)->getFormattedValue(), '</td>';
|
||||||
echo '<td>', $worksheet->getCell('A' . $row)->getFormattedValue(), '</td>';
|
echo '<td>', $worksheet->getCell('C' . $row)->getFormattedValue(), '</td>';
|
||||||
echo '<td>', $worksheet->getCell('B' . $row)->getFormattedValue(), '</td>';
|
echo '<td>', $worksheet->getCell('D' . $row)->getValue(), '</td>';
|
||||||
echo '<td>', $worksheet->getCell('C' . $row)->getFormattedValue(), '</td>';
|
echo '<td>', $worksheet->getCell('D' . $row)->getFormattedValue(), '</td>';
|
||||||
echo '<td>', $worksheet->getCell('D' . $row)->getValue(), '</td>';
|
echo '<td>', $worksheet->getCell('E' . $row)->getFormattedValue(), '</td>';
|
||||||
echo '<td>', $worksheet->getCell('D' . $row)->getFormattedValue(), '</td>';
|
echo '</tr>';
|
||||||
echo '<td>', $worksheet->getCell('E' . $row)->getFormattedValue(), '</td>';
|
}
|
||||||
echo '</tr>';
|
?>
|
||||||
}
|
</table>
|
||||||
?>
|
</body>
|
||||||
</table>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,67 +6,65 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Calculation Examples</title>
|
<title>PhpSpreadsheet Calculation Examples</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>DATEVALUE</h1>
|
<h1>DATEVALUE</h1>
|
||||||
<h2>Converts a date in the form of text to a serial number.</h2>
|
<h2>Converts a date in the form of text to a serial number.</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Add some data
|
||||||
$spreadsheet = new Spreadsheet();
|
$testDates = ['26 March 2012', '29 Feb 2012', 'April 1, 2012', '25/12/2012',
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
'2012-Oct-31', '5th November', 'January 1st', 'April 2012',
|
||||||
|
'17-03', '03-2012', '29 Feb 2011', '03-05-07',
|
||||||
|
'03-MAY-07', '03-13-07',
|
||||||
|
];
|
||||||
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
// Add some data
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
$testDates = ['26 March 2012', '29 Feb 2012', 'April 1, 2012', '25/12/2012',
|
$worksheet->setCellValue('A' . $row, $testDates[$row - 1]);
|
||||||
'2012-Oct-31', '5th November', 'January 1st', 'April 2012',
|
$worksheet->setCellValue('B' . $row, '=DATEVALUE(A' . $row . ')');
|
||||||
'17-03', '03-2012', '29 Feb 2011', '03-05-07',
|
$worksheet->setCellValue('C' . $row, '=B' . $row);
|
||||||
'03-MAY-07', '03-13-07',
|
}
|
||||||
];
|
|
||||||
$testDateCount = count($testDates);
|
|
||||||
|
|
||||||
for ($row = 1; $row <= $testDateCount; ++$row) {
|
$worksheet->getStyle('C1:C' . $testDateCount)
|
||||||
$worksheet->setCellValue('A' . $row, $testDates[$row - 1]);
|
->getNumberFormat()
|
||||||
$worksheet->setCellValue('B' . $row, '=DATEVALUE(A' . $row . ')');
|
->setFormatCode('yyyy-mmm-dd');
|
||||||
$worksheet->setCellValue('C' . $row, '=B' . $row);
|
|
||||||
}
|
|
||||||
|
|
||||||
$worksheet->getStyle('C1:C' . $testDateCount)
|
echo '<hr />';
|
||||||
->getNumberFormat()
|
|
||||||
->setFormatCode('yyyy-mmm-dd');
|
|
||||||
|
|
||||||
echo '<hr />';
|
// Test the formulae
|
||||||
|
?>
|
||||||
// Test the formulae
|
<p><strong>Warning: </strong>The PhpSpreadsheet DATEVALUE() function accepts a wider range of date formats than MS Excel's DATEFORMAT() function.</p>
|
||||||
?>
|
<table border="1" cellspacing="0">
|
||||||
<p><strong>Warning: </strong>The PhpSpreadsheet DATEVALUE() function accepts a wider range of date formats than MS Excel's DATEFORMAT() function.</p>
|
<tr>
|
||||||
<table border="1" cellspacing="0">
|
<th>Date String</th>
|
||||||
<tr>
|
<th>Formula</th>
|
||||||
<th>Date String</th>
|
<th>Excel DateStamp</th>
|
||||||
<th>Formula</th>
|
<th>Formatted DateStamp</th>
|
||||||
<th>Excel DateStamp</th>
|
</tr>
|
||||||
<th>Formatted DateStamp</th>
|
<?php
|
||||||
</tr>
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
<?php
|
echo '<tr>';
|
||||||
for ($row = 1; $row <= $testDateCount; ++$row) {
|
echo '<td>', $worksheet->getCell('A' . $row)->getFormattedValue(), '</td>';
|
||||||
echo '<tr>';
|
echo '<td>', $worksheet->getCell('B' . $row)->getValue(), '</td>';
|
||||||
echo '<td>', $worksheet->getCell('A' . $row)->getFormattedValue(), '</td>';
|
echo '<td>', $worksheet->getCell('B' . $row)->getFormattedValue(), '</td>';
|
||||||
echo '<td>', $worksheet->getCell('B' . $row)->getValue(), '</td>';
|
echo '<td>', $worksheet->getCell('C' . $row)->getFormattedValue(), '</td>';
|
||||||
echo '<td>', $worksheet->getCell('B' . $row)->getFormattedValue(), '</td>';
|
echo '</tr>';
|
||||||
echo '<td>', $worksheet->getCell('C' . $row)->getFormattedValue(), '</td>';
|
}
|
||||||
echo '</tr>';
|
?>
|
||||||
}
|
</table>
|
||||||
?>
|
</body>
|
||||||
</table>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,72 +6,70 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Calculation Examples</title>
|
<title>PhpSpreadsheet Calculation Examples</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>TIME</h1>
|
<h1>TIME</h1>
|
||||||
<h2>Returns the serial number of a particular time.</h2>
|
<h2>Returns the serial number of a particular time.</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Add some data
|
||||||
$spreadsheet = new Spreadsheet();
|
$testDates = [[3, 15], [13, 15], [15, 15, 15], [3, 15, 30],
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
[15, 15, 15], [5], [9, 15, 0], [9, 15, -1],
|
||||||
|
[13, -14, -15], [0, 0, -1],
|
||||||
|
];
|
||||||
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
// Add some data
|
$worksheet->fromArray($testDates, null, 'A1', true);
|
||||||
$testDates = [[3, 15], [13, 15], [15, 15, 15], [3, 15, 30],
|
|
||||||
[15, 15, 15], [5], [9, 15, 0], [9, 15, -1],
|
|
||||||
[13, -14, -15], [0, 0, -1],
|
|
||||||
];
|
|
||||||
$testDateCount = count($testDates);
|
|
||||||
|
|
||||||
$worksheet->fromArray($testDates, null, 'A1', true);
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
|
$worksheet->setCellValue('D' . $row, '=TIME(A' . $row . ',B' . $row . ',C' . $row . ')');
|
||||||
|
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
||||||
|
}
|
||||||
|
$worksheet->getStyle('E1:E' . $testDateCount)
|
||||||
|
->getNumberFormat()
|
||||||
|
->setFormatCode('hh:mm:ss');
|
||||||
|
|
||||||
for ($row = 1; $row <= $testDateCount; ++$row) {
|
echo '<hr />';
|
||||||
$worksheet->setCellValue('D' . $row, '=TIME(A' . $row . ',B' . $row . ',C' . $row . ')');
|
|
||||||
$worksheet->setCellValue('E' . $row, '=D' . $row);
|
|
||||||
}
|
|
||||||
$worksheet->getStyle('E1:E' . $testDateCount)
|
|
||||||
->getNumberFormat()
|
|
||||||
->setFormatCode('hh:mm:ss');
|
|
||||||
|
|
||||||
echo '<hr />';
|
// Test the formulae
|
||||||
|
?>
|
||||||
// Test the formulae
|
<table border="1" cellspacing="0">
|
||||||
?>
|
<tr>
|
||||||
<table border="1" cellspacing="0">
|
<th colspan="3">Date Value</th>
|
||||||
<tr>
|
<th rowspan="2" valign="bottom">Formula</th>
|
||||||
<th colspan="3">Date Value</th>
|
<th rowspan="2" valign="bottom">Excel TimeStamp</th>
|
||||||
<th rowspan="2" valign="bottom">Formula</th>
|
<th rowspan="2" valign="bottom">Formatted TimeStamp</th>
|
||||||
<th rowspan="2" valign="bottom">Excel TimeStamp</th>
|
</tr>
|
||||||
<th rowspan="2" valign="bottom">Formatted TimeStamp</th>
|
<tr>
|
||||||
</tr>
|
<th>Hour</th>
|
||||||
<tr>
|
<th>Minute</th>
|
||||||
<th>Hour</th>
|
<th>Second</th>
|
||||||
<th>Minute</th>
|
<tr>
|
||||||
<th>Second</th>
|
<?php
|
||||||
<tr>
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
<?php
|
echo '<tr>';
|
||||||
for ($row = 1; $row <= $testDateCount; ++$row) {
|
echo '<td>', $worksheet->getCell('A' . $row)->getFormattedValue(), '</td>';
|
||||||
echo '<tr>';
|
echo '<td>', $worksheet->getCell('B' . $row)->getFormattedValue(), '</td>';
|
||||||
echo '<td>', $worksheet->getCell('A' . $row)->getFormattedValue(), '</td>';
|
echo '<td>', $worksheet->getCell('C' . $row)->getFormattedValue(), '</td>';
|
||||||
echo '<td>', $worksheet->getCell('B' . $row)->getFormattedValue(), '</td>';
|
echo '<td>', $worksheet->getCell('D' . $row)->getValue(), '</td>';
|
||||||
echo '<td>', $worksheet->getCell('C' . $row)->getFormattedValue(), '</td>';
|
echo '<td>', $worksheet->getCell('D' . $row)->getFormattedValue(), '</td>';
|
||||||
echo '<td>', $worksheet->getCell('D' . $row)->getValue(), '</td>';
|
echo '<td>', $worksheet->getCell('E' . $row)->getFormattedValue(), '</td>';
|
||||||
echo '<td>', $worksheet->getCell('D' . $row)->getFormattedValue(), '</td>';
|
echo '</tr>';
|
||||||
echo '<td>', $worksheet->getCell('E' . $row)->getFormattedValue(), '</td>';
|
}
|
||||||
echo '</tr>';
|
?>
|
||||||
}
|
</table>
|
||||||
?>
|
</body>
|
||||||
</table>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,63 +6,61 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Calculation Examples</title>
|
<title>PhpSpreadsheet Calculation Examples</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>TIMEVALUE</h1>
|
<h1>TIMEVALUE</h1>
|
||||||
<h2>Converts a time in the form of text to a serial number.</h2>
|
<h2>Converts a time in the form of text to a serial number.</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../src/Bootstrap.php';
|
// Create new PhpSpreadsheet object
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
// Create new PhpSpreadsheet object
|
// Add some data
|
||||||
$spreadsheet = new Spreadsheet();
|
$testDates = ['3:15', '13:15', '15:15:15', '3:15 AM', '3:15 PM', '5PM', '9:15AM', '13:15AM',
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
];
|
||||||
|
$testDateCount = count($testDates);
|
||||||
|
|
||||||
// Add some data
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
$testDates = ['3:15', '13:15', '15:15:15', '3:15 AM', '3:15 PM', '5PM', '9:15AM', '13:15AM',
|
$worksheet->setCellValue('A' . $row, $testDates[$row - 1]);
|
||||||
];
|
$worksheet->setCellValue('B' . $row, '=TIMEVALUE(A' . $row . ')');
|
||||||
$testDateCount = count($testDates);
|
$worksheet->setCellValue('C' . $row, '=B' . $row);
|
||||||
|
}
|
||||||
|
|
||||||
for ($row = 1; $row <= $testDateCount; ++$row) {
|
$worksheet->getStyle('C1:C' . $testDateCount)
|
||||||
$worksheet->setCellValue('A' . $row, $testDates[$row - 1]);
|
->getNumberFormat()
|
||||||
$worksheet->setCellValue('B' . $row, '=TIMEVALUE(A' . $row . ')');
|
->setFormatCode('hh:mm:ss');
|
||||||
$worksheet->setCellValue('C' . $row, '=B' . $row);
|
|
||||||
}
|
|
||||||
|
|
||||||
$worksheet->getStyle('C1:C' . $testDateCount)
|
echo '<hr />';
|
||||||
->getNumberFormat()
|
|
||||||
->setFormatCode('hh:mm:ss');
|
|
||||||
|
|
||||||
echo '<hr />';
|
// Test the formulae
|
||||||
|
?>
|
||||||
// Test the formulae
|
<table border="1" cellspacing="0">
|
||||||
?>
|
<tr>
|
||||||
<table border="1" cellspacing="0">
|
<th>Time String</th>
|
||||||
<tr>
|
<th>Formula</th>
|
||||||
<th>Time String</th>
|
<th>Excel TimeStamp</th>
|
||||||
<th>Formula</th>
|
<th>Formatted TimeStamp</th>
|
||||||
<th>Excel TimeStamp</th>
|
</tr>
|
||||||
<th>Formatted TimeStamp</th>
|
<?php
|
||||||
</tr>
|
for ($row = 1; $row <= $testDateCount; ++$row) {
|
||||||
<?php
|
echo '<tr>';
|
||||||
for ($row = 1; $row <= $testDateCount; ++$row) {
|
echo '<td>', $worksheet->getCell('A' . $row)->getFormattedValue(), '</td>';
|
||||||
echo '<tr>';
|
echo '<td>', $worksheet->getCell('B' . $row)->getValue(), '</td>';
|
||||||
echo '<td>', $worksheet->getCell('A' . $row)->getFormattedValue(), '</td>';
|
echo '<td>', $worksheet->getCell('B' . $row)->getFormattedValue(), '</td>';
|
||||||
echo '<td>', $worksheet->getCell('B' . $row)->getValue(), '</td>';
|
echo '<td>', $worksheet->getCell('C' . $row)->getFormattedValue(), '</td>';
|
||||||
echo '<td>', $worksheet->getCell('B' . $row)->getFormattedValue(), '</td>';
|
echo '</tr>';
|
||||||
echo '<td>', $worksheet->getCell('C' . $row)->getFormattedValue(), '</td>';
|
}
|
||||||
echo '</tr>';
|
?>
|
||||||
}
|
</table>
|
||||||
?>
|
</body>
|
||||||
</table>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
|
@ -1,49 +1,45 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Calculation Function Examples</title>
|
<title>PhpSpreadsheet Calculation Function Examples</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
echo '<h1>PhpSpreadsheet Calculation Function Examples</h1>';
|
||||||
|
|
||||||
echo '<h1>PhpSpreadsheet Calculation Function Examples</h1>';
|
$exampleTypeList = glob('./*', GLOB_ONLYDIR);
|
||||||
|
|
||||||
$exampleTypeList = glob('./*', GLOB_ONLYDIR);
|
foreach ($exampleTypeList as $exampleType) {
|
||||||
|
echo '<h2>' . pathinfo($exampleType, PATHINFO_BASENAME) . ' Function Examples</h2>';
|
||||||
|
|
||||||
foreach ($exampleTypeList as $exampleType) {
|
$exampleList = glob('./' . $exampleType . '/*.php');
|
||||||
echo '<h2>' . pathinfo($exampleType, PATHINFO_BASENAME) . ' Function Examples</h2>';
|
|
||||||
|
|
||||||
$exampleList = glob('./' . $exampleType . '/*.php');
|
foreach ($exampleList as $exampleFile) {
|
||||||
|
$fileData = file_get_contents($exampleFile);
|
||||||
|
|
||||||
foreach ($exampleList as $exampleFile) {
|
$h1Pattern = '#<h1>(.*?)</h1>#';
|
||||||
$fileData = file_get_contents($exampleFile);
|
$h2Pattern = '#<h2>(.*?)</h2>#';
|
||||||
|
|
||||||
$h1Pattern = '#<h1>(.*?)</h1>#';
|
if (preg_match($h1Pattern, $fileData, $out)) {
|
||||||
$h2Pattern = '#<h2>(.*?)</h2>#';
|
$h1Text = $out[1];
|
||||||
|
$h2Text = (preg_match($h2Pattern, $fileData, $out)) ? $out[1] : '';
|
||||||
|
|
||||||
if (preg_match($h1Pattern, $fileData, $out)) {
|
echo '<a href="', $exampleFile, '">', $h1Text, '</a><br />';
|
||||||
$h1Text = $out[1];
|
if ($h2Text > '') {
|
||||||
$h2Text = (preg_match($h2Pattern, $fileData, $out)) ? $out[1] : '';
|
echo $h2Text, '<br />';
|
||||||
|
}
|
||||||
echo '<a href="',$exampleFile,'">',$h1Text,'</a><br />';
|
}
|
||||||
if ($h2Text > '') {
|
|
||||||
echo $h2Text,'<br />';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
?>
|
||||||
}
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,32 +6,29 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #01</title>
|
<title>PhpSpreadsheet Reader Example #01</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #01</h1>
|
<h1>PhpSpreadsheet Reader Example #01</h1>
|
||||||
<h2>Simple File Reader using IOFactory::load()</h2>
|
<h2>Simple File Reader using IOFactory::load()</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.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 = IOFactory::load($inputFileName);
|
||||||
|
|
||||||
$inputFileName = './sampleData/example1.xls';
|
echo '<hr />';
|
||||||
echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory to identify the format<br />';
|
|
||||||
$spreadsheet = IOFactory::load($inputFileName);
|
|
||||||
|
|
||||||
echo '<hr />';
|
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||||
|
var_dump($sheetData);
|
||||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
?>
|
||||||
var_dump($sheetData);
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -8,38 +8,29 @@ set_time_limit(0);
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #02</title>
|
<title>PhpSpreadsheet Reader Example #02</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #02</h1>
|
<h1>PhpSpreadsheet Reader Example #02</h1>
|
||||||
<h2>Simple File Reader using a Specified Reader</h2>
|
<h2>Simple File Reader using a Specified Reader</h2>
|
||||||
<?php
|
<?php
|
||||||
|
$inputFileName = './sampleData/example1.xls';
|
||||||
|
|
||||||
$inputFileName = './sampleData/example1.xls';
|
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using \PhpOffice\PhpSpreadsheet\Reader\Xls<br />';
|
||||||
|
$reader = new Xls();
|
||||||
|
$spreadsheet = $reader->load($inputFileName);
|
||||||
|
|
||||||
echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using \PhpOffice\PhpSpreadsheet\Reader\Xls<br />';
|
echo '<hr />';
|
||||||
$reader = new 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();
|
|
||||||
$spreadsheet = $reader->load($inputFileName);
|
|
||||||
|
|
||||||
echo '<hr />';
|
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||||
|
var_dump($sheetData);
|
||||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
?>
|
||||||
var_dump($sheetData);
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,41 +6,32 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #03</title>
|
<title>PhpSpreadsheet Reader Example #03</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #03</h1>
|
<h1>PhpSpreadsheet Reader Example #03</h1>
|
||||||
<h2>Simple File Reader using the IOFactory to Return a Reader</h2>
|
<h2>Simple File Reader using the IOFactory to Return a Reader</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Xls';
|
||||||
|
$inputFileName = './sampleData/example1.xls';
|
||||||
|
|
||||||
$inputFileType = 'Xls';
|
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||||
// $inputFileType = 'Xlsx';
|
$reader = IOFactory::createReader($inputFileType);
|
||||||
// $inputFileType = 'Xml';
|
$spreadsheet = $reader->load($inputFileName);
|
||||||
// $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 />';
|
echo '<hr />';
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
|
||||||
$spreadsheet = $reader->load($inputFileName);
|
|
||||||
|
|
||||||
echo '<hr />';
|
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||||
|
var_dump($sheetData);
|
||||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
?>
|
||||||
var_dump($sheetData);
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,37 +6,34 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #04</title>
|
<title>PhpSpreadsheet Reader Example #04</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #04</h1>
|
<h1>PhpSpreadsheet Reader Example #04</h1>
|
||||||
<h2>Simple File Reader using the IOFactory to Identify a Reader to Use</h2>
|
<h2>Simple File Reader using the IOFactory to Identify a Reader to Use</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileName = './sampleData/example1.xls';
|
||||||
|
|
||||||
$inputFileName = './sampleData/example1.xls';
|
$inputFileType = IOFactory::identify($inputFileName);
|
||||||
|
echo 'File ', pathinfo($inputFileName, PATHINFO_BASENAME), ' has been identified as an ', $inputFileType, ' file<br />';
|
||||||
|
|
||||||
$inputFileType = IOFactory::identify($inputFileName);
|
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with the identified reader type<br />';
|
||||||
echo 'File ',pathinfo($inputFileName, PATHINFO_BASENAME),' has been identified as an ',$inputFileType,' file<br />';
|
$reader = IOFactory::createReader($inputFileType);
|
||||||
|
$spreadsheet = $reader->load($inputFileName);
|
||||||
|
|
||||||
echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory with the identified reader type<br />';
|
echo '<hr />';
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
|
||||||
$spreadsheet = $reader->load($inputFileName);
|
|
||||||
|
|
||||||
echo '<hr />';
|
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||||
|
var_dump($sheetData);
|
||||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
?>
|
||||||
var_dump($sheetData);
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,41 +6,34 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #05</title>
|
<title>PhpSpreadsheet Reader Example #05</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #05</h1>
|
<h1>PhpSpreadsheet Reader Example #05</h1>
|
||||||
<h2>Simple File Reader using the "Read Data Only" Option</h2>
|
<h2>Simple File Reader using the "Read Data Only" Option</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Xls';
|
||||||
|
$inputFileName = './sampleData/example1.xls';
|
||||||
|
|
||||||
$inputFileType = 'Xls';
|
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||||
// $inputFileType = 'Xlsx';
|
$reader = IOFactory::createReader($inputFileType);
|
||||||
// $inputFileType = 'Xml';
|
echo 'Turning Formatting off for Load<br />';
|
||||||
// $inputFileType = 'Ods';
|
$reader->setReadDataOnly(true);
|
||||||
// $inputFileType = 'Gnumeric';
|
$spreadsheet = $reader->load($inputFileName);
|
||||||
$inputFileName = './sampleData/example1.xls';
|
|
||||||
|
|
||||||
echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
echo '<hr />';
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
|
||||||
echo 'Turning Formatting off for Load<br />';
|
|
||||||
$reader->setReadDataOnly(true);
|
|
||||||
$spreadsheet = $reader->load($inputFileName);
|
|
||||||
|
|
||||||
echo '<hr />';
|
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||||
|
var_dump($sheetData);
|
||||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
?>
|
||||||
var_dump($sheetData);
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,44 +6,37 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #06</title>
|
<title>PhpSpreadsheet Reader Example #06</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #06</h1>
|
<h1>PhpSpreadsheet Reader Example #06</h1>
|
||||||
<h2>Simple File Reader Loading All WorkSheets</h2>
|
<h2>Simple File Reader Loading All WorkSheets</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Xls';
|
||||||
|
$inputFileName = './sampleData/example1.xls';
|
||||||
|
|
||||||
$inputFileType = 'Xls';
|
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||||
// $inputFileType = 'Xlsx';
|
$reader = IOFactory::createReader($inputFileType);
|
||||||
// $inputFileType = 'Xml';
|
echo 'Loading all WorkSheets<br />';
|
||||||
// $inputFileType = 'Ods';
|
$reader->setLoadAllSheets();
|
||||||
// $inputFileType = 'Gnumeric';
|
$spreadsheet = $reader->load($inputFileName);
|
||||||
$inputFileName = './sampleData/example1.xls';
|
|
||||||
|
|
||||||
echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
echo '<hr />';
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
|
||||||
echo 'Loading all WorkSheets<br />';
|
|
||||||
$reader->setLoadAllSheets();
|
|
||||||
$spreadsheet = $reader->load($inputFileName);
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo $spreadsheet->getSheetCount(), ' worksheet', (($spreadsheet->getSheetCount() == 1) ? '' : 's'), ' loaded<br /><br />';
|
||||||
|
$loadedSheetNames = $spreadsheet->getSheetNames();
|
||||||
echo $spreadsheet->getSheetCount(), ' worksheet', (($spreadsheet->getSheetCount() == 1) ? '' : 's'), ' loaded<br /><br />';
|
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||||
$loadedSheetNames = $spreadsheet->getSheetNames();
|
echo $sheetIndex, ' -> ', $loadedSheetName, '<br />';
|
||||||
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
}
|
||||||
echo $sheetIndex, ' -> ', $loadedSheetName, '<br />';
|
?>
|
||||||
}
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,45 +6,38 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #07</title>
|
<title>PhpSpreadsheet Reader Example #07</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #07</h1>
|
<h1>PhpSpreadsheet Reader Example #07</h1>
|
||||||
<h2>Simple File Reader Loading a Single Named WorkSheet</h2>
|
<h2>Simple File Reader Loading a Single Named WorkSheet</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Xls';
|
||||||
|
$inputFileName = './sampleData/example1.xls';
|
||||||
|
$sheetname = 'Data Sheet #2';
|
||||||
|
|
||||||
$inputFileType = 'Xls';
|
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||||
// $inputFileType = 'Xlsx';
|
$reader = IOFactory::createReader($inputFileType);
|
||||||
// $inputFileType = 'Xml';
|
echo 'Loading Sheet "', $sheetname, '" only<br />';
|
||||||
// $inputFileType = 'Ods';
|
$reader->setLoadSheetsOnly($sheetname);
|
||||||
// $inputFileType = 'Gnumeric';
|
$spreadsheet = $reader->load($inputFileName);
|
||||||
$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 />';
|
echo '<hr />';
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
|
||||||
echo 'Loading Sheet "',$sheetname,'" only<br />';
|
|
||||||
$reader->setLoadSheetsOnly($sheetname);
|
|
||||||
$spreadsheet = $reader->load($inputFileName);
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo $spreadsheet->getSheetCount(), ' worksheet', (($spreadsheet->getSheetCount() == 1) ? '' : 's'), ' loaded<br /><br />';
|
||||||
|
$loadedSheetNames = $spreadsheet->getSheetNames();
|
||||||
echo $spreadsheet->getSheetCount(),' worksheet',(($spreadsheet->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />';
|
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||||
$loadedSheetNames = $spreadsheet->getSheetNames();
|
echo $sheetIndex, ' -> ', $loadedSheetName, '<br />';
|
||||||
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
}
|
||||||
echo $sheetIndex,' -> ',$loadedSheetName,'<br />';
|
?>
|
||||||
}
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,45 +6,38 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #08</title>
|
<title>PhpSpreadsheet Reader Example #08</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #08</h1>
|
<h1>PhpSpreadsheet Reader Example #08</h1>
|
||||||
<h2>Simple File Reader Loading Several Named WorkSheets</h2>
|
<h2>Simple File Reader Loading Several Named WorkSheets</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Xls';
|
||||||
|
$inputFileName = './sampleData/example1.xls';
|
||||||
|
$sheetnames = ['Data Sheet #1', 'Data Sheet #3'];
|
||||||
|
|
||||||
$inputFileType = 'Xls';
|
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||||
// $inputFileType = 'Xlsx';
|
$reader = IOFactory::createReader($inputFileType);
|
||||||
// $inputFileType = 'Xml';
|
echo 'Loading Sheet', ((count($sheetnames) == 1) ? '' : 's'), ' "', implode('" and "', $sheetnames), '" only<br />';
|
||||||
// $inputFileType = 'Ods';
|
$reader->setLoadSheetsOnly($sheetnames);
|
||||||
// $inputFileType = 'Gnumeric';
|
$spreadsheet = $reader->load($inputFileName);
|
||||||
$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 />';
|
echo '<hr />';
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
|
||||||
echo 'Loading Sheet',((count($sheetnames) == 1) ? '' : 's'),' "',implode('" and "', $sheetnames),'" only<br />';
|
|
||||||
$reader->setLoadSheetsOnly($sheetnames);
|
|
||||||
$spreadsheet = $reader->load($inputFileName);
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo $spreadsheet->getSheetCount(), ' worksheet', (($spreadsheet->getSheetCount() == 1) ? '' : 's'), ' loaded<br /><br />';
|
||||||
|
$loadedSheetNames = $spreadsheet->getSheetNames();
|
||||||
echo $spreadsheet->getSheetCount(),' worksheet',(($spreadsheet->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />';
|
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||||
$loadedSheetNames = $spreadsheet->getSheetNames();
|
echo $sheetIndex, ' -> ', $loadedSheetName, '<br />';
|
||||||
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
}
|
||||||
echo $sheetIndex,' -> ',$loadedSheetName,'<br />';
|
?>
|
||||||
}
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -7,61 +7,55 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #09</title>
|
<title>PhpSpreadsheet Reader Example #09</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #09</h1>
|
<h1>PhpSpreadsheet Reader Example #09</h1>
|
||||||
<h2>Simple File Reader Using a Read Filter</h2>
|
<h2>Simple File Reader Using a Read Filter</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Xls';
|
||||||
|
$inputFileName = './sampleData/example1.xls';
|
||||||
|
$sheetname = 'Data Sheet #3';
|
||||||
|
|
||||||
$inputFileType = 'Xls';
|
class MyReadFilter implements IReadFilter
|
||||||
// $inputFileType = 'Xlsx';
|
{
|
||||||
// $inputFileType = 'Xml';
|
public function readCell($column, $row, $worksheetName = '')
|
||||||
// $inputFileType = 'Ods';
|
{
|
||||||
// $inputFileType = 'Gnumeric';
|
// Read rows 1 to 7 and columns A to E only
|
||||||
$inputFileName = './sampleData/example1.xls';
|
if ($row >= 1 && $row <= 7) {
|
||||||
$sheetname = 'Data Sheet #3';
|
if (in_array($column, range('A', 'E'))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class MyReadFilter implements IReadFilter
|
return false;
|
||||||
{
|
|
||||||
public function readCell($column, $row, $worksheetName = '')
|
|
||||||
{
|
|
||||||
// Read rows 1 to 7 and columns A to E only
|
|
||||||
if ($row >= 1 && $row <= 7) {
|
|
||||||
if (in_array($column, range('A', 'E'))) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
$filterSubset = new MyReadFilter();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$filterSubset = new MyReadFilter();
|
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||||
|
$reader = IOFactory::createReader($inputFileType);
|
||||||
|
echo 'Loading Sheet "', $sheetname, '" only<br />';
|
||||||
|
$reader->setLoadSheetsOnly($sheetname);
|
||||||
|
echo 'Loading Sheet using filter<br />';
|
||||||
|
$reader->setReadFilter($filterSubset);
|
||||||
|
$spreadsheet = $reader->load($inputFileName);
|
||||||
|
|
||||||
echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
echo '<hr />';
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
|
||||||
echo 'Loading Sheet "',$sheetname,'" only<br />';
|
|
||||||
$reader->setLoadSheetsOnly($sheetname);
|
|
||||||
echo 'Loading Sheet using filter<br />';
|
|
||||||
$reader->setReadFilter($filterSubset);
|
|
||||||
$spreadsheet = $reader->load($inputFileName);
|
|
||||||
|
|
||||||
echo '<hr />';
|
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||||
|
var_dump($sheetData);
|
||||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
?>
|
||||||
var_dump($sheetData);
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -7,73 +7,66 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #10</title>
|
<title>PhpSpreadsheet Reader Example #10</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #10</h1>
|
<h1>PhpSpreadsheet Reader Example #10</h1>
|
||||||
<h2>Simple File Reader Using a Configurable Read Filter</h2>
|
<h2>Simple File Reader Using a Configurable Read Filter</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Xls';
|
||||||
|
$inputFileName = './sampleData/example1.xls';
|
||||||
|
$sheetname = 'Data Sheet #3';
|
||||||
|
|
||||||
$inputFileType = 'Xls';
|
class MyReadFilter implements IReadFilter
|
||||||
// $inputFileType = 'Xlsx';
|
{
|
||||||
// $inputFileType = 'Xml';
|
|
||||||
// $inputFileType = 'Ods';
|
|
||||||
// $inputFileType = 'Gnumeric';
|
|
||||||
$inputFileName = './sampleData/example1.xls';
|
|
||||||
$sheetname = 'Data Sheet #3';
|
|
||||||
|
|
||||||
class MyReadFilter implements IReadFilter
|
private $_startRow = 0;
|
||||||
{
|
private $_endRow = 0;
|
||||||
private $_startRow = 0;
|
private $_columns = [];
|
||||||
|
|
||||||
private $_endRow = 0;
|
public function __construct($startRow, $endRow, $columns)
|
||||||
|
{
|
||||||
private $_columns = [];
|
$this->_startRow = $startRow;
|
||||||
|
$this->_endRow = $endRow;
|
||||||
public function __construct($startRow, $endRow, $columns)
|
$this->_columns = $columns;
|
||||||
{
|
|
||||||
$this->_startRow = $startRow;
|
|
||||||
$this->_endRow = $endRow;
|
|
||||||
$this->_columns = $columns;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function readCell($column, $row, $worksheetName = '')
|
|
||||||
{
|
|
||||||
if ($row >= $this->_startRow && $row <= $this->_endRow) {
|
|
||||||
if (in_array($column, $this->_columns)) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function readCell($column, $row, $worksheetName = '')
|
||||||
|
{
|
||||||
|
if ($row >= $this->_startRow && $row <= $this->_endRow) {
|
||||||
|
if (in_array($column, $this->_columns)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
$filterSubset = new MyReadFilter(9, 15, range('G', 'K'));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$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 = IOFactory::createReader($inputFileType);
|
||||||
|
echo 'Loading Sheet "', $sheetname, '" only<br />';
|
||||||
|
$reader->setLoadSheetsOnly($sheetname);
|
||||||
|
echo 'Loading Sheet using configurable filter<br />';
|
||||||
|
$reader->setReadFilter($filterSubset);
|
||||||
|
$spreadsheet = $reader->load($inputFileName);
|
||||||
|
|
||||||
echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
echo '<hr />';
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
|
||||||
echo 'Loading Sheet "',$sheetname,'" only<br />';
|
|
||||||
$reader->setLoadSheetsOnly($sheetname);
|
|
||||||
echo 'Loading Sheet using configurable filter<br />';
|
|
||||||
$reader->setReadFilter($filterSubset);
|
|
||||||
$spreadsheet = $reader->load($inputFileName);
|
|
||||||
|
|
||||||
echo '<hr />';
|
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||||
|
var_dump($sheetData);
|
||||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
?>
|
||||||
var_dump($sheetData);
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -7,86 +7,80 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #11</title>
|
<title>PhpSpreadsheet Reader Example #11</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #11</h1>
|
<h1>PhpSpreadsheet Reader Example #11</h1>
|
||||||
<h2>Reading a Workbook in "Chunks" Using a Configurable Read Filter (Version 1)</h2>
|
<h2>Reading a Workbook in "Chunks" Using a Configurable Read Filter (Version 1)</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Xls';
|
||||||
|
$inputFileName = './sampleData/example2.xls';
|
||||||
|
|
||||||
$inputFileType = 'Xls';
|
/** Define a Read Filter class implementing IReadFilter */
|
||||||
// $inputFileType = 'Xlsx';
|
class chunkReadFilter implements IReadFilter
|
||||||
// $inputFileType = 'Xml';
|
{
|
||||||
// $inputFileType = 'Ods';
|
|
||||||
// $inputFileType = 'Gnumeric';
|
|
||||||
$inputFileName = './sampleData/example2.xls';
|
|
||||||
|
|
||||||
/** Define a Read Filter class implementing IReadFilter */
|
private $_startRow = 0;
|
||||||
class chunkReadFilter implements IReadFilter
|
private $_endRow = 0;
|
||||||
{
|
|
||||||
private $_startRow = 0;
|
|
||||||
|
|
||||||
private $_endRow = 0;
|
/**
|
||||||
|
* We expect a list of the rows that we want to read to be passed into the constructor.
|
||||||
|
*
|
||||||
|
* @param mixed $startRow
|
||||||
|
* @param mixed $chunkSize
|
||||||
|
*/
|
||||||
|
public function __construct($startRow, $chunkSize)
|
||||||
|
{
|
||||||
|
$this->_startRow = $startRow;
|
||||||
|
$this->_endRow = $startRow + $chunkSize;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
public function readCell($column, $row, $worksheetName = '')
|
||||||
* We expect a list of the rows that we want to read to be passed into the constructor.
|
{
|
||||||
*
|
// Only read the heading row, and the rows that were configured in the constructor
|
||||||
* @param mixed $startRow
|
if (($row == 1) || ($row >= $this->_startRow && $row < $this->_endRow)) {
|
||||||
* @param mixed $chunkSize
|
return true;
|
||||||
*/
|
}
|
||||||
public function __construct($startRow, $chunkSize)
|
|
||||||
{
|
return false;
|
||||||
$this->_startRow = $startRow;
|
}
|
||||||
$this->_endRow = $startRow + $chunkSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function readCell($column, $row, $worksheetName = '')
|
|
||||||
{
|
|
||||||
// Only read the heading row, and the rows that were configured in the constructor
|
|
||||||
if (($row == 1) || ($row >= $this->_startRow && $row < $this->_endRow)) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = IOFactory::createReader($inputFileType);
|
||||||
|
|
||||||
echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
echo '<hr />';
|
||||||
/* Create a new Reader of the type defined in $inputFileType **/
|
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
|
||||||
|
|
||||||
echo '<hr />';
|
/* Define how many rows we want for each "chunk" * */
|
||||||
|
$chunkSize = 20;
|
||||||
|
|
||||||
/* Define how many rows we want for each "chunk" **/
|
/* Loop to read our worksheet in "chunk size" blocks * */
|
||||||
$chunkSize = 20;
|
for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
|
||||||
|
echo 'Loading WorkSheet using configurable filter for headings row 1 and for rows ', $startRow, ' to ', ($startRow + $chunkSize - 1), '<br />';
|
||||||
|
/* Create a new Instance of our Read Filter, passing in the limits on which rows we want to read * */
|
||||||
|
$chunkFilter = new chunkReadFilter($startRow, $chunkSize);
|
||||||
|
/* Tell the Reader that we want to use the new Read Filter that we've just Instantiated * */
|
||||||
|
$reader->setReadFilter($chunkFilter);
|
||||||
|
/* Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object * */
|
||||||
|
$spreadsheet = $reader->load($inputFileName);
|
||||||
|
|
||||||
/* Loop to read our worksheet in "chunk size" blocks **/
|
// Do some processing here
|
||||||
for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
|
|
||||||
echo 'Loading WorkSheet using configurable filter for headings row 1 and for rows ',$startRow,' to ',($startRow + $chunkSize - 1),'<br />';
|
|
||||||
/* Create a new Instance of our Read Filter, passing in the limits on which rows we want to read **/
|
|
||||||
$chunkFilter = new chunkReadFilter($startRow, $chunkSize);
|
|
||||||
/* Tell the Reader that we want to use the new Read Filter that we've just Instantiated **/
|
|
||||||
$reader->setReadFilter($chunkFilter);
|
|
||||||
/* Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object **/
|
|
||||||
$spreadsheet = $reader->load($inputFileName);
|
|
||||||
|
|
||||||
// Do some processing here
|
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||||
|
var_dump($sheetData);
|
||||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
echo '<br /><br />';
|
||||||
var_dump($sheetData);
|
}
|
||||||
echo '<br /><br />';
|
?>
|
||||||
}
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -7,89 +7,83 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #12</title>
|
<title>PhpSpreadsheet Reader Example #12</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #12</h1>
|
<h1>PhpSpreadsheet Reader Example #12</h1>
|
||||||
<h2>Reading a Workbook in "Chunks" Using a Configurable Read Filter (Version 2)</h2>
|
<h2>Reading a Workbook in "Chunks" Using a Configurable Read Filter (Version 2)</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Xls';
|
||||||
|
$inputFileName = './sampleData/example2.xls';
|
||||||
|
|
||||||
$inputFileType = 'Xls';
|
/** Define a Read Filter class implementing IReadFilter */
|
||||||
// $inputFileType = 'Xlsx';
|
class chunkReadFilter implements IReadFilter
|
||||||
// $inputFileType = 'Xml';
|
{
|
||||||
// $inputFileType = 'Ods';
|
|
||||||
// $inputFileType = 'Gnumeric';
|
|
||||||
$inputFileName = './sampleData/example2.xls';
|
|
||||||
|
|
||||||
/** Define a Read Filter class implementing IReadFilter */
|
private $_startRow = 0;
|
||||||
class chunkReadFilter implements IReadFilter
|
private $_endRow = 0;
|
||||||
{
|
|
||||||
private $_startRow = 0;
|
|
||||||
|
|
||||||
private $_endRow = 0;
|
/**
|
||||||
|
* Set the list of rows that we want to read.
|
||||||
|
*
|
||||||
|
* @param mixed $startRow
|
||||||
|
* @param mixed $chunkSize
|
||||||
|
*/
|
||||||
|
public function setRows($startRow, $chunkSize)
|
||||||
|
{
|
||||||
|
$this->_startRow = $startRow;
|
||||||
|
$this->_endRow = $startRow + $chunkSize;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
public function readCell($column, $row, $worksheetName = '')
|
||||||
* Set the list of rows that we want to read.
|
{
|
||||||
*
|
// Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow
|
||||||
* @param mixed $startRow
|
if (($row == 1) || ($row >= $this->_startRow && $row < $this->_endRow)) {
|
||||||
* @param mixed $chunkSize
|
return true;
|
||||||
*/
|
}
|
||||||
public function setRows($startRow, $chunkSize)
|
|
||||||
{
|
return false;
|
||||||
$this->_startRow = $startRow;
|
}
|
||||||
$this->_endRow = $startRow + $chunkSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function readCell($column, $row, $worksheetName = '')
|
|
||||||
{
|
|
||||||
// Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow
|
|
||||||
if (($row == 1) || ($row >= $this->_startRow && $row < $this->_endRow)) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = IOFactory::createReader($inputFileType);
|
||||||
|
|
||||||
echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
echo '<hr />';
|
||||||
/* Create a new Reader of the type defined in $inputFileType **/
|
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
|
||||||
|
|
||||||
echo '<hr />';
|
/* Define how many rows we want to read for each "chunk" * */
|
||||||
|
$chunkSize = 20;
|
||||||
|
/* Create a new Instance of our Read Filter * */
|
||||||
|
$chunkFilter = new chunkReadFilter();
|
||||||
|
|
||||||
/* Define how many rows we want to read for each "chunk" **/
|
/* Tell the Reader that we want to use the Read Filter that we've Instantiated * */
|
||||||
$chunkSize = 20;
|
$reader->setReadFilter($chunkFilter);
|
||||||
/* Create a new Instance of our Read Filter **/
|
|
||||||
$chunkFilter = new chunkReadFilter();
|
|
||||||
|
|
||||||
/* Tell the Reader that we want to use the Read Filter that we've Instantiated **/
|
/* Loop to read our worksheet in "chunk size" blocks * */
|
||||||
$reader->setReadFilter($chunkFilter);
|
for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
|
||||||
|
echo 'Loading WorkSheet using configurable filter for headings row 1 and for rows ', $startRow, ' to ', ($startRow + $chunkSize - 1), '<br />';
|
||||||
|
/* Tell the Read Filter, the limits on which rows we want to read this iteration * */
|
||||||
|
$chunkFilter->setRows($startRow, $chunkSize);
|
||||||
|
/* Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object * */
|
||||||
|
$spreadsheet = $reader->load($inputFileName);
|
||||||
|
|
||||||
/* Loop to read our worksheet in "chunk size" blocks **/
|
// Do some processing here
|
||||||
for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
|
|
||||||
echo 'Loading WorkSheet using configurable filter for headings row 1 and for rows ', $startRow, ' to ', ($startRow + $chunkSize - 1), '<br />';
|
|
||||||
/* Tell the Read Filter, the limits on which rows we want to read this iteration **/
|
|
||||||
$chunkFilter->setRows($startRow, $chunkSize);
|
|
||||||
/* Load only the rows that match our filter from $inputFileName to a PhpSpreadsheet Object **/
|
|
||||||
$spreadsheet = $reader->load($inputFileName);
|
|
||||||
|
|
||||||
// Do some processing here
|
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||||
|
var_dump($sheetData);
|
||||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
echo '<br /><br />';
|
||||||
var_dump($sheetData);
|
}
|
||||||
echo '<br /><br />';
|
?>
|
||||||
}
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,50 +6,47 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #13</title>
|
<title>PhpSpreadsheet Reader Example #13</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #13</h1>
|
<h1>PhpSpreadsheet Reader Example #13</h1>
|
||||||
<h2>Simple File Reader for Multiple CSV Files</h2>
|
<h2>Simple File Reader for Multiple CSV Files</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Csv';
|
||||||
|
$inputFileNames = ['./sampleData/example1.csv', './sampleData/example2.csv'];
|
||||||
|
|
||||||
$inputFileType = 'Csv';
|
$reader = IOFactory::createReader($inputFileType);
|
||||||
$inputFileNames = ['./sampleData/example1.csv', './sampleData/example2.csv'];
|
$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);
|
||||||
|
$spreadsheet->getActiveSheet()->setTitle(pathinfo($inputFileName, PATHINFO_BASENAME));
|
||||||
|
foreach ($inputFileNames as $sheet => $inputFileName) {
|
||||||
|
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' into WorkSheet #', ($sheet + 2), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||||
|
$reader->setSheetIndex($sheet + 1);
|
||||||
|
$reader->loadIntoExisting($inputFileName, $spreadsheet);
|
||||||
|
$spreadsheet->getActiveSheet()->setTitle(pathinfo($inputFileName, PATHINFO_BASENAME));
|
||||||
|
}
|
||||||
|
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
echo '<hr />';
|
||||||
$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);
|
|
||||||
$spreadsheet->getActiveSheet()->setTitle(pathinfo($inputFileName, PATHINFO_BASENAME));
|
|
||||||
foreach ($inputFileNames as $sheet => $inputFileName) {
|
|
||||||
echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' into WorkSheet #',($sheet + 2),' using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
|
||||||
$reader->setSheetIndex($sheet + 1);
|
|
||||||
$reader->loadIntoExisting($inputFileName, $spreadsheet);
|
|
||||||
$spreadsheet->getActiveSheet()->setTitle(pathinfo($inputFileName, PATHINFO_BASENAME));
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo $spreadsheet->getSheetCount(), ' worksheet', (($spreadsheet->getSheetCount() == 1) ? '' : 's'), ' loaded<br /><br />';
|
||||||
|
$loadedSheetNames = $spreadsheet->getSheetNames();
|
||||||
echo $spreadsheet->getSheetCount(), ' worksheet', (($spreadsheet->getSheetCount() == 1) ? '' : 's'), ' loaded<br /><br />';
|
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||||
$loadedSheetNames = $spreadsheet->getSheetNames();
|
echo '<b>Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, '</b><br />';
|
||||||
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
$spreadsheet->setActiveSheetIndexByName($loadedSheetName);
|
||||||
echo '<b>Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, '</b><br />';
|
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||||
$spreadsheet->setActiveSheetIndexByName($loadedSheetName);
|
var_dump($sheetData);
|
||||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
echo '<br /><br />';
|
||||||
var_dump($sheetData);
|
}
|
||||||
echo '<br /><br />';
|
?>
|
||||||
}
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -8,105 +8,103 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #14</title>
|
<title>PhpSpreadsheet Reader Example #14</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #14</h1>
|
<h1>PhpSpreadsheet Reader Example #14</h1>
|
||||||
<h2>Reading a Large CSV file in "Chunks" to split across multiple Worksheets</h2>
|
<h2>Reading a Large CSV file in "Chunks" to split across multiple Worksheets</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Csv';
|
||||||
|
$inputFileName = './sampleData/example2.csv';
|
||||||
|
|
||||||
$inputFileType = 'Csv';
|
/** Define a Read Filter class implementing IReadFilter */
|
||||||
$inputFileName = './sampleData/example2.csv';
|
class chunkReadFilter implements IReadFilter
|
||||||
|
{
|
||||||
|
|
||||||
/** Define a Read Filter class implementing IReadFilter */
|
private $_startRow = 0;
|
||||||
class chunkReadFilter implements IReadFilter
|
private $_endRow = 0;
|
||||||
{
|
|
||||||
private $_startRow = 0;
|
|
||||||
|
|
||||||
private $_endRow = 0;
|
/**
|
||||||
|
* Set the list of rows that we want to read.
|
||||||
|
*
|
||||||
|
* @param mixed $startRow
|
||||||
|
* @param mixed $chunkSize
|
||||||
|
*/
|
||||||
|
public function setRows($startRow, $chunkSize)
|
||||||
|
{
|
||||||
|
$this->_startRow = $startRow;
|
||||||
|
$this->_endRow = $startRow + $chunkSize;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
public function readCell($column, $row, $worksheetName = '')
|
||||||
* Set the list of rows that we want to read.
|
{
|
||||||
*
|
// Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow
|
||||||
* @param mixed $startRow
|
if (($row == 1) || ($row >= $this->_startRow && $row < $this->_endRow)) {
|
||||||
* @param mixed $chunkSize
|
return true;
|
||||||
*/
|
}
|
||||||
public function setRows($startRow, $chunkSize)
|
|
||||||
{
|
return false;
|
||||||
$this->_startRow = $startRow;
|
}
|
||||||
$this->_endRow = $startRow + $chunkSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function readCell($column, $row, $worksheetName = '')
|
|
||||||
{
|
|
||||||
// Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow
|
|
||||||
if (($row == 1) || ($row >= $this->_startRow && $row < $this->_endRow)) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = IOFactory::createReader($inputFileType);
|
||||||
|
|
||||||
echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
echo '<hr />';
|
||||||
/* Create a new Reader of the type defined in $inputFileType **/
|
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
|
||||||
|
|
||||||
echo '<hr />';
|
/* Define how many rows we want to read for each "chunk" * */
|
||||||
|
$chunkSize = 100;
|
||||||
|
/* Create a new Instance of our Read Filter * */
|
||||||
|
$chunkFilter = new chunkReadFilter();
|
||||||
|
|
||||||
/* Define how many rows we want to read for each "chunk" **/
|
/* Tell the Reader that we want to use the Read Filter that we've Instantiated * */
|
||||||
$chunkSize = 100;
|
/* and that we want to store it in contiguous rows/columns * */
|
||||||
/* Create a new Instance of our Read Filter **/
|
$reader->setReadFilter($chunkFilter)
|
||||||
$chunkFilter = new chunkReadFilter();
|
->setContiguous(true);
|
||||||
|
|
||||||
/* Tell the Reader that we want to use the Read Filter that we've Instantiated **/
|
/* Instantiate a new PhpSpreadsheet object manually * */
|
||||||
/* and that we want to store it in contiguous rows/columns **/
|
$spreadsheet = new Spreadsheet();
|
||||||
$reader->setReadFilter($chunkFilter)
|
|
||||||
->setContiguous(true);
|
|
||||||
|
|
||||||
/* Instantiate a new PhpSpreadsheet object manually **/
|
/* Set a sheet index * */
|
||||||
$spreadsheet = new Spreadsheet();
|
$sheet = 0;
|
||||||
|
/* Loop to read our worksheet in "chunk size" blocks * */
|
||||||
|
/** $startRow is set to 2 initially because we always read the headings in row #1 * */
|
||||||
|
for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
|
||||||
|
echo 'Loading WorkSheet #', ($sheet + 1), ' using configurable filter for headings row 1 and for rows ', $startRow, ' to ', ($startRow + $chunkSize - 1), '<br />';
|
||||||
|
/* Tell the Read Filter, the limits on which rows we want to read this iteration * */
|
||||||
|
$chunkFilter->setRows($startRow, $chunkSize);
|
||||||
|
|
||||||
/* Set a sheet index **/
|
/* Increment the worksheet index pointer for the Reader * */
|
||||||
$sheet = 0;
|
$reader->setSheetIndex($sheet);
|
||||||
/* Loop to read our worksheet in "chunk size" blocks **/
|
/* Load only the rows that match our filter into a new worksheet in the PhpSpreadsheet Object * */
|
||||||
/** $startRow is set to 2 initially because we always read the headings in row #1 **/
|
$reader->loadIntoExisting($inputFileName, $spreadsheet);
|
||||||
for ($startRow = 2; $startRow <= 240; $startRow += $chunkSize) {
|
/* Set the worksheet title (to reference the "sheet" of data that we've loaded) * */
|
||||||
echo 'Loading WorkSheet #', ($sheet + 1), ' using configurable filter for headings row 1 and for rows ', $startRow, ' to ', ($startRow + $chunkSize - 1), '<br />';
|
/* and increment the sheet index as well * */
|
||||||
/* Tell the Read Filter, the limits on which rows we want to read this iteration **/
|
$spreadsheet->getActiveSheet()->setTitle('Country Data #' . ( ++$sheet));
|
||||||
$chunkFilter->setRows($startRow, $chunkSize);
|
}
|
||||||
|
|
||||||
/* Increment the worksheet index pointer for the Reader **/
|
echo '<hr />';
|
||||||
$reader->setSheetIndex($sheet);
|
|
||||||
/* Load only the rows that match our filter into a new worksheet in the PhpSpreadsheet Object **/
|
|
||||||
$reader->loadIntoExisting($inputFileName, $spreadsheet);
|
|
||||||
/* Set the worksheet title (to reference the "sheet" of data that we've loaded) **/
|
|
||||||
/* and increment the sheet index as well **/
|
|
||||||
$spreadsheet->getActiveSheet()->setTitle('Country Data #' . (++$sheet));
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo $spreadsheet->getSheetCount(), ' worksheet', (($spreadsheet->getSheetCount() == 1) ? '' : 's'), ' loaded<br /><br />';
|
||||||
|
$loadedSheetNames = $spreadsheet->getSheetNames();
|
||||||
echo $spreadsheet->getSheetCount(), ' worksheet', (($spreadsheet->getSheetCount() == 1) ? '' : 's'), ' loaded<br /><br />';
|
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||||
$loadedSheetNames = $spreadsheet->getSheetNames();
|
echo '<b>Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, '</b><br />';
|
||||||
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
$spreadsheet->setActiveSheetIndexByName($loadedSheetName);
|
||||||
echo '<b>Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, '</b><br />';
|
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, false, false, true);
|
||||||
$spreadsheet->setActiveSheetIndexByName($loadedSheetName);
|
var_dump($sheetData);
|
||||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, false, false, true);
|
echo '<br />';
|
||||||
var_dump($sheetData);
|
}
|
||||||
echo '<br />';
|
?>
|
||||||
}
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -7,66 +7,63 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #15</title>
|
<title>PhpSpreadsheet Reader Example #15</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #15</h1>
|
<h1>PhpSpreadsheet Reader Example #15</h1>
|
||||||
<h2>Simple File Reader for Tab-Separated Value File using the Advanced Value Binder</h2>
|
<h2>Simple File Reader for Tab-Separated Value File using the Advanced Value Binder</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
Cell::setValueBinder(new Cell\AdvancedValueBinder());
|
||||||
|
|
||||||
Cell::setValueBinder(new Cell\AdvancedValueBinder());
|
$inputFileType = 'Csv';
|
||||||
|
$inputFileName = './sampleData/example1.tsv';
|
||||||
|
|
||||||
$inputFileType = 'Csv';
|
$reader = IOFactory::createReader($inputFileType);
|
||||||
$inputFileName = './sampleData/example1.tsv';
|
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);
|
||||||
|
$spreadsheet->getActiveSheet()->setTitle(pathinfo($inputFileName, PATHINFO_BASENAME));
|
||||||
|
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
echo '<hr />';
|
||||||
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);
|
|
||||||
$spreadsheet->getActiveSheet()->setTitle(pathinfo($inputFileName, PATHINFO_BASENAME));
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo $spreadsheet->getSheetCount(), ' worksheet', (($spreadsheet->getSheetCount() == 1) ? '' : 's'), ' loaded<br /><br />';
|
||||||
|
$loadedSheetNames = $spreadsheet->getSheetNames();
|
||||||
|
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||||
|
echo '<b>Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, ' (Formatted)</b><br />';
|
||||||
|
$spreadsheet->setActiveSheetIndexByName($loadedSheetName);
|
||||||
|
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||||
|
var_dump($sheetData);
|
||||||
|
echo '<br />';
|
||||||
|
}
|
||||||
|
|
||||||
echo $spreadsheet->getSheetCount(),' worksheet',(($spreadsheet->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />';
|
echo '<hr />';
|
||||||
$loadedSheetNames = $spreadsheet->getSheetNames();
|
|
||||||
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
|
||||||
echo '<b>Worksheet #',$sheetIndex,' -> ',$loadedSheetName,' (Formatted)</b><br />';
|
|
||||||
$spreadsheet->setActiveSheetIndexByName($loadedSheetName);
|
|
||||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
|
||||||
var_dump($sheetData);
|
|
||||||
echo '<br />';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '<hr />';
|
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||||
|
echo '<b>Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, ' (Unformatted)</b><br />';
|
||||||
|
$spreadsheet->setActiveSheetIndexByName($loadedSheetName);
|
||||||
|
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, false, true);
|
||||||
|
var_dump($sheetData);
|
||||||
|
echo '<br />';
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
echo '<hr />';
|
||||||
echo '<b>Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, ' (Unformatted)</b><br />';
|
|
||||||
$spreadsheet->setActiveSheetIndexByName($loadedSheetName);
|
|
||||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, false, true);
|
|
||||||
var_dump($sheetData);
|
|
||||||
echo '<br />';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '<hr />';
|
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||||
|
echo '<b>Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, ' (Raw)</b><br />';
|
||||||
foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
$spreadsheet->setActiveSheetIndexByName($loadedSheetName);
|
||||||
echo '<b>Worksheet #', $sheetIndex, ' -> ', $loadedSheetName, ' (Raw)</b><br />';
|
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, false, false, true);
|
||||||
$spreadsheet->setActiveSheetIndexByName($loadedSheetName);
|
var_dump($sheetData);
|
||||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, false, false, true);
|
echo '<br />';
|
||||||
var_dump($sheetData);
|
}
|
||||||
echo '<br />';
|
?>
|
||||||
}
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -7,36 +7,33 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #16</title>
|
<title>PhpSpreadsheet Reader Example #16</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #16</h1>
|
<h1>PhpSpreadsheet Reader Example #16</h1>
|
||||||
<h2>Handling Loader Exceptions using Try/Catch</h2>
|
<h2>Handling Loader Exceptions using Try/Catch</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.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 = IOFactory::load($inputFileName);
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
$inputFileName = './sampleData/example_1.xls';
|
echo '<hr />';
|
||||||
echo 'Loading file ',pathinfo($inputFileName, PATHINFO_BASENAME),' using IOFactory to identify the format<br />';
|
|
||||||
try {
|
|
||||||
$spreadsheet = IOFactory::load($inputFileName);
|
|
||||||
} catch (InvalidArgumentException $e) {
|
|
||||||
die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '<hr />';
|
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
||||||
|
var_dump($sheetData);
|
||||||
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
|
?>
|
||||||
var_dump($sheetData);
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,42 +6,35 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #17</title>
|
<title>PhpSpreadsheet Reader Example #17</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #17</h1>
|
<h1>PhpSpreadsheet Reader Example #17</h1>
|
||||||
<h2>Simple File Reader Loading Several Named WorkSheets</h2>
|
<h2>Simple File Reader Loading Several Named WorkSheets</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Xls';
|
||||||
|
$inputFileName = './sampleData/example1.xls';
|
||||||
|
|
||||||
$inputFileType = 'Xls';
|
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||||
// $inputFileType = 'Xlsx';
|
$reader = IOFactory::createReader($inputFileType);
|
||||||
// $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 />';
|
/* Read the list of Worksheet Names from the Workbook file * */
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
echo 'Read the list of Worksheets in the WorkBook<br />';
|
||||||
|
$worksheetNames = $reader->listWorksheetNames($inputFileName);
|
||||||
|
|
||||||
/* Read the list of Worksheet Names from the Workbook file **/
|
echo 'There are ', count($worksheetNames), ' worksheet', ((count($worksheetNames) == 1) ? '' : 's'), ' in the workbook<br /><br />';
|
||||||
echo 'Read the list of Worksheets in the WorkBook<br />';
|
foreach ($worksheetNames as $worksheetName) {
|
||||||
$worksheetNames = $reader->listWorksheetNames($inputFileName);
|
echo $worksheetName, '<br />';
|
||||||
|
}
|
||||||
echo 'There are ',count($worksheetNames),' worksheet',((count($worksheetNames) == 1) ? '' : 's'),' in the workbook<br /><br />';
|
?>
|
||||||
foreach ($worksheetNames as $worksheetName) {
|
<body>
|
||||||
echo $worksheetName,'<br />';
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,42 +6,35 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #18</title>
|
<title>PhpSpreadsheet Reader Example #18</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #18</h1>
|
<h1>PhpSpreadsheet Reader Example #18</h1>
|
||||||
<h2>Reading list of WorkSheets without loading entire file</h2>
|
<h2>Reading list of WorkSheets without loading entire file</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Xls';
|
||||||
|
$inputFileName = './sampleData/example1.xls';
|
||||||
|
|
||||||
$inputFileType = 'Xls';
|
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' information using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||||
// $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 = IOFactory::createReader($inputFileType);
|
||||||
|
$worksheetNames = $reader->listWorksheetNames($inputFileName);
|
||||||
|
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
echo '<h3>Worksheet Names</h3>';
|
||||||
$worksheetNames = $reader->listWorksheetNames($inputFileName);
|
echo '<ol>';
|
||||||
|
foreach ($worksheetNames as $worksheetName) {
|
||||||
echo '<h3>Worksheet Names</h3>';
|
echo '<li>', $worksheetName, '</li>';
|
||||||
echo '<ol>';
|
}
|
||||||
foreach ($worksheetNames as $worksheetName) {
|
echo '</ol>';
|
||||||
echo '<li>', $worksheetName, '</li>';
|
?>
|
||||||
}
|
<body>
|
||||||
echo '</ol>';
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,45 +6,38 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reader Example #19</title>
|
<title>PhpSpreadsheet Reader Example #19</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reader Example #19</h1>
|
<h1>PhpSpreadsheet Reader Example #19</h1>
|
||||||
<h2>Reading WorkSheet information without loading entire file</h2>
|
<h2>Reading WorkSheet information without loading entire file</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Xls';
|
||||||
|
$inputFileName = './sampleData/example1.xls';
|
||||||
|
|
||||||
$inputFileType = 'Xls';
|
echo 'Loading file ', pathinfo($inputFileName, PATHINFO_BASENAME), ' information using IOFactory with a defined reader type of ', $inputFileType, '<br />';
|
||||||
// $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 = IOFactory::createReader($inputFileType);
|
||||||
|
$worksheetData = $reader->listWorksheetInfo($inputFileName);
|
||||||
|
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
echo '<h3>Worksheet Information</h3>';
|
||||||
$worksheetData = $reader->listWorksheetInfo($inputFileName);
|
echo '<ol>';
|
||||||
|
foreach ($worksheetData as $worksheet) {
|
||||||
echo '<h3>Worksheet Information</h3>';
|
echo '<li>', $worksheet['worksheetName'], '<br />';
|
||||||
echo '<ol>';
|
echo 'Rows: ', $worksheet['totalRows'], ' Columns: ', $worksheet['totalColumns'], '<br />';
|
||||||
foreach ($worksheetData as $worksheet) {
|
echo 'Cell Range: A1:', $worksheet['lastColumnLetter'], $worksheet['totalRows'];
|
||||||
echo '<li>', $worksheet['worksheetName'], '<br />';
|
echo '</li>';
|
||||||
echo 'Rows: ', $worksheet['totalRows'], ' Columns: ', $worksheet['totalColumns'], '<br />';
|
}
|
||||||
echo 'Cell Range: A1:', $worksheet['lastColumnLetter'], $worksheet['totalRows'];
|
echo '</ol>';
|
||||||
echo '</li>';
|
?>
|
||||||
}
|
<body>
|
||||||
echo '</ol>';
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -6,83 +6,80 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reading WorkBook Data Example #01</title>
|
<title>PhpSpreadsheet Reading WorkBook Data Example #01</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reading WorkBook Data Example #01</h1>
|
<h1>PhpSpreadsheet Reading WorkBook Data Example #01</h1>
|
||||||
<h2>Read the WorkBook Properties</h2>
|
<h2>Read the WorkBook Properties</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Xls';
|
||||||
|
$inputFileName = './sampleData/example1.xls';
|
||||||
|
|
||||||
$inputFileType = 'Xls';
|
/* Create a new Reader of the type defined in $inputFileType * */
|
||||||
$inputFileName = './sampleData/example1.xls';
|
$reader = IOFactory::createReader($inputFileType);
|
||||||
|
/* Load $inputFileName to a PhpSpreadsheet Object * */
|
||||||
|
$spreadsheet = $reader->load($inputFileName);
|
||||||
|
|
||||||
/* Create a new Reader of the type defined in $inputFileType **/
|
echo '<hr />';
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
|
||||||
/* Load $inputFileName to a PhpSpreadsheet Object **/
|
|
||||||
$spreadsheet = $reader->load($inputFileName);
|
|
||||||
|
|
||||||
echo '<hr />';
|
/* Read the document's creator property * */
|
||||||
|
$creator = $spreadsheet->getProperties()->getCreator();
|
||||||
|
echo '<b>Document Creator: </b>', $creator, '<br />';
|
||||||
|
|
||||||
/* Read the document's creator property **/
|
/* Read the Date when the workbook was created (as a PHP timestamp value) * */
|
||||||
$creator = $spreadsheet->getProperties()->getCreator();
|
$creationDatestamp = $spreadsheet->getProperties()->getCreated();
|
||||||
echo '<b>Document Creator: </b>',$creator,'<br />';
|
/* Format the date and time using the standard PHP date() function * */
|
||||||
|
$creationDate = date('l, d<\s\up>S</\s\up> F Y', $creationDatestamp);
|
||||||
|
$creationTime = date('g:i A', $creationDatestamp);
|
||||||
|
echo '<b>Created On: </b>', $creationDate, ' at ', $creationTime, '<br />';
|
||||||
|
|
||||||
/* Read the Date when the workbook was created (as a PHP timestamp value) **/
|
/* Read the name of the last person to modify this workbook * */
|
||||||
$creationDatestamp = $spreadsheet->getProperties()->getCreated();
|
$modifiedBy = $spreadsheet->getProperties()->getLastModifiedBy();
|
||||||
/* Format the date and time using the standard PHP date() function **/
|
echo '<b>Last Modified By: </b>', $modifiedBy, '<br />';
|
||||||
$creationDate = date('l, d<\s\up>S</\s\up> F Y', $creationDatestamp);
|
|
||||||
$creationTime = date('g:i A', $creationDatestamp);
|
|
||||||
echo '<b>Created On: </b>',$creationDate,' at ',$creationTime,'<br />';
|
|
||||||
|
|
||||||
/* Read the name of the last person to modify this workbook **/
|
/* Read the Date when the workbook was last modified (as a PHP timestamp value) * */
|
||||||
$modifiedBy = $spreadsheet->getProperties()->getLastModifiedBy();
|
$modifiedDatestamp = $spreadsheet->getProperties()->getModified();
|
||||||
echo '<b>Last Modified By: </b>',$modifiedBy,'<br />';
|
/* Format the date and time using the standard PHP date() function * */
|
||||||
|
$modifiedDate = date('l, d<\s\up>S</\s\up> F Y', $modifiedDatestamp);
|
||||||
|
$modifiedTime = date('g:i A', $modifiedDatestamp);
|
||||||
|
echo '<b>Last Modified On: </b>', $modifiedDate, ' at ', $modifiedTime, '<br />';
|
||||||
|
|
||||||
/* Read the Date when the workbook was last modified (as a PHP timestamp value) **/
|
/* Read the workbook title property * */
|
||||||
$modifiedDatestamp = $spreadsheet->getProperties()->getModified();
|
$workbookTitle = $spreadsheet->getProperties()->getTitle();
|
||||||
/* Format the date and time using the standard PHP date() function **/
|
echo '<b>Title: </b>', $workbookTitle, '<br />';
|
||||||
$modifiedDate = date('l, d<\s\up>S</\s\up> F Y', $modifiedDatestamp);
|
|
||||||
$modifiedTime = date('g:i A', $modifiedDatestamp);
|
|
||||||
echo '<b>Last Modified On: </b>',$modifiedDate,' at ',$modifiedTime,'<br />';
|
|
||||||
|
|
||||||
/* Read the workbook title property **/
|
/* Read the workbook description property * */
|
||||||
$workbookTitle = $spreadsheet->getProperties()->getTitle();
|
$description = $spreadsheet->getProperties()->getDescription();
|
||||||
echo '<b>Title: </b>',$workbookTitle,'<br />';
|
echo '<b>Description: </b>', $description, '<br />';
|
||||||
|
|
||||||
/* Read the workbook description property **/
|
/* Read the workbook subject property * */
|
||||||
$description = $spreadsheet->getProperties()->getDescription();
|
$subject = $spreadsheet->getProperties()->getSubject();
|
||||||
echo '<b>Description: </b>',$description,'<br />';
|
echo '<b>Subject: </b>', $subject, '<br />';
|
||||||
|
|
||||||
/* Read the workbook subject property **/
|
/* Read the workbook keywords property * */
|
||||||
$subject = $spreadsheet->getProperties()->getSubject();
|
$keywords = $spreadsheet->getProperties()->getKeywords();
|
||||||
echo '<b>Subject: </b>',$subject,'<br />';
|
echo '<b>Keywords: </b>', $keywords, '<br />';
|
||||||
|
|
||||||
/* Read the workbook keywords property **/
|
/* Read the workbook category property * */
|
||||||
$keywords = $spreadsheet->getProperties()->getKeywords();
|
$category = $spreadsheet->getProperties()->getCategory();
|
||||||
echo '<b>Keywords: </b>',$keywords,'<br />';
|
echo '<b>Category: </b>', $category, '<br />';
|
||||||
|
|
||||||
/* Read the workbook category property **/
|
/* Read the workbook company property * */
|
||||||
$category = $spreadsheet->getProperties()->getCategory();
|
$company = $spreadsheet->getProperties()->getCompany();
|
||||||
echo '<b>Category: </b>',$category,'<br />';
|
echo '<b>Company: </b>', $company, '<br />';
|
||||||
|
|
||||||
/* Read the workbook company property **/
|
/* Read the workbook manager property * */
|
||||||
$company = $spreadsheet->getProperties()->getCompany();
|
$manager = $spreadsheet->getProperties()->getManager();
|
||||||
echo '<b>Company: </b>',$company,'<br />';
|
echo '<b>Manager: </b>', $manager, '<br />';
|
||||||
|
?>
|
||||||
/* Read the workbook manager property **/
|
<body>
|
||||||
$manager = $spreadsheet->getProperties()->getManager();
|
|
||||||
echo '<b>Manager: </b>',$manager,'<br />';
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -6,41 +6,38 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reading WorkBook Data Example #02</title>
|
<title>PhpSpreadsheet Reading WorkBook Data Example #02</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reading WorkBook Data Example #02</h1>
|
<h1>PhpSpreadsheet Reading WorkBook Data Example #02</h1>
|
||||||
<h2>Read a list of Custom Properties for a WorkBook</h2>
|
<h2>Read a list of Custom Properties for a WorkBook</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Xlsx';
|
||||||
|
$inputFileName = './sampleData/example1.xlsx';
|
||||||
|
|
||||||
$inputFileType = 'Xlsx';
|
/* Create a new Reader of the type defined in $inputFileType * */
|
||||||
$inputFileName = './sampleData/example1.xlsx';
|
$reader = IOFactory::createReader($inputFileType);
|
||||||
|
/* Load $inputFileName to a PhpSpreadsheet Object * */
|
||||||
|
$spreadsheet = $reader->load($inputFileName);
|
||||||
|
|
||||||
/* Create a new Reader of the type defined in $inputFileType **/
|
echo '<hr />';
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
|
||||||
/* Load $inputFileName to a PhpSpreadsheet Object **/
|
|
||||||
$spreadsheet = $reader->load($inputFileName);
|
|
||||||
|
|
||||||
echo '<hr />';
|
/* Read an array list of any custom properties for this document * */
|
||||||
|
$customPropertyList = $spreadsheet->getProperties()->getCustomProperties();
|
||||||
|
|
||||||
/* Read an array list of any custom properties for this document **/
|
echo '<b>Custom Property names: </b><br />';
|
||||||
$customPropertyList = $spreadsheet->getProperties()->getCustomProperties();
|
foreach ($customPropertyList as $customPropertyName) {
|
||||||
|
echo $customPropertyName, '<br />';
|
||||||
echo '<b>Custom Property names: </b><br />';
|
}
|
||||||
foreach ($customPropertyList as $customPropertyName) {
|
?>
|
||||||
echo $customPropertyName, '<br />';
|
<body>
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -6,69 +6,66 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reading WorkBook Data Example #03</title>
|
<title>PhpSpreadsheet Reading WorkBook Data Example #03</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reading WorkBook Data Example #03</h1>
|
<h1>PhpSpreadsheet Reading WorkBook Data Example #03</h1>
|
||||||
<h2>Read Custom Property Values for a WorkBook</h2>
|
<h2>Read Custom Property Values for a WorkBook</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Xlsx';
|
||||||
|
$inputFileName = './sampleData/example1.xlsx';
|
||||||
|
|
||||||
$inputFileType = 'Xlsx';
|
/* Create a new Reader of the type defined in $inputFileType * */
|
||||||
$inputFileName = './sampleData/example1.xlsx';
|
$reader = IOFactory::createReader($inputFileType);
|
||||||
|
/* Load $inputFileName to a PhpSpreadsheet Object * */
|
||||||
|
$spreadsheet = $reader->load($inputFileName);
|
||||||
|
|
||||||
/* Create a new Reader of the type defined in $inputFileType **/
|
echo '<hr />';
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
|
||||||
/* Load $inputFileName to a PhpSpreadsheet Object **/
|
|
||||||
$spreadsheet = $reader->load($inputFileName);
|
|
||||||
|
|
||||||
echo '<hr />';
|
/* Read an array list of any custom properties for this document * */
|
||||||
|
$customPropertyList = $spreadsheet->getProperties()->getCustomProperties();
|
||||||
|
|
||||||
/* Read an array list of any custom properties for this document **/
|
echo '<b>Custom Properties: </b><br />';
|
||||||
$customPropertyList = $spreadsheet->getProperties()->getCustomProperties();
|
/* Loop through the list of custom properties * */
|
||||||
|
foreach ($customPropertyList as $customPropertyName) {
|
||||||
|
echo '<b>', $customPropertyName, ': </b>';
|
||||||
|
/* Retrieve the property value * */
|
||||||
|
$propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customPropertyName);
|
||||||
|
/* Retrieve the property type * */
|
||||||
|
$propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customPropertyName);
|
||||||
|
|
||||||
echo '<b>Custom Properties: </b><br />';
|
/* Manipulate properties as appropriate for display purposes * */
|
||||||
/* Loop through the list of custom properties **/
|
switch ($propertyType) {
|
||||||
foreach ($customPropertyList as $customPropertyName) {
|
case 'i': // integer
|
||||||
echo '<b>',$customPropertyName,': </b>';
|
$propertyType = 'integer number';
|
||||||
/* Retrieve the property value **/
|
break;
|
||||||
$propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customPropertyName);
|
case 'f': // float
|
||||||
/* Retrieve the property type **/
|
$propertyType = 'floating point number';
|
||||||
$propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customPropertyName);
|
break;
|
||||||
|
case 's': // string
|
||||||
|
$propertyType = 'string';
|
||||||
|
break;
|
||||||
|
case 'd': // date
|
||||||
|
$propertyValue = date('l, d<\s\up>S</\s\up> F Y g:i A', $propertyValue);
|
||||||
|
$propertyType = 'date';
|
||||||
|
break;
|
||||||
|
case 'b': // boolean
|
||||||
|
$propertyValue = ($propertyValue) ? 'TRUE' : 'FALSE';
|
||||||
|
$propertyType = 'boolean';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Manipulate properties as appropriate for display purposes **/
|
echo $propertyValue, ' (', $propertyType, ')<br />';
|
||||||
switch ($propertyType) {
|
}
|
||||||
case 'i': // integer
|
?>
|
||||||
$propertyType = 'integer number';
|
<body>
|
||||||
break;
|
|
||||||
case 'f': // float
|
|
||||||
$propertyType = 'floating point number';
|
|
||||||
break;
|
|
||||||
case 's': // string
|
|
||||||
$propertyType = 'string';
|
|
||||||
break;
|
|
||||||
case 'd': // date
|
|
||||||
$propertyValue = date('l, d<\s\up>S</\s\up> F Y g:i A', $propertyValue);
|
|
||||||
$propertyType = 'date';
|
|
||||||
break;
|
|
||||||
case 'b': // boolean
|
|
||||||
$propertyValue = ($propertyValue) ? 'TRUE' : 'FALSE';
|
|
||||||
$propertyType = 'boolean';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo $propertyValue, ' (', $propertyType, ')<br />';
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -6,45 +6,42 @@ error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Reading WorkBook Data Example #04</title>
|
<title>PhpSpreadsheet Reading WorkBook Data Example #04</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>PhpSpreadsheet Reading WorkBook Data Example #04</h1>
|
<h1>PhpSpreadsheet Reading WorkBook Data Example #04</h1>
|
||||||
<h2>Get a List of the Worksheets in a WorkBook</h2>
|
<h2>Get a List of the Worksheets in a WorkBook</h2>
|
||||||
<?php
|
<?php
|
||||||
|
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../src/Bootstrap.php';
|
$inputFileType = 'Xls';
|
||||||
|
$inputFileName = './sampleData/example2.xls';
|
||||||
|
|
||||||
$inputFileType = 'Xls';
|
/* Create a new Reader of the type defined in $inputFileType * */
|
||||||
$inputFileName = './sampleData/example2.xls';
|
$reader = IOFactory::createReader($inputFileType);
|
||||||
|
/* Load $inputFileName to a PhpSpreadsheet Object * */
|
||||||
|
$spreadsheet = $reader->load($inputFileName);
|
||||||
|
|
||||||
/* Create a new Reader of the type defined in $inputFileType **/
|
echo '<hr />';
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
|
||||||
/* Load $inputFileName to a PhpSpreadsheet Object **/
|
|
||||||
$spreadsheet = $reader->load($inputFileName);
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo 'Reading the number of Worksheets in the WorkBook<br />';
|
||||||
|
/* Use the PhpSpreadsheet object's getSheetCount() method to get a count of the number of WorkSheets in the WorkBook */
|
||||||
|
$sheetCount = $spreadsheet->getSheetCount();
|
||||||
|
echo 'There ', (($sheetCount == 1) ? 'is' : 'are'), ' ', $sheetCount, ' WorkSheet', (($sheetCount == 1) ? '' : 's'), ' in the WorkBook<br /><br />';
|
||||||
|
|
||||||
echo 'Reading the number of Worksheets in the WorkBook<br />';
|
echo 'Reading the names of Worksheets in the WorkBook<br />';
|
||||||
/* Use the PhpSpreadsheet object's getSheetCount() method to get a count of the number of WorkSheets in the WorkBook */
|
/* Use the PhpSpreadsheet object's getSheetNames() method to get an array listing the names/titles of the WorkSheets in the WorkBook */
|
||||||
$sheetCount = $spreadsheet->getSheetCount();
|
$sheetNames = $spreadsheet->getSheetNames();
|
||||||
echo 'There ',(($sheetCount == 1) ? 'is' : 'are'),' ',$sheetCount,' WorkSheet',(($sheetCount == 1) ? '' : 's'),' in the WorkBook<br /><br />';
|
foreach ($sheetNames as $sheetIndex => $sheetName) {
|
||||||
|
echo 'WorkSheet #', $sheetIndex, ' is named "', $sheetName, '"<br />';
|
||||||
echo 'Reading the names of Worksheets in the WorkBook<br />';
|
}
|
||||||
/* Use the PhpSpreadsheet object's getSheetNames() method to get an array listing the names/titles of the WorkSheets in the WorkBook */
|
?>
|
||||||
$sheetNames = $spreadsheet->getSheetNames();
|
<body>
|
||||||
foreach ($sheetNames as $sheetIndex => $sheetName) {
|
|
||||||
echo 'WorkSheet #',$sheetIndex,' is named "',$sheetName,'"<br />';
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,48 +1,44 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/London');
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<title>PhpSpreadsheet Examples</title>
|
<title>PhpSpreadsheet Examples</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
$exampleTypeList = glob('./*', GLOB_ONLYDIR);
|
||||||
|
|
||||||
$exampleTypeList = glob('./*', GLOB_ONLYDIR);
|
foreach ($exampleTypeList as $exampleType) {
|
||||||
|
echo '<h1>PhpSpreadsheet ' . pathinfo($exampleType, PATHINFO_BASENAME) . ' Examples</h1>';
|
||||||
|
|
||||||
foreach ($exampleTypeList as $exampleType) {
|
$exampleList = glob('./' . $exampleType . '/*.php');
|
||||||
echo '<h1>PhpSpreadsheet ' . pathinfo($exampleType, PATHINFO_BASENAME) . ' Examples</h1>';
|
|
||||||
|
|
||||||
$exampleList = glob('./' . $exampleType . '/*.php');
|
foreach ($exampleList as $exampleFile) {
|
||||||
|
$fileData = file_get_contents($exampleFile);
|
||||||
|
|
||||||
foreach ($exampleList as $exampleFile) {
|
$h1Pattern = '#<h1>(.*?)</h1>#';
|
||||||
$fileData = file_get_contents($exampleFile);
|
$h2Pattern = '#<h2>(.*?)</h2>#';
|
||||||
|
|
||||||
$h1Pattern = '#<h1>(.*?)</h1>#';
|
if (preg_match($h1Pattern, $fileData, $out)) {
|
||||||
$h2Pattern = '#<h2>(.*?)</h2>#';
|
$h1Text = $out[1];
|
||||||
|
$h2Text = (preg_match($h2Pattern, $fileData, $out)) ? $out[1] : '';
|
||||||
|
|
||||||
if (preg_match($h1Pattern, $fileData, $out)) {
|
echo '<a href="', $exampleFile, '">', $h1Text, '</a><br />';
|
||||||
$h1Text = $out[1];
|
if (($h2Text > '') &&
|
||||||
$h2Text = (preg_match($h2Pattern, $fileData, $out)) ? $out[1] : '';
|
(pathinfo($exampleType, PATHINFO_BASENAME) != 'Calculations')) {
|
||||||
|
echo $h2Text, '<br />';
|
||||||
echo '<a href="', $exampleFile, '">', $h1Text, '</a><br />';
|
}
|
||||||
if (($h2Text > '') &&
|
}
|
||||||
(pathinfo($exampleType, PATHINFO_BASENAME) != 'Calculations')) {
|
|
||||||
echo $h2Text, '<br />';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
?>
|
||||||
}
|
<body>
|
||||||
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
</html>
|
</html>
|
|
@ -90,7 +90,7 @@ calculated values, or force recalculation in Excel2003.
|
||||||
### Excel functions that return a Date and Time value
|
### Excel functions that return a Date and Time value
|
||||||
|
|
||||||
Any of the Date and Time functions that return a date value in Excel can
|
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
|
It is possible for scripts to change the data type used for returning
|
||||||
date values by calling the
|
date values by calling the
|
||||||
|
@ -103,9 +103,9 @@ method:
|
||||||
|
|
||||||
where the following constants can be used for `$returnDateType`:
|
where the following constants can be used for `$returnDateType`:
|
||||||
|
|
||||||
- `\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_PHP_NUMERIC`
|
- `\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_PHP_NUMERIC`
|
||||||
- `\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_PHP_OBJECT`
|
- `\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_PHP_OBJECT`
|
||||||
- `\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_EXCEL`
|
- `\PhpOffice\PhpSpreadsheet\Calculation\Functions::RETURNDATE_EXCEL`
|
||||||
|
|
||||||
The method will return a Boolean True on success, False on failure (e.g.
|
The method will return a Boolean True on success, False on failure (e.g.
|
||||||
if an invalid value is passed in for the return date type).
|
if an invalid value is passed in for the return date type).
|
||||||
|
@ -117,11 +117,11 @@ method can be used to determine the current value of this setting:
|
||||||
$returnDateType = \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType();
|
$returnDateType = \PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType();
|
||||||
```
|
```
|
||||||
|
|
||||||
The default is RETURNDATE\_PHP\_NUMERIC.
|
The default is `RETURNDATE_PHP_NUMERIC`.
|
||||||
|
|
||||||
#### PHP Timestamps
|
#### 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
|
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
|
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
|
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
|
gives PHP a date range of between 14th December 1901 and 19th January
|
||||||
2038.
|
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
|
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
|
#### 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
|
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
|
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
|
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`:
|
where the following constants can be used for `$baseDate`:
|
||||||
|
|
||||||
- \PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR\_WINDOWS\_1900
|
- `\PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR_WINDOWS_1900`
|
||||||
- \PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR\_MAC\_1904
|
- `\PhpOffice\PhpSpreadsheet\Shared\Date::CALENDAR_MAC_1904`
|
||||||
|
|
||||||
The method will return a Boolean True on success, False on failure (e.g.
|
The method will return a Boolean True on success, False on failure (e.g.
|
||||||
if an invalid value is passed in).
|
if an invalid value is passed in).
|
||||||
|
@ -170,31 +170,31 @@ be used to determine the current value of this setting:
|
||||||
$baseDate = \PhpOffice\PhpSpreadsheet\Shared\Date::getExcelCalendar();
|
$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
|
#### Functions that return a Date/Time Value
|
||||||
|
|
||||||
- DATE
|
- DATE
|
||||||
- DATEVALUE
|
- DATEVALUE
|
||||||
- EDATE
|
- EDATE
|
||||||
- EOMONTH
|
- EOMONTH
|
||||||
- NOW
|
- NOW
|
||||||
- TIME
|
- TIME
|
||||||
- TIMEVALUE
|
- TIMEVALUE
|
||||||
- TODAY
|
- TODAY
|
||||||
|
|
||||||
### Excel functions that accept Date and Time values as parameters
|
### Excel functions that accept Date and Time values as parameters
|
||||||
|
|
||||||
Date values passed in as parameters to a function can be an Excel
|
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
|
date value (e.g. '1-Jan-2009'). PhpSpreadsheet will attempt to identify
|
||||||
their type based on the PHP datatype:
|
their type based on the PHP datatype:
|
||||||
|
|
||||||
An integer numeric value will be treated as a PHP/Unix timestamp. A real
|
An integer numeric value will be treated as a PHP/Unix timestamp. A real
|
||||||
(floating point) numeric value will be treated as an Excel
|
(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)
|
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
|
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
|
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.
|
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,
|
considered an error by a US-based server, but which is not ambiguous,
|
||||||
then PhpSpreadsheet will attempt to correct this to 31st December 2008.
|
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
|
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),
|
handle a wider range of formats than the normal `strtotime()` function),
|
||||||
then the function will return a `#VALUE` error. However, Excel
|
then the function will return a `#VALUE` error. However, Excel
|
||||||
recommends that you should always use date/timestamps for your date
|
recommends that you should always use date/timestamps for your date
|
||||||
|
@ -213,28 +213,28 @@ The same principle applies when data is being written to Excel. Cells
|
||||||
containing date actual values (rather than Excel functions that return a
|
containing date actual values (rather than Excel functions that return a
|
||||||
date value) are always written as Excel dates, converting where
|
date value) are always written as Excel dates, converting where
|
||||||
necessary. If a cell formatted as a date contains an integer or
|
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
|
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
|
conversion is required. Note that string values are written as strings
|
||||||
rather than converted to Excel date timestamp values.
|
rather than converted to Excel date timestamp values.
|
||||||
|
|
||||||
#### Functions that expect a Date/Time Value
|
#### Functions that expect a Date/Time Value
|
||||||
|
|
||||||
- DATEDIF
|
- DATEDIF
|
||||||
- DAY
|
- DAY
|
||||||
- DAYS360
|
- DAYS360
|
||||||
- EDATE
|
- EDATE
|
||||||
- EOMONTH
|
- EOMONTH
|
||||||
- HOUR
|
- HOUR
|
||||||
- MINUTE
|
- MINUTE
|
||||||
- MONTH
|
- MONTH
|
||||||
- NETWORKDAYS
|
- NETWORKDAYS
|
||||||
- SECOND
|
- SECOND
|
||||||
- WEEKDAY
|
- WEEKDAY
|
||||||
- WEEKNUM
|
- WEEKNUM
|
||||||
- WORKDAY
|
- WORKDAY
|
||||||
- YEAR
|
- YEAR
|
||||||
- YEARFRAC
|
- YEARFRAC
|
||||||
|
|
||||||
### Helper Methods
|
### Helper Methods
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ number of other methods are available in the
|
||||||
\PhpOffice\PhpSpreadsheet\Shared\Date class that can help when working
|
\PhpOffice\PhpSpreadsheet\Shared\Date class that can help when working
|
||||||
with dates:
|
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
|
Converts a date/time from an Excel date timestamp to return a PHP
|
||||||
serialized date/timestamp.
|
serialized date/timestamp.
|
||||||
|
@ -251,17 +251,17 @@ serialized date/timestamp.
|
||||||
Note that this method does not trap for Excel dates that fall outside of
|
Note that this method does not trap for Excel dates that fall outside of
|
||||||
the valid range for a PHP date timestamp.
|
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.
|
object.
|
||||||
|
|
||||||
#### \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($PHPDate)
|
#### \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.
|
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
|
Takes year, month and day values (and optional hour, minute and second
|
||||||
values) and returns an Excel date timestamp value.
|
values) and returns an Excel date timestamp value.
|
||||||
|
@ -979,7 +979,7 @@ Excel and in PHP.
|
||||||
|
|
||||||
#### DATE
|
#### 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.
|
object representing the date that is referenced by the parameters.
|
||||||
|
|
||||||
##### Syntax
|
##### Syntax
|
||||||
|
@ -1025,7 +1025,7 @@ February 27, 2008.
|
||||||
|
|
||||||
**mixed** A date/time stamp that corresponds to the given date.
|
**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
|
or an Excel timestamp value (real), depending on the value of
|
||||||
\PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType().
|
\PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType().
|
||||||
|
|
||||||
|
@ -1093,12 +1093,12 @@ variety of different intervals, such number of years, months, or days.
|
||||||
|
|
||||||
**date1** First Date.
|
**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.
|
represented as a string.
|
||||||
|
|
||||||
**date2** Second Date.
|
**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.
|
represented as a string.
|
||||||
|
|
||||||
**unit** The interval type to use for the calculation
|
**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.
|
**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
|
or an Excel timestamp value (real), depending on the value of
|
||||||
\PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType().
|
\PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType().
|
||||||
|
|
||||||
|
@ -1290,7 +1290,7 @@ $retVal = call_user_func_array(
|
||||||
|
|
||||||
##### Notes
|
##### 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()`
|
(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
|
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.
|
date functions (such as DATEDIF) when the parameter value is a string.
|
||||||
|
@ -1317,7 +1317,7 @@ integer ranging from 1 to 31.
|
||||||
|
|
||||||
**datetime** 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.
|
represented as a string.
|
||||||
|
|
||||||
##### Return Value
|
##### Return Value
|
||||||
|
@ -1371,12 +1371,12 @@ accounting systems.
|
||||||
|
|
||||||
**date1** First Date.
|
**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.
|
represented as a string.
|
||||||
|
|
||||||
**date2** Second Date.
|
**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.
|
represented as a string.
|
||||||
|
|
||||||
**method** A boolean flag (TRUE or FALSE)
|
**method** A boolean flag (TRUE or FALSE)
|
||||||
|
@ -1453,7 +1453,7 @@ Excel `TRUE()` and `FALSE()` functions are used instead.
|
||||||
|
|
||||||
#### EDATE
|
#### 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
|
object representing the date that is the indicated number of months
|
||||||
before or after a specified date (the start\_date). Use EDATE to
|
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
|
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.
|
**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.
|
represented as a string.
|
||||||
|
|
||||||
**months** Number of months to add.
|
**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.
|
**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
|
or an Excel timestamp value (real), depending on the value of
|
||||||
\PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType().
|
\PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType().
|
||||||
|
|
||||||
|
@ -1526,7 +1526,7 @@ the Analysis ToolPak.
|
||||||
#### EOMONTH
|
#### EOMONTH
|
||||||
|
|
||||||
The EOMONTH function returns an Excel timestamp or a PHP timestamp or
|
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
|
the indicated number of months before or after a specified date (the
|
||||||
start\_date). Use EOMONTH to calculate maturity dates or due dates that
|
start\_date). Use EOMONTH to calculate maturity dates or due dates that
|
||||||
fall on the last day of the month.
|
fall on the last day of the month.
|
||||||
|
@ -1539,7 +1539,7 @@ fall on the last day of the month.
|
||||||
|
|
||||||
**baseDate** Start Date.
|
**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.
|
represented as a string.
|
||||||
|
|
||||||
**months** Number of months to add.
|
**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
|
**mixed** A date/time stamp that corresponds to the last day of basedate
|
||||||
+ months.
|
+ 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
|
or an Excel timestamp value (real), depending on the value of
|
||||||
\PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType().
|
\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.
|
**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.
|
date/time represented as a string.
|
||||||
|
|
||||||
##### Return Value
|
##### Return Value
|
||||||
|
@ -1665,7 +1665,7 @@ given as an integer, ranging from 0 to 59.
|
||||||
|
|
||||||
**datetime** Time.
|
**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.
|
date/time represented as a string.
|
||||||
|
|
||||||
##### Return Value
|
##### Return Value
|
||||||
|
@ -1723,7 +1723,7 @@ integer ranging from 1 to 12.
|
||||||
|
|
||||||
**datetime** 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.
|
represented as a string.
|
||||||
|
|
||||||
##### Return Value
|
##### Return Value
|
||||||
|
@ -1779,12 +1779,12 @@ a specific term.
|
||||||
|
|
||||||
**startDate** Start Date of the period.
|
**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.
|
represented as a string.
|
||||||
|
|
||||||
**endDate** End Date of the period.
|
**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.
|
represented as a string.
|
||||||
|
|
||||||
**holidays** Optional array of Holiday dates.
|
**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
|
**mixed** A date/time stamp that corresponds to the current date and
|
||||||
time.
|
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
|
or an Excel timestamp value (real), depending on the value of
|
||||||
\PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType().
|
\PhpOffice\PhpSpreadsheet\Calculation\Functions::getReturnDateType().
|
||||||
|
|
||||||
|
@ -1862,7 +1862,7 @@ given as an integer, ranging from 0 to 59.
|
||||||
|
|
||||||
**datetime** Time.
|
**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.
|
date/time represented as a string.
|
||||||
|
|
||||||
##### Return Value
|
##### Return Value
|
||||||
|
@ -1934,7 +1934,7 @@ modified to return a value between 0 and 6.
|
||||||
|
|
||||||
**datetime** 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.
|
represented as a string.
|
||||||
|
|
||||||
**method** An integer flag (values 0, 1 or 2)
|
**method** An integer flag (values 0, 1 or 2)
|
||||||
|
@ -2012,7 +2012,7 @@ The YEAR function returns the year of a date.
|
||||||
|
|
||||||
**datetime** 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.
|
represented as a string.
|
||||||
|
|
||||||
##### Return Value
|
##### Return Value
|
||||||
|
|
|
@ -13,6 +13,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
|
||||||
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||||
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
|
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
|
||||||
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
|
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Calculation\Token\Stack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2006 - 2016 PhpSpreadsheet.
|
* Copyright (c) 2006 - 2016 PhpSpreadsheet.
|
||||||
|
@ -2059,8 +2060,6 @@ class Calculation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unset an instance of this class.
|
* Unset an instance of this class.
|
||||||
*
|
|
||||||
* @param Spreadsheet $spreadsheet Injected spreadsheet identifying the instance to unset
|
|
||||||
*/
|
*/
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
|
@ -2314,6 +2313,14 @@ class Calculation
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $fromSeparator
|
||||||
|
* @param string $toSeparator
|
||||||
|
* @param string $formula
|
||||||
|
* @param bool $inBraces
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public static function translateSeparator($fromSeparator, $toSeparator, $formula, &$inBraces)
|
public static function translateSeparator($fromSeparator, $toSeparator, $formula, &$inBraces)
|
||||||
{
|
{
|
||||||
$strlen = mb_strlen($formula);
|
$strlen = mb_strlen($formula);
|
||||||
|
@ -2657,6 +2664,12 @@ class Calculation
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $cellReference
|
||||||
|
* @param mixed $cellValue
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function getValueFromCache($cellReference, &$cellValue)
|
public function getValueFromCache($cellReference, &$cellValue)
|
||||||
{
|
{
|
||||||
// Is calculation cacheing enabled?
|
// Is calculation cacheing enabled?
|
||||||
|
@ -2985,6 +2998,11 @@ class Calculation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $formula
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
private function convertMatrixReferences($formula)
|
private function convertMatrixReferences($formula)
|
||||||
{
|
{
|
||||||
static $matrixReplaceFrom = ['{', ';', '}'];
|
static $matrixReplaceFrom = ['{', ';', '}'];
|
||||||
|
@ -3073,6 +3091,13 @@ class Calculation
|
||||||
];
|
];
|
||||||
|
|
||||||
// Convert infix to postfix notation
|
// Convert infix to postfix notation
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $formula
|
||||||
|
* @param Cell|null $pCell
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
private function _parseFormula($formula, Cell $pCell = null)
|
private function _parseFormula($formula, Cell $pCell = null)
|
||||||
{
|
{
|
||||||
if (($formula = $this->convertMatrixReferences(trim($formula))) === false) {
|
if (($formula = $this->convertMatrixReferences(trim($formula))) === false) {
|
||||||
|
@ -3094,7 +3119,7 @@ class Calculation
|
||||||
|
|
||||||
// Start with initialisation
|
// Start with initialisation
|
||||||
$index = 0;
|
$index = 0;
|
||||||
$stack = new Calculation\Token\Stack();
|
$stack = new Stack();
|
||||||
$output = [];
|
$output = [];
|
||||||
$expectingOperator = false; // We use this test in syntax-checking the expression to determine when a
|
$expectingOperator = false; // We use this test in syntax-checking the expression to determine when a
|
||||||
// - is a negation or + is a positive operator rather than an operation
|
// - is a negation or + is a positive operator rather than an operation
|
||||||
|
@ -3401,8 +3426,11 @@ class Calculation
|
||||||
// evaluate postfix notation
|
// evaluate postfix notation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $cellID
|
|
||||||
* @param mixed $tokens
|
* @param mixed $tokens
|
||||||
|
* @param string|null $cellID
|
||||||
|
* @param Cell|null $pCell
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function processTokenStack($tokens, $cellID = null, Cell $pCell = null)
|
private function processTokenStack($tokens, $cellID = null, Cell $pCell = null)
|
||||||
{
|
{
|
||||||
|
@ -3414,7 +3442,7 @@ class Calculation
|
||||||
// so we store the parent cell collection so that we can re-attach it when necessary
|
// so we store the parent cell collection so that we can re-attach it when necessary
|
||||||
$pCellWorksheet = ($pCell !== null) ? $pCell->getWorksheet() : null;
|
$pCellWorksheet = ($pCell !== null) ? $pCell->getWorksheet() : null;
|
||||||
$pCellParent = ($pCell !== null) ? $pCell->getParent() : null;
|
$pCellParent = ($pCell !== null) ? $pCell->getParent() : null;
|
||||||
$stack = new Calculation\Token\Stack();
|
$stack = new Stack();
|
||||||
|
|
||||||
// Loop through each token in turn
|
// Loop through each token in turn
|
||||||
foreach ($tokens as $tokenData) {
|
foreach ($tokens as $tokenData) {
|
||||||
|
@ -3770,9 +3798,6 @@ class Calculation
|
||||||
$output = $stack->pop();
|
$output = $stack->pop();
|
||||||
$output = $output['value'];
|
$output = $output['value'];
|
||||||
|
|
||||||
// if ((is_array($output)) && (self::$returnArrayAsType != self::RETURN_ARRAY_AS_ARRAY)) {
|
|
||||||
// return array_shift(Calculation\Functions::flattenArray($output));
|
|
||||||
// }
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3814,7 +3839,17 @@ class Calculation
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function executeBinaryComparisonOperation($cellID, $operand1, $operand2, $operation, &$stack, $recursingArrays = false)
|
/**
|
||||||
|
* @param string|null $cellID
|
||||||
|
* @param mixed $operand1
|
||||||
|
* @param mixed $operand2
|
||||||
|
* @param string $operation
|
||||||
|
* @param Stack $stack
|
||||||
|
* @param bool $recursingArrays
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function executeBinaryComparisonOperation($cellID, $operand1, $operand2, $operation, Stack &$stack, $recursingArrays = false)
|
||||||
{
|
{
|
||||||
// If we're dealing with matrix operations, we want a matrix result
|
// If we're dealing with matrix operations, we want a matrix result
|
||||||
if ((is_array($operand1)) || (is_array($operand2))) {
|
if ((is_array($operand1)) || (is_array($operand2))) {
|
||||||
|
@ -3954,7 +3989,7 @@ class Calculation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $matrixFunction
|
* @param string $matrixFunction
|
||||||
* @param mixed $cellID
|
* @param string|null $cellID
|
||||||
* @param mixed $operand1
|
* @param mixed $operand1
|
||||||
* @param mixed $operand2
|
* @param mixed $operand2
|
||||||
* @param mixed $operation
|
* @param mixed $operation
|
||||||
|
|
|
@ -2293,7 +2293,7 @@ class Engineering
|
||||||
* Excel Function:
|
* Excel Function:
|
||||||
* IMSUM(complexNumber[,complexNumber[,...]])
|
* IMSUM(complexNumber[,complexNumber[,...]])
|
||||||
*
|
*
|
||||||
* @param string $complexNumbers Series of complex numbers to add
|
* @param string ...$complexNumbers Series of complex numbers to add
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -2333,7 +2333,7 @@ class Engineering
|
||||||
* Excel Function:
|
* Excel Function:
|
||||||
* IMPRODUCT(complexNumber[,complexNumber[,...]])
|
* IMPRODUCT(complexNumber[,complexNumber[,...]])
|
||||||
*
|
*
|
||||||
* @param string $complexNumbers Series of complex numbers to multiply
|
* @param string ...$complexNumbers Series of complex numbers to multiply
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -80,7 +80,7 @@ class Logical
|
||||||
*
|
*
|
||||||
* @category Logical Functions
|
* @category Logical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return string|bool the logical AND of the arguments
|
* @return string|bool the logical AND of the arguments
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -347,7 +347,7 @@ class MathTrig
|
||||||
*
|
*
|
||||||
* @category Mathematical and Trigonometric Functions
|
* @category Mathematical and Trigonometric Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return int Greatest Common Divisor
|
* @return int Greatest Common Divisor
|
||||||
*/
|
*/
|
||||||
|
@ -456,7 +456,7 @@ class MathTrig
|
||||||
*
|
*
|
||||||
* @category Mathematical and Trigonometric Functions
|
* @category Mathematical and Trigonometric Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return int Lowest Common Multiplier
|
* @return int Lowest Common Multiplier
|
||||||
*/
|
*/
|
||||||
|
@ -859,7 +859,7 @@ class MathTrig
|
||||||
*
|
*
|
||||||
* @category Mathematical and Trigonometric Functions
|
* @category Mathematical and Trigonometric Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -899,7 +899,7 @@ class MathTrig
|
||||||
*
|
*
|
||||||
* @category Mathematical and Trigonometric Functions
|
* @category Mathematical and Trigonometric Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -1185,7 +1185,7 @@ class MathTrig
|
||||||
*
|
*
|
||||||
* @category Mathematical and Trigonometric Functions
|
* @category Mathematical and Trigonometric Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -1306,7 +1306,7 @@ class MathTrig
|
||||||
*
|
*
|
||||||
* @category Mathematical and Trigonometric Functions
|
* @category Mathematical and Trigonometric Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -1351,7 +1351,7 @@ class MathTrig
|
||||||
*
|
*
|
||||||
* @category Mathematical and Trigonometric Functions
|
* @category Mathematical and Trigonometric Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -720,7 +720,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -771,7 +771,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -814,7 +814,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -1207,7 +1207,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
@ -1241,7 +1241,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
@ -1271,7 +1271,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
@ -1491,7 +1491,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -1785,7 +1785,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -1851,7 +1851,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -1967,7 +1967,7 @@ class Statistical
|
||||||
* kurtosis indicates a relatively peaked distribution. Negative kurtosis indicates a
|
* kurtosis indicates a relatively peaked distribution. Negative kurtosis indicates a
|
||||||
* relatively flat distribution.
|
* relatively flat distribution.
|
||||||
*
|
*
|
||||||
* @param array Data Series
|
* @param array ...$args Data Series
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -2249,7 +2249,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -2285,7 +2285,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -2368,7 +2368,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -2412,7 +2412,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -2448,7 +2448,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -2568,7 +2568,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -3016,7 +3016,7 @@ class Statistical
|
||||||
* asymmetric tail extending toward more positive values. Negative skewness indicates a
|
* asymmetric tail extending toward more positive values. Negative skewness indicates a
|
||||||
* distribution with an asymmetric tail extending toward more negative values.
|
* distribution with an asymmetric tail extending toward more negative values.
|
||||||
*
|
*
|
||||||
* @param array Data Series
|
* @param array ...$args Data Series
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -3161,7 +3161,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -3210,7 +3210,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -3262,7 +3262,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -3309,7 +3309,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -3599,7 +3599,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -3643,7 +3643,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -3696,7 +3696,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -3741,7 +3741,7 @@ class Statistical
|
||||||
*
|
*
|
||||||
* @category Statistical Functions
|
* @category Statistical Functions
|
||||||
*
|
*
|
||||||
* @param mixed $args Data values
|
* @param mixed ...$args Data values
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -351,7 +351,7 @@ class Gnumeric extends BaseReader implements IReader
|
||||||
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula
|
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula
|
||||||
// cells... during the load, all formulae should be correct, and we're simply bringing the worksheet
|
// cells... during the load, all formulae should be correct, and we're simply bringing the worksheet
|
||||||
// name in line with the formula, not the reverse
|
// name in line with the formula, not the reverse
|
||||||
$spreadsheet->getActiveSheet()->setTitle($worksheetName, false);
|
$spreadsheet->getActiveSheet()->setTitle($worksheetName, false, false);
|
||||||
|
|
||||||
if ((!$this->readDataOnly) && (isset($sheet->PrintInformation))) {
|
if ((!$this->readDataOnly) && (isset($sheet->PrintInformation))) {
|
||||||
if (isset($sheet->PrintInformation->Margins)) {
|
if (isset($sheet->PrintInformation->Margins)) {
|
||||||
|
|
|
@ -317,7 +317,7 @@ class Html extends BaseReader implements IReader
|
||||||
break;
|
break;
|
||||||
case 'title':
|
case 'title':
|
||||||
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
$sheet->setTitle($cellContent);
|
$sheet->setTitle($cellContent, true, false);
|
||||||
$cellContent = '';
|
$cellContent = '';
|
||||||
break;
|
break;
|
||||||
case 'span':
|
case 'span':
|
||||||
|
|
|
@ -440,7 +440,7 @@ class Ods extends BaseReader implements IReader
|
||||||
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in
|
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in
|
||||||
// formula cells... during the load, all formulae should be correct, and we're simply
|
// formula cells... during the load, all formulae should be correct, and we're simply
|
||||||
// bringing the worksheet name in line with the formula, not the reverse
|
// bringing the worksheet name in line with the formula, not the reverse
|
||||||
$spreadsheet->getActiveSheet()->setTitle($worksheetName, false);
|
$spreadsheet->getActiveSheet()->setTitle($worksheetName, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go through every child of table element
|
// Go through every child of table element
|
||||||
|
|
|
@ -808,7 +808,7 @@ class Xls extends BaseReader implements IReader
|
||||||
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula
|
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula
|
||||||
// cells... during the load, all formulae should be correct, and we're simply bringing the worksheet
|
// cells... during the load, all formulae should be correct, and we're simply bringing the worksheet
|
||||||
// name in line with the formula, not the reverse
|
// name in line with the formula, not the reverse
|
||||||
$this->phpSheet->setTitle($sheet['name'], false);
|
$this->phpSheet->setTitle($sheet['name'], false, false);
|
||||||
$this->phpSheet->setSheetState($sheet['sheetState']);
|
$this->phpSheet->setSheetState($sheet['sheetState']);
|
||||||
|
|
||||||
$this->pos = $sheet['offset'];
|
$this->pos = $sheet['offset'];
|
||||||
|
|
|
@ -697,7 +697,7 @@ class Xlsx extends BaseReader implements IReader
|
||||||
// references in formula cells... during the load, all formulae should be correct,
|
// references in formula cells... during the load, all formulae should be correct,
|
||||||
// and we're simply bringing the worksheet name in line with the formula, not the
|
// and we're simply bringing the worksheet name in line with the formula, not the
|
||||||
// reverse
|
// reverse
|
||||||
$docSheet->setTitle((string) $eleSheet['name'], false);
|
$docSheet->setTitle((string) $eleSheet['name'], false, false);
|
||||||
$fileWorksheet = $worksheets[(string) self::getArrayItem($eleSheet->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'id')];
|
$fileWorksheet = $worksheets[(string) self::getArrayItem($eleSheet->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'id')];
|
||||||
$xmlSheet = simplexml_load_string(
|
$xmlSheet = simplexml_load_string(
|
||||||
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
||||||
|
@ -766,7 +766,7 @@ class Xlsx extends BaseReader implements IReader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr['codeName'])) {
|
if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr['codeName'])) {
|
||||||
$docSheet->setCodeName((string) $xmlSheet->sheetPr['codeName']);
|
$docSheet->setCodeName((string) $xmlSheet->sheetPr['codeName'], false);
|
||||||
}
|
}
|
||||||
if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) {
|
if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) {
|
||||||
if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) &&
|
if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) &&
|
||||||
|
|
|
@ -552,7 +552,7 @@ class Xml extends BaseReader implements IReader
|
||||||
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in
|
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in
|
||||||
// formula cells... during the load, all formulae should be correct, and we're simply bringing
|
// formula cells... during the load, all formulae should be correct, and we're simply bringing
|
||||||
// the worksheet name in line with the formula, not the reverse
|
// the worksheet name in line with the formula, not the reverse
|
||||||
$spreadsheet->getActiveSheet()->setTitle($worksheetName, false);
|
$spreadsheet->getActiveSheet()->setTitle($worksheetName, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
$columnID = 'A';
|
$columnID = 'A';
|
||||||
|
|
|
@ -778,7 +778,7 @@ class EigenvalueDecomposition
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// end hqr2
|
// end hqr2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor: Check for symmetry, then construct the eigenvalue decomposition.
|
* Constructor: Check for symmetry, then construct the eigenvalue decomposition.
|
||||||
|
|
|
@ -436,8 +436,6 @@ class SingularValueDecomposition
|
||||||
} // end while
|
} // end while
|
||||||
}
|
}
|
||||||
|
|
||||||
// end constructor
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the left singular vectors.
|
* Return the left singular vectors.
|
||||||
*
|
*
|
||||||
|
|
|
@ -825,52 +825,54 @@ class Worksheet implements IComparable
|
||||||
* Set title.
|
* Set title.
|
||||||
*
|
*
|
||||||
* @param string $pValue String containing the dimension of this worksheet
|
* @param string $pValue String containing the dimension of this worksheet
|
||||||
* @param string $updateFormulaCellReferences boolean Flag indicating whether cell references in formulae should
|
* @param bool $updateFormulaCellReferences Flag indicating whether cell references in formulae should
|
||||||
* be updated to reflect the new sheet name.
|
* be updated to reflect the new sheet name.
|
||||||
* This should be left as the default true, unless you are
|
* This should be left as the default true, unless you are
|
||||||
* certain that no formula cells on any worksheet contain
|
* certain that no formula cells on any worksheet contain
|
||||||
* references to this worksheet
|
* references to this worksheet
|
||||||
|
* @param bool $validate False to skip validation of new title. WARNING: This should only be set
|
||||||
|
* at parse time (by Readers), where titles can be assumed to be valid.
|
||||||
*
|
*
|
||||||
* @return Worksheet
|
* @return Worksheet
|
||||||
*/
|
*/
|
||||||
public function setTitle($pValue, $updateFormulaCellReferences = true)
|
public function setTitle($pValue, $updateFormulaCellReferences = true, $validate = true)
|
||||||
{
|
{
|
||||||
// Is this a 'rename' or not?
|
// Is this a 'rename' or not?
|
||||||
if ($this->getTitle() == $pValue) {
|
if ($this->getTitle() == $pValue) {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Syntax check
|
|
||||||
self::checkSheetTitle($pValue);
|
|
||||||
|
|
||||||
// Old title
|
// Old title
|
||||||
$oldTitle = $this->getTitle();
|
$oldTitle = $this->getTitle();
|
||||||
|
|
||||||
if ($this->parent) {
|
if ($validate) {
|
||||||
// Is there already such sheet name?
|
// Syntax check
|
||||||
if ($this->parent->sheetNameExists($pValue)) {
|
self::checkSheetTitle($pValue);
|
||||||
// Use name, but append with lowest possible integer
|
|
||||||
|
|
||||||
if (Shared\StringHelper::countCharacters($pValue) > 29) {
|
if ($this->parent) {
|
||||||
$pValue = Shared\StringHelper::substring($pValue, 0, 29);
|
// Is there already such sheet name?
|
||||||
}
|
if ($this->parent->sheetNameExists($pValue)) {
|
||||||
$i = 1;
|
// Use name, but append with lowest possible integer
|
||||||
while ($this->parent->sheetNameExists($pValue . ' ' . $i)) {
|
|
||||||
++$i;
|
if (Shared\StringHelper::countCharacters($pValue) > 29) {
|
||||||
if ($i == 10) {
|
$pValue = Shared\StringHelper::substring($pValue, 0, 29);
|
||||||
if (Shared\StringHelper::countCharacters($pValue) > 28) {
|
}
|
||||||
$pValue = Shared\StringHelper::substring($pValue, 0, 28);
|
$i = 1;
|
||||||
}
|
while ($this->parent->sheetNameExists($pValue . ' ' . $i)) {
|
||||||
} elseif ($i == 100) {
|
++$i;
|
||||||
if (Shared\StringHelper::countCharacters($pValue) > 27) {
|
if ($i == 10) {
|
||||||
$pValue = Shared\StringHelper::substring($pValue, 0, 27);
|
if (Shared\StringHelper::countCharacters($pValue) > 28) {
|
||||||
|
$pValue = Shared\StringHelper::substring($pValue, 0, 28);
|
||||||
|
}
|
||||||
|
} elseif ($i == 100) {
|
||||||
|
if (Shared\StringHelper::countCharacters($pValue) > 27) {
|
||||||
|
$pValue = Shared\StringHelper::substring($pValue, 0, 27);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pValue .= " $i";
|
||||||
}
|
}
|
||||||
|
|
||||||
$altTitle = $pValue . ' ' . $i;
|
|
||||||
|
|
||||||
return $this->setTitle($altTitle, $updateFormulaCellReferences);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1161,7 +1163,6 @@ class Worksheet implements IComparable
|
||||||
* @param int $pRow Numeric row coordinate of the cell
|
* @param int $pRow Numeric row coordinate of the cell
|
||||||
* @param mixed $pValue Value of the cell
|
* @param mixed $pValue Value of the cell
|
||||||
* @param string $pDataType Explicit data type, see Cell\DataType::TYPE_*
|
* @param string $pDataType Explicit data type, see Cell\DataType::TYPE_*
|
||||||
* @param bool $returnCell Return the worksheet (false, default) or the cell (true)
|
|
||||||
*
|
*
|
||||||
* @return Worksheet
|
* @return Worksheet
|
||||||
*/
|
*/
|
||||||
|
@ -2976,51 +2977,55 @@ class Worksheet implements IComparable
|
||||||
/**
|
/**
|
||||||
* Define the code name of the sheet.
|
* Define the code name of the sheet.
|
||||||
*
|
*
|
||||||
* @param null|string Same rule as Title minus space not allowed (but, like Excel, change silently space to underscore)
|
* @param string $pValue Same rule as Title minus space not allowed (but, like Excel, change
|
||||||
* @param null|mixed $pValue
|
* silently space to underscore)
|
||||||
|
* @param bool $validate False to skip validation of new title. WARNING: This should only be set
|
||||||
|
* at parse time (by Readers), where titles can be assumed to be valid.
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*
|
*
|
||||||
* @return objWorksheet
|
* @return objWorksheet
|
||||||
*/
|
*/
|
||||||
public function setCodeName($pValue)
|
public function setCodeName($pValue, $validate = true)
|
||||||
{
|
{
|
||||||
// Is this a 'rename' or not?
|
// Is this a 'rename' or not?
|
||||||
if ($this->getCodeName() == $pValue) {
|
if ($this->getCodeName() == $pValue) {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
$pValue = str_replace(' ', '_', $pValue); //Excel does this automatically without flinching, we are doing the same
|
|
||||||
// Syntax check
|
|
||||||
// throw an exception if not valid
|
|
||||||
self::checkSheetCodeName($pValue);
|
|
||||||
|
|
||||||
// We use the same code that setTitle to find a valid codeName else not using a space (Excel don't like) but a '_'
|
if ($validate) {
|
||||||
|
$pValue = str_replace(' ', '_', $pValue); //Excel does this automatically without flinching, we are doing the same
|
||||||
|
|
||||||
if ($this->getParent()) {
|
// Syntax check
|
||||||
// Is there already such sheet name?
|
// throw an exception if not valid
|
||||||
if ($this->getParent()->sheetCodeNameExists($pValue)) {
|
self::checkSheetCodeName($pValue);
|
||||||
// Use name, but append with lowest possible integer
|
|
||||||
|
|
||||||
if (Shared\StringHelper::countCharacters($pValue) > 29) {
|
// We use the same code that setTitle to find a valid codeName else not using a space (Excel don't like) but a '_'
|
||||||
$pValue = Shared\StringHelper::substring($pValue, 0, 29);
|
|
||||||
}
|
if ($this->getParent()) {
|
||||||
$i = 1;
|
// Is there already such sheet name?
|
||||||
while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
|
if ($this->getParent()->sheetCodeNameExists($pValue)) {
|
||||||
++$i;
|
// Use name, but append with lowest possible integer
|
||||||
if ($i == 10) {
|
|
||||||
if (Shared\StringHelper::countCharacters($pValue) > 28) {
|
if (Shared\StringHelper::countCharacters($pValue) > 29) {
|
||||||
$pValue = Shared\StringHelper::substring($pValue, 0, 28);
|
$pValue = Shared\StringHelper::substring($pValue, 0, 29);
|
||||||
}
|
}
|
||||||
} elseif ($i == 100) {
|
$i = 1;
|
||||||
if (Shared\StringHelper::countCharacters($pValue) > 27) {
|
while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
|
||||||
$pValue = Shared\StringHelper::substring($pValue, 0, 27);
|
++$i;
|
||||||
|
if ($i == 10) {
|
||||||
|
if (Shared\StringHelper::countCharacters($pValue) > 28) {
|
||||||
|
$pValue = Shared\StringHelper::substring($pValue, 0, 28);
|
||||||
|
}
|
||||||
|
} elseif ($i == 100) {
|
||||||
|
if (Shared\StringHelper::countCharacters($pValue) > 27) {
|
||||||
|
$pValue = Shared\StringHelper::substring($pValue, 0, 27);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$pValue = $pValue . '_' . $i; // ok, we have a valid name
|
$pValue = $pValue . '_' . $i; // ok, we have a valid name
|
||||||
//codeName is'nt used in formula : no need to call for an update
|
}
|
||||||
//return $this->setTitle($altTitle, $updateFormulaCellReferences);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -629,6 +629,7 @@ class AutoFilter
|
||||||
$rules = $filterColumn->getRules();
|
$rules = $filterColumn->getRules();
|
||||||
switch ($filterColumn->getFilterType()) {
|
switch ($filterColumn->getFilterType()) {
|
||||||
case AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER:
|
case AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER:
|
||||||
|
$ruleType = null;
|
||||||
$ruleValues = [];
|
$ruleValues = [];
|
||||||
// Build a list of the filter value selections
|
// Build a list of the filter value selections
|
||||||
foreach ($rules as $rule) {
|
foreach ($rules as $rule) {
|
||||||
|
@ -700,7 +701,6 @@ class AutoFilter
|
||||||
$ruleValues = [];
|
$ruleValues = [];
|
||||||
// Build a list of the filter value selections
|
// Build a list of the filter value selections
|
||||||
foreach ($rules as $rule) {
|
foreach ($rules as $rule) {
|
||||||
$ruleType = $rule->getRuleType();
|
|
||||||
$ruleValue = $rule->getValue();
|
$ruleValue = $rule->getValue();
|
||||||
if (!is_numeric($ruleValue)) {
|
if (!is_numeric($ruleValue)) {
|
||||||
// Convert to a regexp allowing for regexp reserved characters, wildcards and escaped wildcards
|
// Convert to a regexp allowing for regexp reserved characters, wildcards and escaped wildcards
|
||||||
|
|
|
@ -84,9 +84,9 @@ class Font
|
||||||
$bFamily = 0; // Font family
|
$bFamily = 0; // Font family
|
||||||
$bCharSet = \PhpOffice\PhpSpreadsheet\Shared\Font::getCharsetFromFontName($this->font->getName()); // Character set
|
$bCharSet = \PhpOffice\PhpSpreadsheet\Shared\Font::getCharsetFromFontName($this->font->getName()); // Character set
|
||||||
|
|
||||||
$record = 0x31; // Record identifier
|
$record = 0x31; // Record identifier
|
||||||
$reserved = 0x00; // Reserved
|
$reserved = 0x00; // Reserved
|
||||||
$grbit = 0x00; // Font attributes
|
$grbit = 0x00; // Font attributes
|
||||||
if ($this->font->getItalic()) {
|
if ($this->font->getItalic()) {
|
||||||
$grbit |= 0x02;
|
$grbit |= 0x02;
|
||||||
}
|
}
|
||||||
|
@ -134,10 +134,10 @@ class Font
|
||||||
private static function mapBold($bold)
|
private static function mapBold($bold)
|
||||||
{
|
{
|
||||||
if ($bold) {
|
if ($bold) {
|
||||||
return 0x2BC; // 700 = Bold font weight
|
return 0x2BC; // 700 = Bold font weight
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0x190; // 400 = Normal font weight
|
return 0x190; // 400 = Normal font weight
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1190,14 +1190,14 @@ class Worksheet extends BIFFwriter
|
||||||
|
|
||||||
// Pack the main data stream
|
// Pack the main data stream
|
||||||
$data = pack('vvvv', $row1, $row2, $col1, $col2) .
|
$data = pack('vvvv', $row1, $row2, $col1, $col2) .
|
||||||
$unknown1 .
|
$unknown1 .
|
||||||
$link_type .
|
$link_type .
|
||||||
$unknown2 .
|
$unknown2 .
|
||||||
$up_count .
|
$up_count .
|
||||||
$dir_short_len .
|
$dir_short_len .
|
||||||
$dir_short .
|
$dir_short .
|
||||||
$unknown3 .
|
$unknown3 .
|
||||||
$stream_len; /*.
|
$stream_len; /*.
|
||||||
$dir_long_len .
|
$dir_long_len .
|
||||||
$unknown4 .
|
$unknown4 .
|
||||||
$dir_long .
|
$dir_long .
|
||||||
|
|
|
@ -159,8 +159,8 @@ class Xlsx extends BaseWriter implements IWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
$hashTablesArray = ['stylesConditionalHashTable', 'fillHashTable', 'fontHashTable',
|
$hashTablesArray = ['stylesConditionalHashTable', 'fillHashTable', 'fontHashTable',
|
||||||
'bordersHashTable', 'numFmtHashTable', 'drawingHashTable',
|
'bordersHashTable', 'numFmtHashTable', 'drawingHashTable',
|
||||||
'styleHashTable',
|
'styleHashTable',
|
||||||
];
|
];
|
||||||
|
|
||||||
// Set HashTable variables
|
// Set HashTable variables
|
||||||
|
|
|
@ -306,7 +306,6 @@ class Worksheet extends WriterPart
|
||||||
}
|
}
|
||||||
|
|
||||||
// Selection
|
// Selection
|
||||||
// if ($pane != '') {
|
|
||||||
// Only need to write selection element if we have a split pane
|
// Only need to write selection element if we have a split pane
|
||||||
// We cheat a little by over-riding the active cell selection, setting it to the split cell
|
// We cheat a little by over-riding the active cell selection, setting it to the split cell
|
||||||
$objWriter->startElement('selection');
|
$objWriter->startElement('selection');
|
||||||
|
@ -316,7 +315,6 @@ class Worksheet extends WriterPart
|
||||||
$objWriter->writeAttribute('activeCell', $activeCell);
|
$objWriter->writeAttribute('activeCell', $activeCell);
|
||||||
$objWriter->writeAttribute('sqref', $activeCell);
|
$objWriter->writeAttribute('sqref', $activeCell);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
// }
|
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,7 @@ class HTMLTest extends PHPUnit_Framework_TestCase
|
||||||
public function testCsvWithAngleBracket()
|
public function testCsvWithAngleBracket()
|
||||||
{
|
{
|
||||||
$filename = __DIR__ . '/../../data/Reader/HTML/csv_with_angle_bracket.csv';
|
$filename = __DIR__ . '/../../data/Reader/HTML/csv_with_angle_bracket.csv';
|
||||||
$this->assertFalse($this->getInstance()->canRead($filename));
|
$reader = new Html();
|
||||||
}
|
$this->assertFalse($reader->canRead($filename));
|
||||||
|
|
||||||
private function getInstance()
|
|
||||||
{
|
|
||||||
return new HTML();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,126 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpSpreadsheetTests;
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet;
|
||||||
|
use PHPUnit_Framework_TestCase;
|
||||||
|
|
||||||
|
class WorksheetTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function testSetTitle()
|
||||||
|
{
|
||||||
|
$testTitle = str_repeat('a', 31);
|
||||||
|
|
||||||
|
$worksheet = new Worksheet();
|
||||||
|
$worksheet->setTitle($testTitle);
|
||||||
|
$this->assertSame($testTitle, $worksheet->getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTitleInvalidProvider()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[str_repeat('a', 32), 'Maximum 31 characters allowed in sheet title.'],
|
||||||
|
['invalid*title', 'Invalid character found in sheet title'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $title
|
||||||
|
* @param string $expectMessage
|
||||||
|
* @dataProvider setTitleInvalidProvider
|
||||||
|
*/
|
||||||
|
public function testSetTitleInvalid($title, $expectMessage)
|
||||||
|
{
|
||||||
|
// First, test setting title with validation disabled -- should be successful
|
||||||
|
$worksheet = new Worksheet();
|
||||||
|
$worksheet->setTitle($title, true, false);
|
||||||
|
|
||||||
|
// Next, test again with validation enabled -- this time we should fail
|
||||||
|
$worksheet = new Worksheet();
|
||||||
|
$this->expectException(\Exception::class);
|
||||||
|
$this->expectExceptionMessage($expectMessage);
|
||||||
|
$worksheet->setTitle($title);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetTitleDuplicate()
|
||||||
|
{
|
||||||
|
// Create a Spreadsheet with three Worksheets (the first is created automatically)
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$spreadsheet->createSheet();
|
||||||
|
$spreadsheet->createSheet();
|
||||||
|
|
||||||
|
// Set unique title -- should be unchanged
|
||||||
|
$sheet = $spreadsheet->getSheet(0);
|
||||||
|
$sheet->setTitle('Test Title');
|
||||||
|
$this->assertSame('Test Title', $sheet->getTitle());
|
||||||
|
|
||||||
|
// Set duplicate title -- should have numeric suffix appended
|
||||||
|
$sheet = $spreadsheet->getSheet(1);
|
||||||
|
$sheet->setTitle('Test Title');
|
||||||
|
$this->assertSame('Test Title 1', $sheet->getTitle());
|
||||||
|
|
||||||
|
// Set duplicate title with validation disabled -- should be unchanged
|
||||||
|
$sheet = $spreadsheet->getSheet(2);
|
||||||
|
$sheet->setTitle('Test Title', true, false);
|
||||||
|
$this->assertSame('Test Title', $sheet->getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetCodeName()
|
||||||
|
{
|
||||||
|
$testCodeName = str_repeat('a', 31);
|
||||||
|
|
||||||
|
$worksheet = new Worksheet();
|
||||||
|
$worksheet->setCodeName($testCodeName);
|
||||||
|
$this->assertSame($testCodeName, $worksheet->getCodeName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCodeNameInvalidProvider()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[str_repeat('a', 32), 'Maximum 31 characters allowed in sheet code name.'],
|
||||||
|
['invalid*code*name', 'Invalid character found in sheet code name'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $codeName
|
||||||
|
* @param string $expectMessage
|
||||||
|
* @dataProvider setCodeNameInvalidProvider
|
||||||
|
*/
|
||||||
|
public function testSetCodeNameInvalid($codeName, $expectMessage)
|
||||||
|
{
|
||||||
|
// First, test setting code name with validation disabled -- should be successful
|
||||||
|
$worksheet = new Worksheet();
|
||||||
|
$worksheet->setCodeName($codeName, false);
|
||||||
|
|
||||||
|
// Next, test again with validation enabled -- this time we should fail
|
||||||
|
$worksheet = new Worksheet();
|
||||||
|
$this->expectException(\Exception::class);
|
||||||
|
$this->expectExceptionMessage($expectMessage);
|
||||||
|
$worksheet->setCodeName($codeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetCodeNameDuplicate()
|
||||||
|
{
|
||||||
|
// Create a Spreadsheet with three Worksheets (the first is created automatically)
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$spreadsheet->createSheet();
|
||||||
|
$spreadsheet->createSheet();
|
||||||
|
|
||||||
|
// Set unique code name -- should be massaged to Snake_Case
|
||||||
|
$sheet = $spreadsheet->getSheet(0);
|
||||||
|
$sheet->setCodeName('Test Code Name');
|
||||||
|
$this->assertSame('Test_Code_Name', $sheet->getCodeName());
|
||||||
|
|
||||||
|
// Set duplicate code name -- should be massaged and have numeric suffix appended
|
||||||
|
$sheet = $spreadsheet->getSheet(1);
|
||||||
|
$sheet->setCodeName('Test Code Name');
|
||||||
|
$this->assertSame('Test_Code_Name_1', $sheet->getCodeName());
|
||||||
|
|
||||||
|
// Set duplicate code name with validation disabled -- should be unchanged, and unmassaged
|
||||||
|
$sheet = $spreadsheet->getSheet(2);
|
||||||
|
$sheet->setCodeName('Test Code Name', false);
|
||||||
|
$this->assertSame('Test Code Name', $sheet->getCodeName());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue