通过PhpOffice/PhpSpreadSheet的分组/级别过滤从xlsx-file中获取可扩展行的方法如下:
composer require phpoffice/phpspreadsheet
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Worksheet\RowIterator;
$spreadsheet = IOFactory::load('path/to/your/file.xlsx');
$worksheet = $spreadsheet->getActiveSheet();
$worksheet->setAutoFilter('A1:Z1');
$iterator = $worksheet->getRowIterator();
$expandableRows = [];
foreach ($iterator as $row) {
$cellValue = $worksheet->getCell('A' . $row->getRowIndex())->getValue();
if ($cellValue !== null && $cellValue !== '') {
$expandableRows[] = $row->getRowIndex();
}
}
foreach ($expandableRows as $rowIndex) {
$rowData = $worksheet->rangeToArray('A' . $rowIndex . ':Z' . $rowIndex, null, true, false);
print_r($rowData);
}
这样,你就可以通过PhpOffice/PhpSpreadSheet的分组/级别过滤从xlsx-file中获取可扩展行了。
注意:以上代码仅为示例,实际应用中可能需要根据具体情况进行适当的修改和调整。
推荐的腾讯云相关产品:腾讯云对象存储(COS)
领取专属 10元无门槛券
手把手带您无忧上云