Paulo Henrique Paulo Henrique - 11 months ago 81
PHP Question

PHP Excel can't read Excel 4.0 worksheet

Have this project which aims to import an Excel sheet: the file is a report, not a flat file and there's no way to obtain such. So I'm using PHP Excel to read the file and save the data we need into the application.

Problem is that the file is in Excel 4.0 format which I can't edit (apparently), it can be opened and viewed in MS Excel application, but PHP Excel throws the exception when trying to read it with Excel5:

Fatal error: Uncaught exception 'PHPExcel_Reader_Exception' with message 'The filename C:/xampp/htdocs/uploads/PS.xls is not recognised as an OLE file' in C:\xampp\htdocs\includes\PHPExcel-1.8\Classes\PHPExcel\Shared\OLERead.php on line 90

PHP Excel identifies the file as in HTML format, but also, throws me the error:

Warning: DOMDocument::loadHTML(): Invalid char in CDATA 0x4 in Entity, line: 1 in C:\xampp\htdocs\includes\PHPExcel-1.8\Classes\PHPExcel\Reader\HTML.php on line 495

I suppose this is beacuse the data contains special characters (UTF-8), but found nothing in PHPExcel that could change the encoding... neither could find anything about this problem and I'm starting to think there's no solution for this, except by asking the user to copy & paste the data to "decent" Excel file... That way works, but require some manual manipulation...

Answer Source

No it can't read it. The minimum BIFF format version that PHPExcel can read is BIFF 5 (from 1993, 24 years ago)

Good luck finding anything capable of reading BIFF 4 (from 1992)... BIFF 4 uses OLE1, while PHPExcel can only read xls files using OLE2 (from BIFF 5 onwards). I'm not aware of any pure PHP extensions that can handle such an early format; you may need to use the commercial LibXl extension

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download