Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Alexb0903's avatar

Editing an Excel file with maatwebsite/excel

Hi everyone,

I need to do 3 specific thing but i really don't know how to do it in Laravel. Can somone hint me, I Have to

  1. Import an excel file without saving it
  2. Do some modification on the excel file like Calculate field (Seems to have good documentation about that)
  3. Export the new file to the user with the modification on it

In the version 2.1 of the maatwebsite/excel there was this method to do the editing but now it seems to be deprecated

Excel::load('file.csv', function($file) {

    // modify stuff

})->export('csv');

Is there any substitute for this method now because what i need is basically an edit of the file

Thank you very much!

0 likes
2 replies
Alexb0903's avatar

So far, i've made an Import where i change the value of the Collection

 public function collection(Collection $collection)
    {


        foreach ($collection as $row)
        {
           //Change to Collection Here
        }

        $this->data = $collection;

    }

    public function getData() {
        return $this->data;
    }

And then im passing that new Collection in the controller and call the Export class with the new Collection as a parameter for the Data.

Is this a good way to do it or i would gain alot of performance by storing it locally and then deleting it once the export is done?

Please or to participate in this conversation.