ExcelFilter.php 670 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace app\models;
  3. use PhpOffice\PhpSpreadsheet\IOFactory;
  4. use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
  5. class ExcelFilter implements IReadFilter
  6. {
  7. private $startRow = 0;
  8. private $endRow = 0;
  9. private $columns = [];
  10. public function __construct($startRow, $endRow, $columns)
  11. {
  12. $this->startRow = $startRow;
  13. $this->endRow = $endRow;
  14. $this->columns = $columns;
  15. }
  16. public function readCell($column, $row, $worksheetName = '')
  17. {
  18. if ($row >= $this->startRow) {
  19. if (in_array($column, $this->columns)) {
  20. return true;
  21. }
  22. }
  23. return false;
  24. }
  25. }