Just let PHPExcel figure out the file type by using PHPExcel_IOFactory::identify()
$filename = 'your_file.xls'; require_once 'PHPExcel/Classes/PHPExcel.php'; // Create new PHPExcel object $filetype = PHPExcel_IOFactory::identify($filename); $objReader = PHPExcel_IOFactory::createReader($filetype); $objReader->setReadDataOnly(true); // set this if you don't need to write $objPHPExcel = $objReader->load($filename); // go through each sheet foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { ... }
This comment is wrong..
$objReader->setReadDataOnly(true); // set this if you don’t need to write
it’s not “read-only” .. it’s “only-data” .. means cell values, but no format, comment, etc.
LikeLike
Apache crash when opening file. Even blank file. Any idea?
LikeLike