Answer the question
In order to leave comments, you need to log in
How to merge two files into one phpExcel (one sheet)?
There are two documents, how to connect the contents of one sheet of the first document and the contents of the sheet of the second document, in a new one?
Answer the question
In order to leave comments, you need to log in
stackoverflow.com/questions/31463423/phpexcel-comb...
$objPHPExcel1 = PHPExcel_IOFactory::load("MergeBook1.xlsx");
$objPHPExcel2 = PHPExcel_IOFactory::load("MergeBook2.xlsx");
foreach($objPHPExcel2->getSheetNames() as $sheetName) {
$sheet = $objPHPExcel2->getSheetByName($sheetName);
$sheet->setTitle($sheet->getTitle() . ' copied');
$objPHPExcel1->addExternalSheet($sheet);
}
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel1, 'Excel2007');
$objWriter->save('mergedBooks.xlsx');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question