12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace cutExcel;
- use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
- /**
- * 解析过滤类
- */
- class MyreadFilter implements IReadFilter
- {
- private $startRow = 0;
- private $endRow = 0;
- public function __construct($startRow, $endRow) {
- $this->startRow = $startRow;
- $this->endRow = $endRow;
- }
- public function readCell($column, $row, $worksheetName = '')
- {
- if ($row >= $this->startRow && $row <= $this->endRow) {
- return true;
- }
- return false;
- }
- // 标准示例 调用 new MyReadFilter(9,15,range('G','K'));
- /* private $startRow = 0;
- private $endRow = 0;
- private $columns = [];
- public function __construct($startRow, $endRow, $columns) {
- $this->startRow = $startRow;
- $this->endRow = $endRow;
- $this->columns = $columns;
- }
- public function readCell($column, $row, $worksheetName = '') {
- // Only read the rows and columns that were configured
- if ($row >= $this->startRow && $row <= $this->endRow) {
- if (in_array($column,$this->columns)) {
- return true;
- }
- }
- return false;
- } */
- }
|