I need to create an xls file using lists of other files
I do something like this:
$objReader = PHPExcel_IOFactory::createReader('Excel5');
$file_tmpl = $objReader->load('doc10.xls');
$file_tmpl - the resulting file
$file1 = $objReader->load('doc11.xls');
$file1 - file that is copied sheet
$file1->setActiveSheetIndex(1);
$sheet = $file1->getActiveSheet();
$file_tmpl->addSheet($sheet,1);
As a result, the sheet is copied, except for the style of the cell: the borders, fonts, text size, text color. How to move all together with style?
Thank you.
There is a method built into PHPExcel for this: addExternalSheet()
which copies the styling as well as the content from one workbook to another.
There is a script (43mergeWorkbooks.php
) to demonstrate its use in the /Examples
folder of PHPExcel
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With