I have file what have two worksheets which I wish to use as templates.
In php I create new PHPExcel object and load data from first worksheet to it.
$objReader = new PHPExcel_Reader_Excel5();
$objReader->setLoadSheetsOnly('Page1');
$objPHPExcel = $objReader->load('template.xls');
Then I need to create another worksheet in objPHPExcel and fill it with template from worksheet 'Page2' of file template.xls
But when I do like this:
$objReader->setLoadSheetsOnly('Page2');
$objWorksheet = $objPHPExcel->createSheet();
$objWorksheet->setTitle('Sheet'.$sheetIndex);
$objPHPExcel = $objReader->load($timesheetTemplatePath);
I get file with only last results.
How can I create worksheet and read data (with styles) from another file?
Try passing an index to createSheet
method, in this case it would be 1:
$objWorksheet = $objPHPExcel->createSheet(1);
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