我想用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