MyAheadreadFilter.php 658 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace cutExcel;
  3. /**
  4. * 预读过滤类
  5. * @author wangyelou
  6. * @date 2018-07-30
  7. */
  8. class MyAheadreadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter
  9. {
  10. public $record = array();
  11. private $lastRow = '';
  12. public function readCell($column, $row, $worksheetName = '')
  13. {
  14. if (isset($this->record[$worksheetName]) ) {
  15. if ($this->lastRow != $row) {
  16. $this->record[$worksheetName] ++;
  17. $this->lastRow = $row;
  18. }
  19. } else {
  20. $this->record[$worksheetName] = 1;
  21. $this->lastRow = $row;
  22. }
  23. return false;
  24. }
  25. }