我正在尝试使用 PHPExcel 阅读 xlsx 文档。我的文档在我的本地,我的代码向我显示了这个错误。*
无法打开 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() 方法正在查找文件的目录?我迷路了 提前谢谢