我正在使用Sphpspreadsheet图书馆并测试上载的Excel文档。 这些是我的法典
require vendor/autoload.php ;
use PhpOfficePhpSpreadsheetIOFactory;
use PhpOfficePhpSpreadsheetSpreadsheet;
use PhpOfficePhpSpreadsheetWriterXlsx;
$excel_file = $_FILES[ excelFile ][ tmp_name ];
$reader = PhpOfficePhpSpreadsheetIOFactory::createReaderForFile($excel_file);
$reader->setReadDataOnly(TRUE);
$spreadsheet = $reader->load($excel_file);
$worksheet = $spreadsheet->getActiveSheet();
foreach ($worksheet->getRowIterator() as $row) {
$cell_values = $row->toArray();
if (empty($cell_values[0]) || empty($cell_values[1]) || empty($cell_values[2])) {
$error = Error: Date, Sample and Isolate columns must not be empty in row . $row->getRowIndex();
error_log($error, 3, $log_file);
}
}
I am seeing this error: Fatal error: Uncaught Error: Call to undefined method PhpOfficePhpSpreadsheetWorksheetRow::toArray() on the line that corresponds to
foreach ($worksheet->getRowIterator() as $row) { $cell_values = $row->toArray();
问题是什么? 请帮助我。