Laravel-excel: Need to be able to load a template file, and read and edit specific cells

Created on 11 Jun 2015  ·  3Comments  ·  Source: Maatwebsite/Laravel-Excel

I have a problem with a project I am working on. I have to use specific excel templates file to send data via ftp to a 3rd part integration partner we are working with. The only format their system can accept is xlsx documents.

The problem is that they have lots of data above the column headers, so I basically need to be able to edit these files on a cell by cell basis. Can someone please give me a big of a code example so that I can target specific cells? Perhaps something like cell("B1") or row(5)->column(5)?

I've been looking thru the maatsoftware documentation and I can't seem to find anything specific on it. I found a reference to doing something like this with the phpOffice excel library, but am unsure how to call that via this library. I am using Laravel 4.2. My project was started before Laravel5 came out so I'm kinda stuck in the laravel 4.2 arena.

Thanks in advance for any help.

Wade

Most helpful comment

Hi,

it was not too easy to find out, but I finally got it. I needed it to use var_dump(get_class_methods($reader)); many times until I found the correct method.

$reader->getExcel()->getSheet()->getCell('C7')->getValue() 
 \Excel::selectSheets('Configuration')->load($file->getRealPath(), function($reader) {              
        $reader->getExcel()->getSheet()->getCell('C7')->getValue() ;            
});

it might be useful to someone.

All 3 comments

You can call the PHPExcel native methods in this package.
You can find the wrapper methods in our documentation: http://www.maatwebsite.nl/laravel-excel/docs/export#rows (sections Row & Cell manipulation)

Hi,

it was not too easy to find out, but I finally got it. I needed it to use var_dump(get_class_methods($reader)); many times until I found the correct method.

$reader->getExcel()->getSheet()->getCell('C7')->getValue() 
 \Excel::selectSheets('Configuration')->load($file->getRealPath(), function($reader) {              
        $reader->getExcel()->getSheet()->getCell('C7')->getValue() ;            
});

it might be useful to someone.

Thanks All. I did find a method that worked for me too today.

$excel->getActiveSheet()->getCellByColumnAndRow($col-1, $row-1)->getValue()
and
$excel->getActiveSheet()->setCellValueByColumnAndRow($field[$key],$startRow+1,$value)

I wasn't able to get the getCell() function to work, but I will give your method a try.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings