merge multiple worksheets into 1 worksheet

Topics: Developer Forum, User Forum
Oct 5, 2013 at 8:24 AM
I want to merge worksheets from multiple excel sheets into 1 worksheet in a new excel file.

I referred to the discussion https://phpexcel.codeplex.com/discussions/390898

I did not understand what MarkBaker meant by using toArray(). I mean how do I use it.
My Current Code is:
$file1="file1.xlsx";
$objPHPExcel1 = PHPExcel_IOFactory::load($file1);
$file2="file2.xlsx";
$outputFile = "output.xlsx";

$objPHPExcel2 = PHPExcel_IOFactory::load($file2);
$sheet = $objPHPExcel2->getActiveSheet();
$objPHPExcel1->addExternalSheet($sheet);

$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel1); 
$objWriter->save($outputFile);
With this I am able to get different worksheets of various files into a new workbook but as different sheets.

What should I do to get it all onto the same sheet like vitman said?
first_excel_file_with_one_worksheet
--empty line--
second_excel_file_with_one_worksheet
--empty line--
etc.