im now on working to create import excel/csv to database.
ive tried some extensions, phpoffice/phpexcel, but still can’t find a way.
whenever it tries to load the file, it always shows ‘file does not exist’ message.
ive searched many blogs and posts about the default folder of phpxcel to load the file that we wanted to import, but still no result.
then i tried to placed the excel file inside baseurl folder (Web folder), but still can’t found the file.
but when i tried to access an image, from that folder, the image appears perfectly.
is there any default folder of phpexcel? or is there any other extension that better that phpexcel for import function?
Thank you very much.
here is my load code:
$objPHPExcel = new \PHPExcel();
$objPHPExcel = \PHPExcel_IOFactory::load(\Yii::$app->request->BaseUrl.’/uploads/test.xlsx’);
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
here is the error message:
Could not open /advanced/backend/web/uploads/test.xlsx for reading! File does not exist.
and ive also tried using \Yii::$app->basePath for rooting load path, but still get same error.
Use Composer to install PHPOffice/PHPExcel.
After that, in your controllers use:
$inputFileName = 'template.xlsx';
$excel = \PHPExcel_IOFactory::load($inputFileName);
Please note that my template.xlsx is in my web folder.
Does your test.xlsx exists? Can you check out permissions.
$objPHPExcel = \PHPExcel_IOFactory::load(\Yii::getAlias('@webroot/uploads/test.xlsx'));
No, PHPExcel doesn’t make any assumptions about your app’s directory structure.
It’s your responsibility to specify the correct filesystem path for PHPExcel.
Exactly. When he installs PHPExcel it will be in Vendor folder and that’s it.