PHPSpreadsheet:如何获取加载的行数?

标签 php excel phpspreadsheet

如何使用 PHPSpreadsheet\Reader\Xlsx::load() 方法找出已加载的行数?

我也找不到在电子表格或工作表类中获取行数的方法(或属性)。

顺便说一句,我正在使用以下代码:

$filename = 'test.xlsx';
$inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($filename);
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);

$reader->setReadDataOnly(true);  
$reader->setLoadSheetsOnly($sheet);  

$this->spreadsheet = $reader->load($filename);
$this->worksheet = $this->spreadsheet->getActiveSheet();

最佳答案

使用工作表的 getHighestRow() 方法

$highestRow = $this->spreadsheet->getActiveSheet()->getHighestRow();

getHighestDataRow() 如果您只对单元格包含数据的行感兴趣,而不对工作表末尾的任何空白行感兴趣

关于PHPSpreadsheet:如何获取加载的行数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48789835/

相关文章:

php - 删除行php mysql动态链接

php - 在多个浏览器上同步用户输入

php - 在php中使用策略模式的优点

php - Insert Into on DUPLICATE KEY 更新错误

vba - 如何在 SheetChange 事件中检查所做的更改是否在命名范围内

php - 如何使用 PhpSpreadsheet 从表格单元格中检索日期?

php - 找不到类 'ZipArchive'

vba - 防止 Range.Find() 更改 "match entire cell content"用户界面设置

vba - 忽略图表VBA中的空单元格

php - 使用 PhpSpreadsheet 获取列范围