diff --git a/Documentation/Examples/Reader/exampleReader01.php b/Documentation/Examples/Reader/exampleReader01.php new file mode 100644 index 0000000..f881af0 --- /dev/null +++ b/Documentation/Examples/Reader/exampleReader01.php @@ -0,0 +1,42 @@ + + + + + +PHPExcel Reader Example #01 + + + + +

PHPExcel Reader Example #01

+

Simple File Reader using PHPExcel_IOFactory::load()

+'; +$objPHPExcel = PHPExcel_IOFactory::load($inputFileName); + + +echo '
'; + +$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); +var_dump($sheetData); + + +?> + + \ No newline at end of file diff --git a/Documentation/Examples/Reader/exampleReader02.php b/Documentation/Examples/Reader/exampleReader02.php new file mode 100644 index 0000000..51b36e5 --- /dev/null +++ b/Documentation/Examples/Reader/exampleReader02.php @@ -0,0 +1,50 @@ + + + + + +PHPExcel Reader Example #02 + + + + +

PHPExcel Reader Example #02

+

Simple File Reader using a Specified Reader

+'; +$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 '
'; + +$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); +var_dump($sheetData); + + +?> + + \ No newline at end of file diff --git a/Documentation/Examples/Reader/exampleReader03.php b/Documentation/Examples/Reader/exampleReader03.php new file mode 100644 index 0000000..1c571d3 --- /dev/null +++ b/Documentation/Examples/Reader/exampleReader03.php @@ -0,0 +1,51 @@ + + + + + +PHPExcel Reader Example #03 + + + + +

PHPExcel Reader Example #03

+

Simple File Reader using the PHPExcel_IOFactory to Return a Reader

+'; +$objReader = PHPExcel_IOFactory::createReader($inputFileType); +$objPHPExcel = $objReader->load($inputFileName); + + +echo '
'; + +$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); +var_dump($sheetData); + + +?> + + \ No newline at end of file diff --git a/Documentation/Examples/Reader/exampleReader04.php b/Documentation/Examples/Reader/exampleReader04.php new file mode 100644 index 0000000..a18c711 --- /dev/null +++ b/Documentation/Examples/Reader/exampleReader04.php @@ -0,0 +1,47 @@ + + + + + +PHPExcel Reader Example #04 + + + + +

PHPExcel Reader Example #04

+

Simple File Reader using the PHPExcel_IOFactory to Identify a Reader to Use

+'; + +echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with the identified reader type
'; +$objReader = PHPExcel_IOFactory::createReader($inputFileType); +$objPHPExcel = $objReader->load($inputFileName); + + +echo '
'; + +$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); +var_dump($sheetData); + + +?> + + \ No newline at end of file diff --git a/Documentation/Examples/Reader/exampleReader05.php b/Documentation/Examples/Reader/exampleReader05.php new file mode 100644 index 0000000..9bee5b4 --- /dev/null +++ b/Documentation/Examples/Reader/exampleReader05.php @@ -0,0 +1,51 @@ + + + + + +PHPExcel Reader Example #05 + + + + +

PHPExcel Reader Example #05

+

Simple File Reader using the "Read Data Only" Option

+'; +$objReader = PHPExcel_IOFactory::createReader($inputFileType); +echo 'Turning Formatting off for Load
'; +$objReader->setReadDataOnly(true); +$objPHPExcel = $objReader->load($inputFileName); + + +echo '
'; + +$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); +var_dump($sheetData); + + +?> + + \ No newline at end of file diff --git a/Documentation/Examples/Reader/exampleReader06.php b/Documentation/Examples/Reader/exampleReader06.php new file mode 100644 index 0000000..6997a38 --- /dev/null +++ b/Documentation/Examples/Reader/exampleReader06.php @@ -0,0 +1,54 @@ + + + + + +PHPExcel Reader Example #06 + + + + +

PHPExcel Reader Example #06

+

Simple File Reader Loading All WorkSheets

+'; +$objReader = PHPExcel_IOFactory::createReader($inputFileType); +echo 'Loading all WorkSheets
'; +$objReader->setLoadAllSheets(); +$objPHPExcel = $objReader->load($inputFileName); + + +echo '
'; + +echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded

