2

I had made a custom module for product Import via Xls and xlsx.

Path is :: \Productimport\Controller\Adminhtml\ProductImport i have placed PHPExcel folder and 2 other files here.

In controller I am accessing

$inputFileName = $_FILES["file"]["tmp_name"];
            $dir_val = dirname(__FILE__);
            require_once $dir_val.'/IOFactory.php';
            $inputFileType = PHPExcel_IOFactory::identify($inputFileName);
            $objReader = PHPExcel_IOFactory::createReader($inputFileType);
            $objPHPExcel = $objReader->load($inputFileName);
            $sheet = $objPHPExcel->getSheet(0);
            $highestRow = $sheet->getHighestRow();
            $highestColumn = $sheet->getHighestColumn();

this is giving error

a:4:{i:0;s:197:"Source class "\Fliplearn\Productimport\Controller\Adminhtml\ProductImport\PHPExcel_IO" for "Fliplearn\Productimport\Controller\Adminhtml\ProductImport\PHPExcel_IOFactory" generation does not exist.";i:1;s:6455:"#0 E:\xampp\htdocs\market-release\educomp-online\App\EOL\marketplace\vendor\magento\framework\Code\Generator.php(112): Magento\Framework\Code\Generator->tryToLoadSourceClass('Fliplearn\Produ...', Object(Magento\Framework\ObjectManager\Code\Generator\Factory))

Please give me a solution how can i use this.

  • Vishwas Bhatnagar, did you find an answer for your problem? – mvistas Dec 21 '16 at 13:05
2

As Magento 2 is working with Namespaces, you should add backslashes in front of class names. Use \PHPExcel_IOFactory instead of PHPExcel_IOFactory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.