I want to generate an array from my xlsx file first, before I insert it to Mysql, so I am using phpexcel because this one is good enough (I know it from every website's review). But there is a problem when I am trying to making an array from the xlsx defined sheet, here is my script :
<?php
error_reporting(E_ALL);
set_time_limit(0);
date_default_timezone_set('Europe/London');
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Automatic Importer</title>
</head>
<body>
<h1>PHPExcel Reader Example #07</h1>
<h2>Simple File Reader Loading a Single Named WorkSheet</h2>
<?php
/** PHPExcel_IOFactory */
include 'Classes/PHPExcel/IOFactory.php';
//$inputFileType = 'Excel5';
$inputFileType = 'Excel2007';
// $inputFileType = 'Excel2003XML';
// $inputFileType = 'OOCalc';
// $inputFileType = 'Gnumeric';
$inputFileName = 'file.xlsx';
$sheetname = 'My Sheet 4';
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'<br />';
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
echo 'Loading Sheet "',$sheetname,'" only<br />';
$objReader->setLoadSheetsOnly($sheetname);
$objPHPExcel = $objReader->load($inputFileName);
echo '<hr />';
echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />';
$loadedSheetNames = $objPHPExcel->getSheetNames();
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
var_dump($sheetData);
?>
<body>
</html>
and this is the error says :
Fatal error: Call to a member function cellExists() on a non-object in C:\xampp\htdocs\chi\import\Classes\PHPExcel\Calculation.php on line 3241
Can someone tell where is the error is? My OOP is not good, thanks