'; +$loadedSheetNames = $objPHPExcel->getSheetNames(); +foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) { + echo $sheetIndex,' -> ',$loadedSheetName,'
'; +} + + +?> + + \ No newline at end of file diff --git a/Documentation/Examples/Reader/exampleReader07.php b/Documentation/Examples/Reader/exampleReader07.php new file mode 100644 index 0000000..0d86ea7 --- /dev/null +++ b/Documentation/Examples/Reader/exampleReader07.php @@ -0,0 +1,55 @@ + + + + + +PHPExcel Reader Example #07 + + + + +

PHPExcel Reader Example #07

+

Simple File Reader Loading a Single Named WorkSheet

+'; +$objReader = PHPExcel_IOFactory::createReader($inputFileType); +echo 'Loading Sheet "',$sheetname,'" only
'; +$objReader->setLoadSheetsOnly($sheetname); +$objPHPExcel = $objReader->load($inputFileName); + + +echo '
'; + +echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded

'; +$loadedSheetNames = $objPHPExcel->getSheetNames(); +foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) { + echo $sheetIndex,' -> ',$loadedSheetName,'
'; +} + + +?> + + \ No newline at end of file diff --git a/Documentation/Examples/Reader/exampleReader08.php b/Documentation/Examples/Reader/exampleReader08.php new file mode 100644 index 0000000..c6a4460 --- /dev/null +++ b/Documentation/Examples/Reader/exampleReader08.php @@ -0,0 +1,55 @@ + + + + + +PHPExcel Reader Example #08 + + + + +

PHPExcel Reader Example #08

+

Simple File Reader Loading Several Named WorkSheets

+'; +$objReader = PHPExcel_IOFactory::createReader($inputFileType); +echo 'Loading Sheet',((count($sheetnames) == 1) ? '' : 's'),' "',implode('" and "',$sheetnames),'" only
'; +$objReader->setLoadSheetsOnly($sheetnames); +$objPHPExcel = $objReader->load($inputFileName); + + +echo '
'; + +echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded

'; +$loadedSheetNames = $objPHPExcel->getSheetNames(); +foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) { + echo $sheetIndex,' -> ',$loadedSheetName,'
'; +} + + +?> + + \ No newline at end of file diff --git a/Documentation/Examples/Reader/exampleReader09.php b/Documentation/Examples/Reader/exampleReader09.php new file mode 100644 index 0000000..a6cd144 --- /dev/null +++ b/Documentation/Examples/Reader/exampleReader09.php @@ -0,0 +1,71 @@ + + + + + +PHPExcel Reader Example #09 + + + + +

PHPExcel Reader Example #09

+

Simple File Reader Using a Read Filter

+= 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,'
'; +$objReader = PHPExcel_IOFactory::createReader($inputFileType); +echo 'Loading Sheet "',$sheetname,'" only
'; +$objReader->setLoadSheetsOnly($sheetname); +echo 'Loading Sheet using filter
'; +$objReader->setReadFilter($filterSubset); +$objPHPExcel = $objReader->load($inputFileName); + + +echo '
'; + +$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); +var_dump($sheetData); + + +?> + + \ No newline at end of file diff --git a/Documentation/Examples/Reader/exampleReader10.php b/Documentation/Examples/Reader/exampleReader10.php new file mode 100644 index 0000000..d608c64 --- /dev/null +++ b/Documentation/Examples/Reader/exampleReader10.php @@ -0,0 +1,82 @@ + + + + + +PHPExcel Reader Example #10 + + + + +

PHPExcel Reader Example #10

+

Simple File Reader Using a Configurable Read Filter

+_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,'
'; +$objReader = PHPExcel_IOFactory::createReader($inputFileType); +echo 'Loading Sheet "',$sheetname,'" only
'; +$objReader->setLoadSheetsOnly($sheetname); +echo 'Loading Sheet using configurable filter
'; +$objReader->setReadFilter($filterSubset); +$objPHPExcel = $objReader->load($inputFileName); + + +echo '
'; + +$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); +var_dump($sheetData); + + +?> + + \ No newline at end of file diff --git a/Documentation/Examples/Reader/sampleData/example1.xls b/Documentation/Examples/Reader/sampleData/example1.xls new file mode 100644 index 0000000..a7e0e08 Binary files /dev/null and b/Documentation/Examples/Reader/sampleData/example1.xls differ