CodeIgniter Forums
trouble with OLE check in the read function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7)
+--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13)
+--- Thread: trouble with OLE check in the read function (/showthread.php?tid=70039)



trouble with OLE check in the read function - richb201 - 02-11-2018

In phpSpreadsheet I am trying to do a read(filename). One of the first things the code does is check the first 8 bytes of the xls (or xlsx) to see if it has the OLE signature. My code keeps failing there.

$this->data = file_get_contents($pFilename, false, null, 0, 8);
$identifierOle = pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1);
if ($this->data != $identifierOle) {
   throw new ReaderException('The filename ' . $pFilename . ' is not recognized as an OLE file');
}






The attached jpg shows this identifierOLE (packed into a string) on the second line, and the first 8 bytes of my xls file on the first line. 

I think that the file_get_contents() is working. But I can see that my first 8 bytes and identifierOle are NOT the same. I thought maybe it was the way I was looking at it. But I am out of ideas. This same piece of code seems to run whether it is a xls or a xlsx file.