我想用PHPExcel讀取xlsx文件。我的文件在我的本地和我的代碼顯示我這個錯誤。 *phpexcel文件不存在
無法打開MunicipioPreinscripcion.xlsx閱讀!文件不存在 。
*
這是我的代碼(我的Excel文檔是我當前的目錄與我的控制器)
#namespace Backend\AlumnosBundle\Controller
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/');
$inputFileName = 'MunicipioPreinscripcion.xlsx';
$inputFileNameWithPath = PHPEXCEL_ROOT.$inputFileName;
if(file_exists($inputFileNameWithPath)) {
echo 'exist'; //Allways show exist
echo $inputFileNameWithPath."<br>";
} else {
echo 'dont exist';
}
/** Identify the type of $inputFileName **/
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
/** Create a new Reader of the type that has been identified **/
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
/** Advise the Reader that we only want to load cell data **/
$objReader->setReadDataOnly(true);
/** Load $inputFileName to a PHPExcel Object **/
$objPHPExcel = $objReader->load($inputFileName); //This is where throw the error
什麼,我做錯了什麼? 如何顯示load()方法查找文件的目錄?我迷路了 在此先感謝
檢查權限,嘗試用完整路徑前綴文件名 –
您是否成功加載phpexcel示例? – periback2
是的,如果你需要一些幫助,你可以聯繫我。 – Freenando