I want to read data from excel file (Not from .csv file but from excel file) .

Does anyone know how can i get data from excel file ?

1 Answer 1


Please try this way may it work .

include 'PHPExcel/IOFactory.php'; File Get from this link

$objPHPExcel = PHPExcel_IOFactory::load($location);
    $sheet = $objPHPExcel->getSheet(0);
    $total_rows = $sheet->getHighestRow();
    $total_columns = $sheet->getHighestColumn();
    for($row =2; $row <= $total_rows; $row++) {
        $singlerow = $sheet->rangeToArray('A' . $row . ':' . $total_columns . $row, NULL, TRUE, FALSE);
            $set_excel_query['opus_transaction_date']= date('Y-m-d', PHPExcel_Shared_Date::ExcelToPHP($single_row[4]));
            $set_excel_query['upload_date']= date('Y-m-d', PHPExcel_Shared_Date::ExcelToPHP($single_row[14]));

  • Thanks @Chirag For Answer it is good , but is there any way from magento 2 core without using external library? Dec 26, 2019 at 11:53
  • @SanjayShiyal did you find any solution using Magento2 ? Nov 4, 2020 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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