1
votes

Is there any way to get the cell value with exact address in Excel?

Like I upload the excel file then return sheet(2).cell(10,1).value ?

Since I am writing a website to upload a excel and put those data into DB, the file's rows and columns are automatically generated and the formats are not exactly matching maatwebsite/Excel's upload sample.

I am using Laravel 5.7 and maatwebsite/Excel 3.1

2
Can you show, what you have tried?Prafulla Kumar Sahu
Please see Daniel's reply , he gave the ans, thanks for your comment~W Kenny

2 Answers

1
votes

I hope this would be help to you.

1
votes

In maatwebsite/Excel 2.* you could fetch the value in the cell with

Excel::load('file.xlsx, function($excel) {
    $cell = $excel->getSheet(2)->getCellByColumnAndRow(10, 1);       
});

These methods have been removed in 3.*

However maatwebsite/Excel is just a wrapper around phpoffice/phpspreadsheet - so we can still call the function directly from that library:

$inputFileName = 'filename.xlsx';

$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);

$cellValue = $spreadsheet->getSheet(2)->getCellByColumnAndRow(10, 1)->getValue();