PHPOffice / PHPExcel

ARCHIVED
Other
11.46k stars 4.19k forks source link

Issue importing files #979

Open geradt opened 8 years ago

geradt commented 8 years ago

Hi folks,

Thank you so much for such a great product. I have run into a small issue with my app when using this package.

ErrorException in PHPExcel.php line 889: Undefined offset: 0

Here is the call stack:

1. in PHPExcel.php line 889
2. at HandleExceptions->handleError('8', 'Undefined offset: 0', 'C:\laragon\www\yieldfolio\vendor\phpoffice\phpexcel\Classes\PHPExcel.php', '889', array('pIndex' => '0')) in PHPExcel.php line 889
3. at PHPExcel->getCellXfByIndex('0') in Style.php line 153
4. at PHPExcel_Style->getSharedComponent() in NumberFormat.php line 135
5. at PHPExcel_Style_NumberFormat->getSharedComponent() in NumberFormat.php line 188
6. at PHPExcel_Style_NumberFormat->getFormatCode() in Date.php line 270
7. at PHPExcel_Shared_Date::isDateTimeFormat(object(PHPExcel_Style_NumberFormat)) in Date.php line 259
8. at PHPExcel_Shared_Date::isDateTime(object(PHPExcel_Cell)) in ExcelParser.php line 606
9. at ExcelParser->cellIsDate('Parcel ID') in ExcelParser.php line 476
10. at ExcelParser->parseCell('Parcel ID') in ExcelParser.php line 449
11. at ExcelParser->parseCells() in ExcelParser.php line 376
12. at ExcelParser->parseRows() in ExcelParser.php line 183
13. at ExcelParser->parseWorksheet() in ExcelParser.php line 133

I have attached a copy of the sheet that I'm trying to import as well. Just in case someone wants to try and recreate it. :) Export-test.xlsx

nathanh0 commented 7 years ago

Getting this as well.

It only happens when using ->toArray() iterating sheets.

Was attempting to prevent 984,000 "null" rows from being imported. Kind of having a time figuring this out.

motin commented 7 years ago

I found the underlying issue. Your file (as well as my problematic files) uses an XML namespace "d" in xl/styles.xml (ie <d:cellFx>), while as ordinary Excel XML files do not use any XML namespace (just <cellFx>). This prevents PHPExcel from loading the style information (cellfx) in the workbook. PHPExcel has no sanity check against this case, so the loading continues without an error until the style information is requested the first time.