-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error reading file column into specific row #4063
Comments
Excel file was be created with PhpSpreadsheet. |
After several trials in creating the file I found that this error if occurs if I try to write a cell with empty content, if I instead jump when the content is empty the problem is no longer generated. Is it normal for entering empty content to cause this problem? Of course now that I know this I avoid writing the cell if it is empty. |
Yes, there is a flaw in Xlsx Reader. I'm surprised it hasn't surfaced before. Expect a fix in the next day or two. |
Thanks, fantastic. |
Aha, it was previously reported as issue #1293, which was closed as stale in March 2020. I will reopen it (and reclose it when my PR is merged). |
Fix PHPOffice#4063. Fix PHPOffice#1560. Fix PHPOffice#1293. PhpSpreadsheet is not accounting for an empty string in Xlsx sharedStrings.xml.The code which parses it in Reader/Xlsx looks for a `t` or `r` tag descending from `si`, but, in this case, the tag is coded as `<si/>`, with neither t nor r tag descending. An else clause is added to set the string to empty string in this case. I was surprised that this had not turned up before, and a search through the archives found at least 2 earlier reports from 4 years ago. Those had been marked stale; the stale indicator is removed, and the issues are re-opened, to be closed when this PR is merged.
This is:
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:
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
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
The text was updated successfully, but these errors were encountered: