-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
This is:
- [x ] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
What is the expected behavior?
Correct reading of rows and columns.
What is the current behavior?
After a few empty cells, reading the file extracts the next row cell.
What are the steps to reproduce?
Try to import the attached file and try to read line 17, I tried both “getRowIterator” and “toArray” function:
This is excel with row

This is the result of reading:
Array
(
[0] => 226
[1] =>
[2] => 38871**(this value is the first value of next row)**
)
If you read line before this row the result is correct.
The cell of the row is empty.
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:
<?php
require __DIR__ . '/vendor/autoload.php';
// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader("Xlsx");
$Spreadsheet = $reader->load("path-to-file");
$Sheet = $Spreadsheet->getActiveSheet();
$RowIt = $Sheet->getRowIterator(17, 17);
foreach ($RowIt as $idx => $Row) {
$CellIterator = $Row->getCellIterator();
$data = array();
foreach ($CellIterator as $Cell) {
array_push($data, (string) $Cell->getValue());
}
}
$data = $Sheet->toArray(null, true, true, true)[17]
;20240605111107_it-IT_en-GB.xlsx
If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.
What features do you think are causing the issue
- Reader
- Writer
- Styles
- Data Validations
- Formula Calculations
- Charts
- AutoFilter
- Form Elements
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
If open file with excel and only save it the file will be read correctly.
Which versions of PhpSpreadsheet and PHP are affected?
2.1