示例#1
0
 /**
  * @test
  * @covers Plum\PlumExcel\ExcelReader::getIterator()
  * @covers Plum\PlumExcel\ExcelReader::getData()
  */
 public function getIteratorReturnsIterator()
 {
     $iterator = $this->reader->getIterator();
     $this->assertEquals('col A', $iterator[0][0]);
     $this->assertEquals('col B', $iterator[0][1]);
     $this->assertEquals('line 1A', $iterator[1][0]);
     $this->assertEquals('line 1B', $iterator[1][1]);
     $this->assertCount(4, $iterator);
 }
示例#2
0
<?php

/**
 * This file is part of plumphp/plum-excel.
 *
 * (c) Florian Eckerstorfer <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
use Plum\PlumExcel\ExcelReader;
require_once __DIR__ . '/../vendor/autoload.php';
if (!file_exists(__DIR__ . '/example.xlsx')) {
    echo "Please run the write-excel.php first to generate a Excel file.\n";
    exit(1);
}
$excel = PHPExcel_IOFactory::load(__DIR__ . '/example.xlsx');
$reader = new ExcelReader($excel);
foreach ($reader->getIterator() as $row) {
    print_r($row);
}