Open ydakilux opened 4 years ago
Hello,
I have found a solution to change the PageHeader and PageFooter using the BEFORE_SAVE event
I just changed the declaration to
PhpExcelTemplator::BEFORE_SAVE => function(Spreadsheet $spreadsheet, $writer) { .. }
So I just removed the IWriter type, otherwise it generate an exception ( problem between Iwriter and XlsWriter )
For your information information and/or for the example, this is how a change the PageHeader and PageFooter :
$events = [
PhpExcelTemplator::BEFORE_SAVE => function(Spreadsheet $spreadsheet, $writer) {
// fires before saving to a file. It is used when you need to modify the $writer or $spreadsheet object before saving, for example, $writer->setPreCalculateFormulas(false);
// Headers
$spreadsheet->getActiveSheet()->getHeaderFooter()->setOddHeader('New PageHeader Text);
// Footers
$spreadsheet->getActiveSheet()->getHeaderFooter()->setEvenHeader('New Text PageFooter Text');
},
];
I made a small template with your basic template as base and it's working But if the fields are in the Header of the page in Excel, fields are not updated, while the same fields are updated if they are on the page. Just to be sure I have put the same fields in the footer and in a normal cell