first commit
This commit is contained in:
42
PHPExcel/Documentation/Examples/Reader/exampleReader01.php
Executable file
42
PHPExcel/Documentation/Examples/Reader/exampleReader01.php
Executable file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #01</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #01</h1>
|
||||
<h2>Simple File Reader using PHPExcel_IOFactory::load()</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory to identify the format<br />';
|
||||
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
|
||||
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
|
||||
var_dump($sheetData);
|
||||
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
50
PHPExcel/Documentation/Examples/Reader/exampleReader02.php
Executable file
50
PHPExcel/Documentation/Examples/Reader/exampleReader02.php
Executable file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #02</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #02</h1>
|
||||
<h2>Simple File Reader using a Specified Reader</h2>
|
||||
<?php
|
||||
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using PHPExcel_Reader_Excel5<br />';
|
||||
$objReader = new PHPExcel_Reader_Excel5();
|
||||
// $objReader = new PHPExcel_Reader_Excel2007();
|
||||
// $objReader = new PHPExcel_Reader_Excel2003XML();
|
||||
// $objReader = new PHPExcel_Reader_OOCalc();
|
||||
// $objReader = new PHPExcel_Reader_SYLK();
|
||||
// $objReader = new PHPExcel_Reader_Gnumeric();
|
||||
// $objReader = new PHPExcel_Reader_CSV();
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
|
||||
var_dump($sheetData);
|
||||
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
51
PHPExcel/Documentation/Examples/Reader/exampleReader03.php
Executable file
51
PHPExcel/Documentation/Examples/Reader/exampleReader03.php
Executable file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #03</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #03</h1>
|
||||
<h2>Simple File Reader using the PHPExcel_IOFactory to Return a Reader</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileType = 'Excel5';
|
||||
// $inputFileType = 'Excel2007';
|
||||
// $inputFileType = 'Excel2003XML';
|
||||
// $inputFileType = 'OOCalc';
|
||||
// $inputFileType = 'SYLK';
|
||||
// $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 />';
|
||||
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
|
||||
var_dump($sheetData);
|
||||
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
47
PHPExcel/Documentation/Examples/Reader/exampleReader04.php
Executable file
47
PHPExcel/Documentation/Examples/Reader/exampleReader04.php
Executable file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #04</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #04</h1>
|
||||
<h2>Simple File Reader using the PHPExcel_IOFactory to Identify a Reader to Use</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
|
||||
echo 'File ',pathinfo($inputFileName,PATHINFO_BASENAME),' has been identified as an ',$inputFileType,' file<br />';
|
||||
|
||||
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with the identified reader type<br />';
|
||||
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
|
||||
var_dump($sheetData);
|
||||
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
51
PHPExcel/Documentation/Examples/Reader/exampleReader05.php
Executable file
51
PHPExcel/Documentation/Examples/Reader/exampleReader05.php
Executable file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #05</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #05</h1>
|
||||
<h2>Simple File Reader using the "Read Data Only" Option</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileType = 'Excel5';
|
||||
// $inputFileType = 'Excel2007';
|
||||
// $inputFileType = 'Excel2003XML';
|
||||
// $inputFileType = 'OOCalc';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
||||
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||
echo 'Turning Formatting off for Load<br />';
|
||||
$objReader->setReadDataOnly(true);
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
|
||||
var_dump($sheetData);
|
||||
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
54
PHPExcel/Documentation/Examples/Reader/exampleReader06.php
Executable file
54
PHPExcel/Documentation/Examples/Reader/exampleReader06.php
Executable file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #06</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #06</h1>
|
||||
<h2>Simple File Reader Loading All WorkSheets</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileType = 'Excel5';
|
||||
// $inputFileType = 'Excel2007';
|
||||
// $inputFileType = 'Excel2003XML';
|
||||
// $inputFileType = 'OOCalc';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
||||
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||
echo 'Loading all WorkSheets<br />';
|
||||
$objReader->setLoadAllSheets();
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />';
|
||||
$loadedSheetNames = $objPHPExcel->getSheetNames();
|
||||
foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||
echo $sheetIndex,' -> ',$loadedSheetName,'<br />';
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
55
PHPExcel/Documentation/Examples/Reader/exampleReader07.php
Executable file
55
PHPExcel/Documentation/Examples/Reader/exampleReader07.php
Executable file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #07</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #07</h1>
|
||||
<h2>Simple File Reader Loading a Single Named WorkSheet</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileType = 'Excel5';
|
||||
// $inputFileType = 'Excel2007';
|
||||
// $inputFileType = 'Excel2003XML';
|
||||
// $inputFileType = 'OOCalc';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
$sheetname = 'Data Sheet #2';
|
||||
|
||||
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
||||
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||
echo 'Loading Sheet "',$sheetname,'" only<br />';
|
||||
$objReader->setLoadSheetsOnly($sheetname);
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />';
|
||||
$loadedSheetNames = $objPHPExcel->getSheetNames();
|
||||
foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||
echo $sheetIndex,' -> ',$loadedSheetName,'<br />';
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
55
PHPExcel/Documentation/Examples/Reader/exampleReader08.php
Executable file
55
PHPExcel/Documentation/Examples/Reader/exampleReader08.php
Executable file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #08</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #08</h1>
|
||||
<h2>Simple File Reader Loading Several Named WorkSheets</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileType = 'Excel5';
|
||||
// $inputFileType = 'Excel2007';
|
||||
// $inputFileType = 'Excel2003XML';
|
||||
// $inputFileType = 'OOCalc';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
$sheetnames = array('Data Sheet #1','Data Sheet #3');
|
||||
|
||||
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
||||
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||
echo 'Loading Sheet',((count($sheetnames) == 1) ? '' : 's'),' "',implode('" and "',$sheetnames),'" only<br />';
|
||||
$objReader->setLoadSheetsOnly($sheetnames);
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />';
|
||||
$loadedSheetNames = $objPHPExcel->getSheetNames();
|
||||
foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||
echo $sheetIndex,' -> ',$loadedSheetName,'<br />';
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
71
PHPExcel/Documentation/Examples/Reader/exampleReader09.php
Executable file
71
PHPExcel/Documentation/Examples/Reader/exampleReader09.php
Executable file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #09</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #09</h1>
|
||||
<h2>Simple File Reader Using a Read Filter</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileType = 'Excel5';
|
||||
// $inputFileType = 'Excel2007';
|
||||
// $inputFileType = 'Excel2003XML';
|
||||
// $inputFileType = 'OOCalc';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
$sheetname = 'Data Sheet #3';
|
||||
|
||||
|
||||
class MyReadFilter implements PHPExcel_Reader_IReadFilter
|
||||
{
|
||||
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();
|
||||
|
||||
|
||||
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
||||
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||
echo 'Loading Sheet "',$sheetname,'" only<br />';
|
||||
$objReader->setLoadSheetsOnly($sheetname);
|
||||
echo 'Loading Sheet using filter<br />';
|
||||
$objReader->setReadFilter($filterSubset);
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
|
||||
var_dump($sheetData);
|
||||
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
82
PHPExcel/Documentation/Examples/Reader/exampleReader10.php
Executable file
82
PHPExcel/Documentation/Examples/Reader/exampleReader10.php
Executable file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #10</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #10</h1>
|
||||
<h2>Simple File Reader Using a Configurable Read Filter</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileType = 'Excel5';
|
||||
// $inputFileType = 'Excel2007';
|
||||
// $inputFileType = 'Excel2003XML';
|
||||
// $inputFileType = 'OOCalc';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
$sheetname = 'Data Sheet #3';
|
||||
|
||||
|
||||
class MyReadFilter implements PHPExcel_Reader_IReadFilter
|
||||
{
|
||||
private $_startRow = 0;
|
||||
|
||||
private $_endRow = 0;
|
||||
|
||||
private $_columns = array();
|
||||
|
||||
public function __construct($startRow, $endRow, $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;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$filterSubset = new MyReadFilter(9,15,range('G','K'));
|
||||
|
||||
|
||||
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
||||
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||
echo 'Loading Sheet "',$sheetname,'" only<br />';
|
||||
$objReader->setLoadSheetsOnly($sheetname);
|
||||
echo 'Loading Sheet using configurable filter<br />';
|
||||
$objReader->setReadFilter($filterSubset);
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
|
||||
var_dump($sheetData);
|
||||
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
91
PHPExcel/Documentation/Examples/Reader/exampleReader11.php
Executable file
91
PHPExcel/Documentation/Examples/Reader/exampleReader11.php
Executable file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #11</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #11</h1>
|
||||
<h2>Reading a Workbook in "Chunks" Using a Configurable Read Filter (Version 1)</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileType = 'Excel5';
|
||||
// $inputFileType = 'Excel2007';
|
||||
// $inputFileType = 'Excel2003XML';
|
||||
// $inputFileType = 'OOCalc';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example2.xls';
|
||||
|
||||
|
||||
/** Define a Read Filter class implementing PHPExcel_Reader_IReadFilter */
|
||||
class chunkReadFilter implements PHPExcel_Reader_IReadFilter
|
||||
{
|
||||
private $_startRow = 0;
|
||||
|
||||
private $_endRow = 0;
|
||||
|
||||
/** We expect a list of the rows that we want to read to be passed into the constructor */
|
||||
public function __construct($startRow, $chunkSize) {
|
||||
$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 **/
|
||||
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
|
||||
/** Define how many rows we want for each "chunk" **/
|
||||
$chunkSize = 20;
|
||||
|
||||
/** Loop to read our worksheet in "chunk size" blocks **/
|
||||
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 **/
|
||||
$objReader->setReadFilter($chunkFilter);
|
||||
/** Load only the rows that match our filter from $inputFileName to a PHPExcel Object **/
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
// Do some processing here
|
||||
|
||||
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
|
||||
var_dump($sheetData);
|
||||
echo '<br /><br />';
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
94
PHPExcel/Documentation/Examples/Reader/exampleReader12.php
Executable file
94
PHPExcel/Documentation/Examples/Reader/exampleReader12.php
Executable file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #12</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #12</h1>
|
||||
<h2>Reading a Workbook in "Chunks" Using a Configurable Read Filter (Version 2)</h2>
|
||||
<?php
|
||||
|
||||
/** Set Include path to point at the PHPExcel Classes folder **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** Include PHPExcel_IOFactory **/
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileType = 'Excel5';
|
||||
// $inputFileType = 'Excel2007';
|
||||
// $inputFileType = 'Excel2003XML';
|
||||
// $inputFileType = 'OOCalc';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example2.xls';
|
||||
|
||||
|
||||
/** Define a Read Filter class implementing PHPExcel_Reader_IReadFilter */
|
||||
class chunkReadFilter implements PHPExcel_Reader_IReadFilter
|
||||
{
|
||||
private $_startRow = 0;
|
||||
|
||||
private $_endRow = 0;
|
||||
|
||||
/** Set the list of rows that we want to read */
|
||||
public function setRows($startRow, $chunkSize) {
|
||||
$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 **/
|
||||
$objReader = PHPExcel_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();
|
||||
|
||||
/** Tell the Reader that we want to use the Read Filter that we've Instantiated **/
|
||||
$objReader->setReadFilter($chunkFilter);
|
||||
|
||||
/** Loop to read our worksheet in "chunk size" blocks **/
|
||||
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 PHPExcel Object **/
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
|
||||
// Do some processing here
|
||||
|
||||
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
|
||||
var_dump($sheetData);
|
||||
echo '<br /><br />';
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
60
PHPExcel/Documentation/Examples/Reader/exampleReader13.php
Executable file
60
PHPExcel/Documentation/Examples/Reader/exampleReader13.php
Executable file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #13</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #13</h1>
|
||||
<h2>Simple File Reader for Multiple CSV Files</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileType = 'CSV';
|
||||
$inputFileNames = array('./sampleData/example1.csv','./sampleData/example2.csv');
|
||||
|
||||
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||
$inputFileName = array_shift($inputFileNames);
|
||||
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' into WorkSheet #1 using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
$objPHPExcel->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 />';
|
||||
$objReader->setSheetIndex($sheet+1);
|
||||
$objReader->loadIntoExisting($inputFileName,$objPHPExcel);
|
||||
$objPHPExcel->getActiveSheet()->setTitle(pathinfo($inputFileName,PATHINFO_BASENAME));
|
||||
}
|
||||
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />';
|
||||
$loadedSheetNames = $objPHPExcel->getSheetNames();
|
||||
foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||
echo '<b>Worksheet #',$sheetIndex,' -> ',$loadedSheetName,'</b><br />';
|
||||
$objPHPExcel->setActiveSheetIndexByName($loadedSheetName);
|
||||
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
|
||||
var_dump($sheetData);
|
||||
echo '<br /><br />';
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
105
PHPExcel/Documentation/Examples/Reader/exampleReader14.php
Executable file
105
PHPExcel/Documentation/Examples/Reader/exampleReader14.php
Executable file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #15</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #14</h1>
|
||||
<h2>Reading a Large CSV file in "Chunks" to split across multiple Worksheets</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileType = 'CSV';
|
||||
$inputFileName = './sampleData/example2.csv';
|
||||
|
||||
/** Define a Read Filter class implementing PHPExcel_Reader_IReadFilter */
|
||||
class chunkReadFilter implements PHPExcel_Reader_IReadFilter
|
||||
{
|
||||
private $_startRow = 0;
|
||||
|
||||
private $_endRow = 0;
|
||||
|
||||
/** Set the list of rows that we want to read */
|
||||
public function setRows($startRow, $chunkSize) {
|
||||
$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 **/
|
||||
$objReader = PHPExcel_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();
|
||||
|
||||
/** Tell the Reader that we want to use the Read Filter that we've Instantiated **/
|
||||
/** and that we want to store it in contiguous rows/columns **/
|
||||
$objReader->setReadFilter($chunkFilter)
|
||||
->setContiguous(true);
|
||||
|
||||
|
||||
/** Instantiate a new PHPExcel object manually **/
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
/** Set a sheet index **/
|
||||
$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);
|
||||
|
||||
/** Increment the worksheet index pointer for the Reader **/
|
||||
$objReader->setSheetIndex($sheet);
|
||||
/** Load only the rows that match our filter into a new worksheet in the PHPExcel Object **/
|
||||
$objReader->loadIntoExisting($inputFileName,$objPHPExcel);
|
||||
/** Set the worksheet title (to reference the "sheet" of data that we've loaded) **/
|
||||
/** and increment the sheet index as well **/
|
||||
$objPHPExcel->getActiveSheet()->setTitle('Country Data #'.(++$sheet));
|
||||
}
|
||||
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />';
|
||||
$loadedSheetNames = $objPHPExcel->getSheetNames();
|
||||
foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||
echo '<b>Worksheet #',$sheetIndex,' -> ',$loadedSheetName,'</b><br />';
|
||||
$objPHPExcel->setActiveSheetIndexByName($loadedSheetName);
|
||||
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,false,false,true);
|
||||
var_dump($sheetData);
|
||||
echo '<br />';
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
71
PHPExcel/Documentation/Examples/Reader/exampleReader15.php
Executable file
71
PHPExcel/Documentation/Examples/Reader/exampleReader15.php
Executable file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #15</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #15</h1>
|
||||
<h2>Simple File Reader for Tab-Separated Value File using the Advanced Value Binder</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
PHPExcel_Cell::setValueBinder( new PHPExcel_Cell_AdvancedValueBinder() );
|
||||
|
||||
|
||||
$inputFileType = 'CSV';
|
||||
$inputFileName = './sampleData/example1.tsv';
|
||||
|
||||
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' into WorkSheet #1 using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
||||
$objReader->setDelimiter("\t");
|
||||
$objPHPExcel = $objReader->load($inputFileName);
|
||||
$objPHPExcel->getActiveSheet()->setTitle(pathinfo($inputFileName,PATHINFO_BASENAME));
|
||||
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />';
|
||||
$loadedSheetNames = $objPHPExcel->getSheetNames();
|
||||
foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) {
|
||||
echo '<b>Worksheet #',$sheetIndex,' -> ',$loadedSheetName,' (Formatted)</b><br />';
|
||||
$objPHPExcel->setActiveSheetIndexByName($loadedSheetName);
|
||||
$sheetData = $objPHPExcel->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 />';
|
||||
$objPHPExcel->setActiveSheetIndexByName($loadedSheetName);
|
||||
$sheetData = $objPHPExcel->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 />';
|
||||
$objPHPExcel->setActiveSheetIndexByName($loadedSheetName);
|
||||
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,false,false,true);
|
||||
var_dump($sheetData);
|
||||
echo '<br />';
|
||||
}
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
46
PHPExcel/Documentation/Examples/Reader/exampleReader16.php
Executable file
46
PHPExcel/Documentation/Examples/Reader/exampleReader16.php
Executable file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #16</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #16</h1>
|
||||
<h2>Handling Loader Exceptions using Try/Catch</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileName = './sampleData/example_1.xls';
|
||||
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory to identify the format<br />';
|
||||
try {
|
||||
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
|
||||
} catch(PHPExcel_Reader_Exception $e) {
|
||||
die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
echo '<hr />';
|
||||
|
||||
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
|
||||
var_dump($sheetData);
|
||||
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
52
PHPExcel/Documentation/Examples/Reader/exampleReader17.php
Executable file
52
PHPExcel/Documentation/Examples/Reader/exampleReader17.php
Executable file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #17</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #17</h1>
|
||||
<h2>Simple File Reader Loading Several Named WorkSheets</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileType = 'Excel5';
|
||||
// $inputFileType = 'Excel2007';
|
||||
// $inputFileType = 'Excel2003XML';
|
||||
// $inputFileType = 'OOCalc';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
||||
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||
|
||||
|
||||
/** Read the list of Worksheet Names from the Workbook file **/
|
||||
echo 'Read the list of Worksheets in the WorkBook<br />';
|
||||
$worksheetNames = $objReader->listWorksheetNames($inputFileName);
|
||||
|
||||
echo 'There are ',count($worksheetNames),' worksheet',((count($worksheetNames) == 1) ? '' : 's'),' in the workbook<br /><br />';
|
||||
foreach($worksheetNames as $worksheetName) {
|
||||
echo $worksheetName,'<br />';
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
50
PHPExcel/Documentation/Examples/Reader/exampleReader18.php
Executable file
50
PHPExcel/Documentation/Examples/Reader/exampleReader18.php
Executable file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #18</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #18</h1>
|
||||
<h2>Reading list of WorkSheets without loading entire file</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileType = 'Excel5';
|
||||
// $inputFileType = 'Excel2007';
|
||||
// $inputFileType = 'Excel2003XML';
|
||||
// $inputFileType = 'OOCalc';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' information using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
||||
|
||||
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||
$worksheetNames = $objReader->listWorksheetNames($inputFileName);
|
||||
|
||||
echo '<h3>Worksheet Names</h3>';
|
||||
echo '<ol>';
|
||||
foreach ($worksheetNames as $worksheetName) {
|
||||
echo '<li>', $worksheetName, '</li>';
|
||||
}
|
||||
echo '</ol>';
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
53
PHPExcel/Documentation/Examples/Reader/exampleReader19.php
Executable file
53
PHPExcel/Documentation/Examples/Reader/exampleReader19.php
Executable file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
set_time_limit(0);
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
<title>PHPExcel Reader Example #19</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>PHPExcel Reader Example #19</h1>
|
||||
<h2>Reading WorkSheet information without loading entire file</h2>
|
||||
<?php
|
||||
|
||||
/** Include path **/
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
|
||||
|
||||
/** PHPExcel_IOFactory */
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
$inputFileType = 'Excel5';
|
||||
// $inputFileType = 'Excel2007';
|
||||
// $inputFileType = 'Excel2003XML';
|
||||
// $inputFileType = 'OOCalc';
|
||||
// $inputFileType = 'Gnumeric';
|
||||
$inputFileName = './sampleData/example1.xls';
|
||||
|
||||
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' information using IOFactory with a defined reader type of ',$inputFileType,'<br />';
|
||||
|
||||
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
|
||||
$worksheetData = $objReader->listWorksheetInfo($inputFileName);
|
||||
|
||||
echo '<h3>Worksheet Information</h3>';
|
||||
echo '<ol>';
|
||||
foreach ($worksheetData as $worksheet) {
|
||||
echo '<li>', $worksheet['worksheetName'], '<br />';
|
||||
echo 'Rows: ', $worksheet['totalRows'], ' Columns: ', $worksheet['totalColumns'], '<br />';
|
||||
echo 'Cell Range: A1:', $worksheet['lastColumnLetter'], $worksheet['totalRows'];
|
||||
echo '</li>';
|
||||
}
|
||||
echo '</ol>';
|
||||
|
||||
?>
|
||||
<body>
|
||||
</html>
|
4
PHPExcel/Documentation/Examples/Reader/sampleData/example1.csv
Executable file
4
PHPExcel/Documentation/Examples/Reader/sampleData/example1.csv
Executable file
@ -0,0 +1,4 @@
|
||||
First Name,Last Name,Nationality,Gender,Date of Birth,Time of Birth,Date/Time,PHP Coder,Sanity %Age
|
||||
Mark,Baker,British,M,19-Dec-1960,01:30,=E2+F2,TRUE,32%
|
||||
Toni,Baker,British,F,24-Nov-1950,20:00,=E3+F3,FALSE,95%
|
||||
Rachel,Baker,British,F,7-Dec-1982,00:15,=E4+F4,FALSE,100%
|
|
4
PHPExcel/Documentation/Examples/Reader/sampleData/example1.tsv
Executable file
4
PHPExcel/Documentation/Examples/Reader/sampleData/example1.tsv
Executable file
@ -0,0 +1,4 @@
|
||||
First Name Last Name Nationality Gender Date of Birth Time of Birth Date/Time PHP Coder Sanity %Age
|
||||
Mark Baker British M 19-Dec-1960 01:30 =E2+F2 TRUE 32%
|
||||
Toni Baker British F 24-Nov-1950 20:00 =E3+F3 FALSE 95%
|
||||
Rachel Baker British F 7-Dec-1982 00:15 =E4+F4 FALSE 100%
|
|
BIN
PHPExcel/Documentation/Examples/Reader/sampleData/example1.xls
Executable file
BIN
PHPExcel/Documentation/Examples/Reader/sampleData/example1.xls
Executable file
Binary file not shown.
223
PHPExcel/Documentation/Examples/Reader/sampleData/example2.csv
Executable file
223
PHPExcel/Documentation/Examples/Reader/sampleData/example2.csv
Executable file
@ -0,0 +1,223 @@
|
||||
"City","Country","Latitude","Longitude"
|
||||
"Kabul","Afghanistan",34.528455,69.171703
|
||||
"Tirane","Albania",41.33,19.82
|
||||
"Algiers","Algeria",36.752887,3.042048
|
||||
"Pago Pago","American Samoa",-14.27933,-170.700897
|
||||
"Andorra la Vella","Andorra",42.507531,1.521816
|
||||
"Luanda","Angola",-8.838333,13.234444
|
||||
"Buenos Aires","Argentina",-34.608417,-58.373161
|
||||
"Yerevan","Armenia",40.183333,44.516667
|
||||
"Oranjestad","Aruba",12.52458,-70.026459
|
||||
"Canberra","Australia",-35.3075,149.124417
|
||||
"Vienna","Austria",48.208333,16.373056
|
||||
"Baku","Azerbaijan",40.379571,49.891233
|
||||
"Nassau","Bahamas",25.06,-77.345
|
||||
"Manama","Bahrain",26.216667,50.583333
|
||||
"Dhaka","Bangladesh",23.709921,90.407143
|
||||
"Bridgetown","Barbados",13.096111,-59.608333
|
||||
"Minsk","Belarus",53.9,27.566667
|
||||
"Brussels","Belgium",50.846281,4.354727
|
||||
"Belmopan","Belize",17.251389,-88.766944
|
||||
"Thimphu","Bhutan",27.466667,89.641667
|
||||
"La Paz","Bolivia",-16.49901,-68.146248
|
||||
"Sarajevo","Bosnia and Herzegovina",43.8476,18.3564
|
||||
"Gaborone","Botswana",-24.65411,25.908739
|
||||
"Brasilia","Brazil",-15.780148,-47.92917
|
||||
"Road Town","British Virgin Islands",18.433333,-64.616667
|
||||
"Bandar Seri Begawan","Brunei Darussalam",4.9431,114.9425
|
||||
"Sofia","Bulgaria",42.697626,23.322284
|
||||
"Ouagadougou","Burkina Faso",12.364637,-1.533864
|
||||
"Bujumbura","Burundi",-3.361378,29.359878
|
||||
"Phnom Penh","Cambodia",11.55,104.916667
|
||||
"Yaounde","Cameroon",3.866667,11.516667
|
||||
"Ottawa","Canada",45.423494,-75.697933
|
||||
"Praia","Cape Verde",14.920833,-23.508333
|
||||
"George Town","Cayman Islands",19.286932,-81.367439
|
||||
"Bangui","Central African Republic",4.361698,18.555975
|
||||
"N'Djamena","Chad",12.104797,15.044506
|
||||
"Santiago","Chile",-33.42536,-70.566466
|
||||
"Beijing","China",39.904667,116.408198
|
||||
"Bogota","Colombia",4.647302,-74.096268
|
||||
"Moroni","Comoros",-11.717216,43.247315
|
||||
"Brazzaville","Congo",-4.266667,15.283333
|
||||
"San Jose","Costa Rica",9.933333,-84.083333
|
||||
"Yamoussoukro","Cote d'Ivoire",6.816667,-5.283333
|
||||
"Zagreb","Croatia",45.814912,15.978515
|
||||
"Havana","Cuba",23.133333,-82.366667
|
||||
"Nicosia","Cyprus",35.166667,33.366667
|
||||
"Prague","Czech Republic",50.087811,14.42046
|
||||
"Kinshasa","Congo",-4.325,15.322222
|
||||
"Copenhagen","Denmark",55.676294,12.568116
|
||||
"Djibouti","Djibouti",11.588,43.145
|
||||
"Roseau","Dominica",15.301389,-61.388333
|
||||
"Santo Domingo","Dominican Republic",18.5,-69.983333
|
||||
"Dili","East Timor",-8.566667,125.566667
|
||||
"Quito","Ecuador",-0.229498,-78.524277
|
||||
"Cairo","Egypt",30.064742,31.249509
|
||||
"San Salvador","El Salvador",13.69,-89.190003
|
||||
"Malabo","Equatorial Guinea",3.75,8.783333
|
||||
"Asmara","Eritrea",15.33236,38.92617
|
||||
"Tallinn","Estonia",59.438862,24.754472
|
||||
"Addis Ababa","Ethiopia",9.022736,38.746799
|
||||
"Stanley","Falkland Islands",-51.700981,-57.84919
|
||||
"Torshavn","Faroe Islands",62.017707,-6.771879
|
||||
"Suva","Fiji",-18.1416,178.4419
|
||||
"Helsinki","Finland",60.169813,24.93824
|
||||
"Paris","France",48.856667,2.350987
|
||||
"Cayenne","French Guiana",4.9227,-52.3269
|
||||
"Papeete","French Polynesia",-17.535021,-149.569595
|
||||
"Libreville","Gabon",0.390841,9.453644
|
||||
"Banjul","Gambia",13.453056,-16.5775
|
||||
"T'bilisi","Georgia",41.716667,44.783333
|
||||
"Berlin","Germany",52.523405,13.4114
|
||||
"Accra","Ghana",5.555717,-0.196306
|
||||
"Athens","Greece",37.97918,23.716647
|
||||
"Nuuk","Greenland",64.18362,-51.721407
|
||||
"Basse-Terre","Guadeloupe",15.998503,-61.72202
|
||||
"Guatemala","Guatemala",14.641389,-90.513056
|
||||
"St. Peter Port","Guernsey",49.458858,-2.534752
|
||||
"Conakry","Guinea",9.537029,-13.67847
|
||||
"Bissau","Guinea-Bissau",11.866667,-15.6
|
||||
"Georgetown","Guyana",6.804611,-58.154831
|
||||
"Port-au-Prince","Haiti",18.539269,-72.336408
|
||||
"Tegucigalpa","Honduras",14.082054,-87.206285
|
||||
"Budapest","Hungary",47.498406,19.040758
|
||||
"Reykjavik","Iceland",64.135338,-21.89521
|
||||
"New Delhi","India",28.635308,77.22496
|
||||
"Jakarta","Indonesia",-6.211544,106.845172
|
||||
"Tehran","Iran",35.696216,51.422945
|
||||
"Baghdad","Iraq",33.3157,44.3922
|
||||
"Dublin","Ireland",53.344104,-6.267494
|
||||
"Jerusalem","Israel",31.7857,35.2007
|
||||
"Rome","Italy",41.895466,12.482324
|
||||
"Kingston","Jamaica",17.992731,-76.792009
|
||||
"St. Helier","Jersey",49.190278,-2.108611
|
||||
"Amman","Jordan",31.956578,35.945695
|
||||
"Astana","Kazakhstan",51.10,71.30
|
||||
"Nairobi","Kenya",-01.17,36.48
|
||||
"Tarawa","Kiribati",01.30,173.00
|
||||
"Seoul","South Korea",37.31,126.58
|
||||
"Kuwait City","Kuwait",29.30,48.00
|
||||
"Bishkek","Kyrgyzstan",42.54,74.46
|
||||
"Riga","Latvia",56.53,24.08
|
||||
"Beirut","Lebanon",33.53,35.31
|
||||
"Maseru","Lesotho",-29.18,27.30
|
||||
"Monrovia","Liberia",06.18,-10.47
|
||||
"Vaduz","Liechtenstein",47.08,09.31
|
||||
"Vilnius","Lithuania",54.38,25.19
|
||||
"Luxembourg","Luxembourg",49.37,06.09
|
||||
"Antananarivo","Madagascar",-18.55,47.31
|
||||
"Lilongwe","Malawi",-14.00,33.48
|
||||
"Kuala Lumpur","Malaysia",03.09,101.41
|
||||
"Male","Maldives",04.00,73.28
|
||||
"Bamako","Mali",12.34,-07.55
|
||||
"Valletta","Malta",35.54,14.31
|
||||
"Fort-de-France","Martinique",14.36,-61.02
|
||||
"Nouakchott","Mauritania",-20.10,57.30
|
||||
"Mamoudzou","Mayotte",-12.48,45.14
|
||||
"Mexico City","Mexico",19.20,-99.10
|
||||
"Palikir","Micronesia",06.55,158.09
|
||||
"Chisinau","Moldova",47.02,28.50
|
||||
"Maputo","Mozambique",-25.58,32.32
|
||||
"Yangon","Myanmar",16.45,96.20
|
||||
"Windhoek","Namibia",-22.35,17.04
|
||||
"Kathmandu","Nepal",27.45,85.20
|
||||
"Amsterdam","Netherlands",52.23,04.54
|
||||
"Willemstad","Netherlands Antilles",12.05,-69.00
|
||||
"Noumea","New Caledonia",-22.17,166.30
|
||||
"Wellington","New Zealand",-41.19,174.46
|
||||
"Managua","Nicaragua",12.06,-86.20
|
||||
"Niamey","Niger",13.27,02.06
|
||||
"Abuja","Nigeria",09.05,07.32
|
||||
"Kingston","Norfolk Island",-45.20,168.43
|
||||
"Saipan","Northern Mariana Islands",15.12,145.45
|
||||
"Oslo","Norway",59.55,10.45
|
||||
"Masqat","Oman",23.37,58.36
|
||||
"Islamabad","Pakistan",33.40,73.10
|
||||
"Koror","Palau",07.20,134.28
|
||||
"Panama City","Panama",09.00,-79.25
|
||||
"Port Moresby","Papua New Guinea",-09.24,147.08
|
||||
"Asuncion","Paraguay",-25.10,-57.30
|
||||
"Lima","Peru",-12.00,-77.00
|
||||
"Manila","Philippines",14.40,121.03
|
||||
"Warsaw","Poland",52.13,21.00
|
||||
"Lisbon","Portugal",38.42,-09.10
|
||||
"San Juan","Puerto Rico",18.28,-66.07
|
||||
"Doha","Qatar",25.15,51.35
|
||||
"Bucuresti","Romania",44.27,26.10
|
||||
"Moskva","Russian Federation",55.45,37.35
|
||||
"Kigali","Rawanda",-01.59,30.04
|
||||
"Basseterre","Saint Kitts and Nevis",17.17,-62.43
|
||||
"Castries","Saint Lucia",14.02,-60.58
|
||||
"Saint-Pierre","Saint Pierre and Miquelon",46.46,-56.12
|
||||
"Apia","Samoa",-13.50,-171.50
|
||||
"San Marino","San Marino",43.55,12.30
|
||||
"Sao Tome","Sao Tome and Principe",00.10,06.39
|
||||
"Riyadh","Saudi Arabia",24.41,46.42
|
||||
"Dakar","Senegal",14.34,-17.29
|
||||
"Freetown","Sierra Leone",08.30,-13.17
|
||||
"Bratislava","Slovakia",48.10,17.07
|
||||
"Ljubljana","Slovenia",46.04,14.33
|
||||
"Honiara","Solomon Islands",-09.27,159.57
|
||||
"Mogadishu","Somalia",02.02,45.25
|
||||
"Pretoria","South Africa",-25.44,28.12
|
||||
"Madrid","Spain",40.25,-03.45
|
||||
"Khartoum","Sudan",15.31,32.35
|
||||
"Paramaribo","Suriname",05.50,-55.10
|
||||
"Mbabane","Swaziland",-26.18,31.06
|
||||
"Stockholm","Sweden",59.20,18.03
|
||||
"Bern","Switzerland",46.57,07.28
|
||||
"Damascus","Syrian Arab Republic",33.30,36.18
|
||||
"Dushanbe","Tajikistan",38.33,68.48
|
||||
"Bangkok","Thailand",13.45,100.35
|
||||
"Lome","Togo",06.09,01.20
|
||||
"Nuku'alofa","Tonga",-21.10,-174.00
|
||||
"Tunis","Tunisia",36.50,10.11
|
||||
"Ankara","Turkey",39.57,32.54
|
||||
"Ashgabat","Turkmenistan",38.00,57.50
|
||||
"Funafuti","Tuvalu",-08.31,179.13
|
||||
"Kampala","Uganda",00.20,32.30
|
||||
"Kiev","Ukraine",50.30,30.28
|
||||
"Abu Dhabi","United Arab Emirates",24.28,54.22
|
||||
"London","United Kingdom",51.36,-00.05
|
||||
"Dodoma","Tanzania",-06.08,35.45
|
||||
"Washington DC","United States of America",39.91,-77.02
|
||||
"Montevideo","Uruguay",-34.50,-56.11
|
||||
"Tashkent","Uzbekistan",41.20,69.10
|
||||
"Port-Vila","Vanuatu",-17.45,168.18
|
||||
"Caracas","Venezuela",10.30,-66.55
|
||||
"Hanoi","Viet Nam",21.05,105.55
|
||||
"Belgrade","Yugoslavia",44.50,20.37
|
||||
"Lusaka","Zambia",-15.28,28.16
|
||||
"Harare","Zimbabwe",-17.43,31.02
|
||||
"St. John's","Antigua and Barbuda",17.08,-61.50
|
||||
"Porto Novo","Benin",06.30,02.47
|
||||
"Hamilton","Bermuda"","32.18,-64.48
|
||||
"Avarua","Cook Islands",-21.12,-159.46
|
||||
"St. George's","Grenada",12.04,-61.44
|
||||
"Aga<EFBFBD>a","Guam",13.28,144.45
|
||||
"Victoria","Hong Kong",22.16,114.13
|
||||
"Tokyo","Japan",35.40,139.45
|
||||
"Pyongyang","North Korea",39.00,125.47
|
||||
"Vientiane","Laos",17.59,102.38
|
||||
"Tripoli","Libya",32.54,013.11
|
||||
"Skopje","Macedonia",42.00,021.28
|
||||
"Majuro","Marshall Islands",07.05,171.08
|
||||
"Port Louis","Mauritius",-20.10,57.30
|
||||
"Monaco","Monaco",43.44,007.25
|
||||
"Ulan Bator","Mongolia",47.54,106.52
|
||||
"Plymouth","Montserrat",16.44,-62.14
|
||||
"Rabat","Morocco",34.02,-06.51
|
||||
"Alofi","Niue",-14.27,-178.05
|
||||
"Saint-Denis","R<EFBFBD>union",-20.52,55.27
|
||||
"Victoria","Seychelles",-04.38,55.28
|
||||
"Singapore","Singapore",01.18,103.50
|
||||
"Colombo","Sri Lanka",06.55,79.52
|
||||
"Kingstown","St Vincent and the Grenadines",13.12,-61.14
|
||||
"Taipei","Taiwan",25.50,121.32
|
||||
"Port-of-Spain","Trinidad and Tobago",10.38,-61.31
|
||||
"Cockburn Harbour","Turks and Caicos Islands",21.30,-71.30
|
||||
"Charlotte Amalie","US Virgin Islands",18.22,-64.56
|
||||
"Vatican City","Vatican State",41.54,12.27
|
||||
"La<EFBFBD>youne","Western Sahara",27.10,-13.11
|
||||
"San'a","Yemen",15.24,44.14
|
Can't render this file because it contains an unexpected character in line 195 and column 23.
|
BIN
PHPExcel/Documentation/Examples/Reader/sampleData/example2.xls
Executable file
BIN
PHPExcel/Documentation/Examples/Reader/sampleData/example2.xls
Executable file
Binary file not shown.
Reference in New Issue
Block a user