PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, October 5, 2022

[FIXED] How to copy a sheet to another in php laravel excel?

 October 05, 2022     excel, laravel, maatwebsite-excel, php, phpexcel     No comments   

Issue

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');
    });

Solution

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');
    });


Answered By - Rex
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing