RiomoX Mouad
RiomoX Mouad

Reputation: 63

How to copy a sheet to another in php laravel excel?

my question is as the title said ! how can i copy an excel sheet content to another using laravel excel of maatwebsite!

Excel::load(Input::file('file'), function($file)
    {     
        $sheet1 = $file->setActiveSheetIndex(0);
        Excel::create('Filename', function($excel) use($sheet1) {
            // Create first sheet
            $excel->sheet('First sheet', function($sheet) use ($sheet1){
                $sheet = $sheet1;
            });
        })->export('xls');
    });

Upvotes: 2

Views: 2244

Answers (1)

Rex
Rex

Reputation: 36

Excel::load(Input::file('file'), function($file)
    {     
        $sheet1 = $file->setActiveSheetIndex(0);
        Excel::create('Filename', function($excel) use($sheet1) {
            // add $sheet1 for new file
            $excel->addExternalSheet($sheet1)
        })->export('xls');
    });

Upvotes: 1

Related Questions