merge files

Topics: Developer Forum
Jan 19, 2015 at 9:36 AM
Edited Jan 19, 2015 at 9:47 AM
PHPExcel 1.8.0
PHP Version 5.5.9-1ubuntu4.5

Hello.
Sorry for my English. I'm not very good at it.

I can not understand how to combine multiple files into one. In one worksheet.

Now I do like this (get multiple worksheets in a single file):
$filenames = array($obl, $titul);

$bigExcel = new PHPExcel();
$bigExcel->removeSheetByIndex(0);

foreach ($filenames as $filename) {
    $excel = PHPExcel_IOFactory::load($filename);   

    foreach ($excel->getAllSheets() as $sheet) {
        $bigExcel->addExternalSheet($sheet);
    }

    foreach ($excel->getNamedRanges() as $namedRange) {
        $bigExcel->addNamedRange($namedRange);
    }
}

$writer = PHPExcel_IOFactory::createWriter($bigExcel, 'Excel5');

$file_creation_date = date("Y-m-d");

$saving_name = "Report_Name" . $file_creation_date . '.xls';

$writer->save($saving_name);    
But I have to get exactly one worksheet.
How to do it?